sync.order.cs 612 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214
  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. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1744815215000,\"deliveryType\":\"OFFLINE\",\"discountFee\":10.5,\"flag\":\"NONE\",\"lines\":[{\"mark2\":[],\"num\":2,\"outerId\":\"\",\"payment\":72.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2214039539799/O1CN01X2VaqK2MFzycDO1WS_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":40.0,\"refOlId\":\"2533697330538960567\",\"refSkuId\":\"0\",\"refSpuId\":\"769985341390\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":36.0,\"singleFee\":36.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"春游横幅定制中小学生研学广告宣传标语手拉条定做踏青露营旗帜布条挂布设计幼儿园户外亲子活动彩色条幅制作\",\"totalFee\":72.0,\"totalPrice\":80.0,\"totalSellPrice\":72.0},{\"mark2\":[],\"num\":25,\"outerId\":\"\",\"payment\":22.5,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2214039539799/O1CN01tmBb3z2MG05SvMQO8_!!2214039539799.jpg\",\"platServiceFee\":0.0,\"price\":1.0,\"refOlId\":\"2533697330539960567\",\"refSkuId\":\"5746227904659\",\"refSpuId\":\"896207996515\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.9,\"singleFee\":0.9,\"spuOuterId\":\"\",\"standards\":\"任意模板尺寸数量均可定制【买贵包退】\",\"status\":\"NOT_SHIPPED\",\"title\":\"纸质票根定制手可撕正副券异形入场券设计纪念广告宣传卡片优惠代金卷印刷活动邀请函来图打印演唱会门票制作\",\"totalFee\":22.5,\"totalPrice\":25.0,\"totalSellPrice\":22.5}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1744820079000,\"openBuyerId\":\"AAFRRHraABkUZRPgSx3jejVC\",\"openBuyerNick\":\"c**\",\"openSellerNick\":\"千方百计旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1744815210000,\"payTime\":1744815211000,\"payment\":94.5,\"platServiceFee\":0.0,\"posCode\":\"qianfangbaiji\",\"posId\":601759,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"深圳市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"南山区\",\"receiverId\":\"0a2d75d6e0dc6d045b27b32102148c0a$\",\"receiverState\":\"广东省\",\"receiverTown\":\"南山街道\",\"refOid\":\"2533697330537960567\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"50x300cm-1张-条幅-红色底-净裁-cherryxu1102-椰子-47,50x100cm-1张-条幅-红色底-四角打孔-cherryxu1102-椰子-47.5\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":94.5,\"totalPrice\":105.0,\"totalSellPrice\":94.5,\"type\":\"SALE\"}}");
  65. //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}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. 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));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string spudata = GetPostString("spudata");
  188. if ("0".Equals(spudata))
  189. {
  190. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  191. }
  192. if ("1".Equals(spudata))
  193. {
  194. lw.Add(string.Format("spu_id <> ''"));
  195. }
  196. string finishdate1 = GetPostString("finishdate1");
  197. string finishdate2 = GetPostString("finishdate2");
  198. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  199. bool isFinish = false;
  200. if (finishdate.Length > 0)
  201. {
  202. lw.Add(finishdate);
  203. isFinish = true;
  204. paramsCount++;
  205. }
  206. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  207. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  208. if (ex_psize > 0)
  209. {
  210. int UserID = CurrentUser.UserID;
  211. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  212. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  213. {
  214. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  215. }
  216. dStruct.Order = "pay_time desc";
  217. }
  218. string isNew = GetPostString("isNew");
  219. if (isNew == "true")
  220. {
  221. lw.Add(string.Format("IsNew = {0}", 1));
  222. }
  223. string overtime = GetPostString("overtime");
  224. if (overtime == "1")
  225. {
  226. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  227. }
  228. String usePost = CurrentUser.UserPost.Post.Code;
  229. if (usePost.Equals("Operation") == true)
  230. {
  231. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  232. }
  233. else
  234. {
  235. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  236. }
  237. //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";
  238. if (dStruct.PageSize == 100000)
  239. {
  240. dStruct.Order = "";
  241. }
  242. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  243. DataTable dt = null;
  244. string tablename = "view_orderlist";
  245. if (isFinish)
  246. {
  247. tablename = "view_orderlist_end";
  248. }
  249. dt = WebCache.GetData(tablename, dStruct);
  250. if (dt != null && dt.Rows.Count > 0)
  251. {
  252. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  253. foreach (DataRow dr in dt.Rows)
  254. {
  255. try
  256. {
  257. if (dr["refund_fees"] != null)
  258. {
  259. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  260. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  261. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  262. if (payment == refund_fees)
  263. {
  264. dr["refund_fees"] = Math.Round(refund_fees, 2);
  265. }
  266. else if (refund_fees == total_fee)
  267. {
  268. dr["refund_fees"] = payment;
  269. }
  270. else
  271. {
  272. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  273. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  274. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  275. }
  276. }
  277. // 对象操作
  278. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  279. ceErpTradeCell.ctid = dr["ctid"].ToString();
  280. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  281. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  282. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  283. if (dStruct.PageSize != 100000)
  284. {
  285. if (dr["DispatchSort"].ToString() == "2")
  286. {
  287. dr["gongchuang"] = 200;
  288. }
  289. else
  290. {
  291. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  292. dr["gongchuang"] = response.code;
  293. }
  294. }
  295. }
  296. catch (NullReferenceException ex)
  297. {
  298. // 处理空引用异常
  299. dr["refund_fees"] = "0.00";
  300. }
  301. }
  302. }
  303. writeGridDataTableJson(dStruct.TotalCount, dt);
  304. }
  305. public void get_erp_orderlist_sumprice()
  306. {
  307. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  308. return;
  309. List<string> lw = new List<string>();
  310. string tid = GetPostString("ctid");
  311. string date1 = GetPostString("date1");
  312. string date2 = GetPostString("date2");
  313. if (tid.Length > 0 || date1.Length > 0)
  314. {
  315. lw.Add(string.Format("ctid like '%{0}%'", tid));
  316. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  317. if (dw.Length > 0) lw.Add(dw);
  318. }
  319. else
  320. {
  321. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  322. }
  323. string shopname = GetPostString("shopname");
  324. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  325. string buyernick = GetPostString("buyer_nick");
  326. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  327. string customer = GetPostString("customer");
  328. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  329. string design = GetPostString("design");
  330. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  331. string orderState = GetPostString("orderState");
  332. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  333. string address = GetPostString("address");
  334. 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));
  335. string sellermemo = GetPostString("seller_memo");
  336. if (sellermemo.Length > 0)
  337. {
  338. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  339. }
  340. string apdate1 = GetPostString("apdate1");
  341. string apdate2 = GetPostString("apdate2");
  342. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  343. if (dwap.Length > 0) lw.Add(dwap);
  344. string price1 = GetPostString("price1");
  345. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  346. string price2 = GetPostString("price2");
  347. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  348. string isoldcustomer = GetPostString("isoldcus");
  349. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  350. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  351. if (PKey != "admin")
  352. {
  353. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  354. lw.Add(string.Format("shopId in ({0})", usershop));
  355. }
  356. //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";
  357. string mainWhere = string.Join(" and ", lw.ToArray());
  358. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  359. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  360. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  361. decimal total = 0;
  362. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  363. {
  364. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  365. }
  366. var res = new
  367. {
  368. data = total
  369. };
  370. string ro_jsond = JsonConvert.SerializeObject(res);
  371. returnSuccess(ro_jsond);
  372. return;
  373. }
  374. public void get_erp_CustomerServiceGather()
  375. {
  376. string userWhere = "", orderWhere = "";
  377. List<string> lw = new List<string>();
  378. string customer = GetPostString("customer");
  379. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  380. string shopname = GetPostString("shopname");
  381. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  382. string date1 = GetPostString("date1");
  383. string date2 = GetPostString("date2");
  384. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  385. if (dw.Length > 0) lw.Add(dw);
  386. orderWhere = string.Join(" and ", lw.ToArray());
  387. 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 " +
  388. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  389. "left join " +
  390. "( " +
  391. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  392. ") as b on a.ID = b.CustomerUserId " +
  393. "left join " +
  394. "( " +
  395. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  396. ") as d on a.ID = d.CustomerUserId " +
  397. "left join " +
  398. "( " +
  399. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  400. ") as e on a.ID = e.CustomerUserId " +
  401. "left join " +
  402. "( " +
  403. " select CustomerUserId, RefundCount, RefundSum from " +
  404. " ( " +
  405. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  406. " from CE_ErpTradeRefund a " +
  407. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  408. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  409. " group by CustomerUserId " +
  410. " ) as a " +
  411. ") as f on a.ID = f.CustomerUserId " +
  412. "where a.PostCode = 'CustomerService'",
  413. userWhere, orderWhere);
  414. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  415. writeGridDataTableJson(dt.Rows.Count, dt);
  416. //writeGridDataTableJson(dt.Rows.Count, dt);
  417. }
  418. //设计汇总
  419. public void get_erp_DesignerGather()
  420. {
  421. string userWhere = "", orderWhere = "";
  422. List<string> lw = new List<string>();
  423. string Designer = GetPostString("designer");
  424. int org = GetPostInt("org");
  425. if (Designer.Length > 0)
  426. {
  427. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  428. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  429. }
  430. else if (org > 0)
  431. {
  432. userWhere = string.Format(" where OrgID ={0}", org);
  433. }
  434. string shopname = GetPostString("shopname");
  435. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  436. string state = GetPostString("state");
  437. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  438. string OrderArea = GetPostString("order_area");
  439. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  440. string date1 = GetPostString("date1");
  441. string date2 = GetPostString("date2");
  442. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  443. if (dw.Length > 0) lw.Add(dw);
  444. string UpDate1 = GetPostString("UpDate1");
  445. string UpDate2 = GetPostString("UpDate2");
  446. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  447. if (dw.Length > 0) lw.Add(dw);
  448. orderWhere = string.Join(" and ", lw.ToArray());
  449. 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 (" +
  450. "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 " +
  451. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  452. "left join " +
  453. "( " +
  454. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  455. ") as b on a.ID = b.DesignUserId " +
  456. "left join " +
  457. "( " +
  458. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  459. ") as d on a.ID = d.DesignUserId " +
  460. "left join " +
  461. "( " +
  462. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  463. ") as e on a.ID = e.DesignUserId " +
  464. "left join " +
  465. "( " +
  466. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  467. ") as g on a.ID = g.DesignUserId " +
  468. "left join " +
  469. "( " +
  470. " select CustomerUserId, RefundCount, RefundSum from " +
  471. " ( " +
  472. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  473. " from CE_ErpTradeRefund a " +
  474. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  475. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  476. " group by CustomerUserId " +
  477. " ) as a " +
  478. ") as f on a.ID = f.CustomerUserId " +
  479. "where a.PostCode = 'Designer') as z",
  480. userWhere, orderWhere);
  481. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  482. writeGridDataTableJson(dt.Rows.Count, dt);
  483. }
  484. //删除tradecell的订单
  485. public void del_erp_cellorder()
  486. {
  487. if (UrlPostParmsCheck("ctid"))
  488. {
  489. string eid = GetPostString("ctid");
  490. CeErpTradeCell.DelByCtid(eid);
  491. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  492. returnSuccessMsg("删除成功");
  493. }
  494. }
  495. public void clear_erp_refundstate()
  496. {
  497. if (UrlPostParmsCheck("ids"))
  498. {
  499. string eids = GetPostString("ids");
  500. string[] ctidList = eids.Split(',');
  501. foreach (string ctid in ctidList)
  502. {
  503. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  504. if (entity != null)
  505. {
  506. entity.IsRefund = 0;
  507. entity.Update();
  508. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  509. }
  510. else
  511. continue;
  512. }
  513. returnSuccessMsg("操作成功");
  514. return;
  515. }
  516. returnErrorMsg("缺少必要参数");
  517. }
  518. public void set_erp_urgency()
  519. {
  520. if (UrlPostParmsCheck("ctid"))
  521. {
  522. string eid = GetPostString("ctid");
  523. CeErpTradeCell entity = null;
  524. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  525. if (entity != null)
  526. {
  527. string utime = GetPostString("urgencytime");
  528. if (utime.Length > 0)
  529. {
  530. entity.UrgencyTime = Convert.ToDateTime(utime);
  531. }
  532. else
  533. {
  534. returnErrorMsg("请选择加急时间");
  535. return;
  536. }
  537. if (entity.OrderState <= 4)
  538. {
  539. //entity.seller_memo = entity.seller_memo + "-加急";
  540. string smemo = entity.seller_memo;
  541. int kindex = smemo.IndexOf(")");
  542. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  543. if (lastoneStr != "-")
  544. {
  545. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  546. }
  547. string prememo = smemo.Substring(0, kindex + 2);
  548. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  549. int lastkindex = lastmemo.IndexOf("(");
  550. DateTime urgtime = Convert.ToDateTime(utime);
  551. string newlastmemo = "";
  552. if (lastkindex == 0)
  553. {
  554. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  555. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  556. }
  557. else
  558. {
  559. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  560. }
  561. entity.seller_memo = prememo + newlastmemo;
  562. }
  563. entity.IsUrgency = true;
  564. entity.UpdateTime = DateTime.Now;
  565. entity.Update();
  566. ApiVo apiVo = new ApiVo();
  567. apiVo.orderNumber = entity.ctid;
  568. apiVo.actionName = "changeDesign";
  569. apiVo.orderRemarks = entity.seller_memo;
  570. apiVo.remarkSign = 3;
  571. designHelper.API_WorkCore(apiVo); //changeDesign
  572. CeErpSukuraData.createInfo(entity.ctid, 7);
  573. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  574. returnSuccessMsg("设置成功!");
  575. return;
  576. }
  577. returnErrorMsg("找不到记录");
  578. }
  579. }
  580. public void set_erp_reset()
  581. {
  582. if (UrlPostParmsCheck("ctid"))
  583. {
  584. string eid = GetPostString("ctid");
  585. CeErpTradeCell entity = null;
  586. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  587. if (entity != null)
  588. {
  589. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  590. {
  591. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  592. {
  593. returnErrorMsg("财务要求已下单已发货无法重置");
  594. return;
  595. }
  596. }
  597. entity.IsUrgency = false;
  598. entity.seller_memo = "";
  599. entity.OtherMemo = "";
  600. entity.OrderState = 0;
  601. entity.IsReturn = 0;
  602. //entity.IsRefund = 0;
  603. entity.MemoOpt = 0;
  604. entity.AfterSaleState = 0;
  605. entity.AfterSaleResponsible = "";
  606. entity.AfterSaleUserId = 0;
  607. entity.IsNeedBill = 0;
  608. entity.CustomerUserId = 0;
  609. entity.DesignUserId = 0;
  610. entity.SupplierId = 0;
  611. entity.PlaceUserId = 0;
  612. entity.ptid = "";
  613. entity.IsSample = 0;
  614. entity.IsXianHuo = 0;
  615. entity.isDianziOrder = 0;
  616. entity.DispatchSort = 0;
  617. entity.FinishPlaceTime = null;
  618. entity.Update();
  619. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  620. if (trade != null)
  621. {
  622. trade.seller_memo = "";
  623. trade.Update();
  624. }
  625. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  626. returnSuccessMsg("重置成功!");
  627. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  628. if (desginBill != null)
  629. {
  630. desginBill.isDel = 1;
  631. desginBill.Update();
  632. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  633. }
  634. ApiVo apiVo = new ApiVo();
  635. apiVo.orderNumber = entity.ctid;
  636. apiVo.actionName = "resetDesign";
  637. designHelper.API_WorkCore(apiVo);//resetDesign
  638. return;
  639. }
  640. returnErrorMsg("找不到记录");
  641. }
  642. }
  643. public void save_erp_sellermemo()
  644. {
  645. if (UrlPostParmsCheck("ctid"))
  646. {
  647. string ctid = GetPostString("ctid");
  648. CeErpTradeCell entity = null;
  649. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  650. if (entity != null)
  651. {
  652. string memo = GetPostString("seller_memo");
  653. memo = memo.Replace(" ", "");
  654. if (memo.Contains("补差"))
  655. {
  656. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  657. return;
  658. }
  659. if (entity.seller_memo != memo)
  660. {
  661. if (entity.IsSample == 2)
  662. {
  663. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  664. return;
  665. }
  666. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  667. {
  668. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  669. {
  670. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  671. return;
  672. }
  673. }
  674. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  675. }
  676. commonHelper.getCytPrice(entity);
  677. int memoopt = GetPostInt("MemoOpt");
  678. Boolean ismemoopt = false;
  679. if (memoopt > 0)
  680. {
  681. string stropt = "";
  682. if (memoopt == 1)
  683. {
  684. stropt = "“改稿”";
  685. ismemoopt = true;
  686. }
  687. else if (memoopt == 2)
  688. {
  689. stropt = "“定稿”";
  690. }
  691. else if (memoopt == 3)
  692. {
  693. stropt = "“查货”";
  694. CeErpSukuraData.createInfo(entity.ctid, 6);
  695. }
  696. entity.MemoOpt = Convert.ToInt32(memoopt);
  697. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  698. }
  699. if (entity.OrderState < 5)
  700. {
  701. memo = memo.Replace("(", "(");
  702. memo = memo.Replace(")", ")");
  703. }
  704. entity.seller_memo = memo;
  705. entity.UpdateTime = DateTime.Now;
  706. entity.Update();
  707. ApiVo apiVo = new ApiVo();
  708. apiVo.orderNumber = entity.ctid;
  709. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  710. apiVo.orderRemarks = memo;
  711. apiVo.remarkSign = memoopt;
  712. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  713. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  714. returnSuccessMsg("保存成功!");
  715. return;
  716. }
  717. returnErrorMsg("找不到记录");
  718. }
  719. }
  720. public void ins_erp_checkorder()
  721. {
  722. if (UrlPostParmsCheck("ctid"))
  723. {
  724. string ctid = GetPostString("ctid");
  725. CeErpTradeCell entity = null;
  726. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  727. if (entity != null)
  728. {
  729. if (entity.OrderState < 6)
  730. {
  731. returnErrorMsg("下单完成后才可查货");
  732. return;
  733. }
  734. /*if (entity.OrderState > 6)
  735. {
  736. returnErrorMsg("订单已发货");
  737. return;
  738. }*/
  739. if (entity.FinishPlaceTime != null)
  740. {
  741. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  742. {
  743. returnErrorMsg("下单时间不足,无法查货");
  744. return;
  745. }
  746. }
  747. entity.MemoOpt = 3;
  748. entity.CheckOrderTime = DateTime.Now;
  749. entity.UpdateTime = DateTime.Now;
  750. entity.Update();
  751. CeErpSukuraData.createInfo(entity.ctid, 6);
  752. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  753. returnSuccessMsg("操作成功!");
  754. return;
  755. }
  756. returnErrorMsg("找不到记录");
  757. }
  758. }
  759. public void save_erp_othermemo()
  760. {
  761. if (UrlPostParmsCheck("ctid"))
  762. {
  763. string ctid = GetPostString("ctid");
  764. CeErpTradeCell entity = null;
  765. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  766. if (entity != null)
  767. {
  768. entity.OtherMemo = GetPostString("otherMemo");
  769. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  770. {
  771. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  772. StringBuilder sql = new StringBuilder();
  773. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  774. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  775. if (dt != null && dt.Rows.Count > 0)
  776. {
  777. foreach (DataRow dr in dt.Rows)
  778. {
  779. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  780. {
  781. //品类一直
  782. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  783. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  784. if (ceErpSampleCustomer == null)
  785. {
  786. ceErpSampleCustomer = new CeErpSampleCustomer();
  787. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  788. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  789. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  790. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  791. ceErpSampleCustomer.shopId = entity.ShopId;
  792. }
  793. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  794. ceErpSampleCustomer.lastTid = entity.tid;
  795. if (ceErpSampleCustomer.ID > 0)
  796. {
  797. ceErpSampleCustomer.Update();
  798. }
  799. else
  800. {
  801. ceErpSampleCustomer.Create();
  802. }
  803. }
  804. }
  805. }
  806. }
  807. //if (entity.IsOldCustomer == 1)
  808. //{
  809. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  810. //{
  811. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  813. //}
  814. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  815. //{
  816. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  817. // {
  818. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  819. // {
  820. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  821. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  822. // }
  823. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  824. // {
  825. // entity.OrderState = 2;
  826. // entity.DesignUserId = 0;
  827. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  828. // }
  829. // else
  830. // {
  831. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  832. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  833. // }
  834. // }
  835. //}
  836. //}
  837. entity.Update();
  838. returnSuccessMsg("保存成功!");
  839. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  840. return;
  841. }
  842. returnErrorMsg("找不到记录");
  843. }
  844. }
  845. public void save_erp_customermemo()
  846. {
  847. if (UrlPostParmsCheck("ctid"))
  848. {
  849. string ctid = GetPostString("ctid");
  850. CeErpTradeCell entity = null;
  851. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  852. if (entity != null)
  853. {
  854. entity.CustomerMemo = GetPostString("CustomerMemo");
  855. entity.Update();
  856. ApiVo apiVo = new ApiVo();
  857. apiVo.orderNumber = entity.ctid;
  858. apiVo.actionName = "followRemarks";
  859. apiVo.orderRemarks = entity.CustomerMemo;
  860. designHelper.API_WorkCore(apiVo);//followRemarks
  861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  862. returnSuccessMsg("保存成功!");
  863. return;
  864. }
  865. returnErrorMsg("找不到记录");
  866. }
  867. }
  868. public void upd_erp_addmemotag()
  869. {
  870. if (UrlPostParmsCheck("ctid"))
  871. {
  872. ;
  873. string eid = GetPostString("ctid");
  874. string sfTagstr = GetPostString("memotag");
  875. CeErpTradeCell entity = null;
  876. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  877. if (entity != null)
  878. {
  879. ApiVo apiVo = new ApiVo();
  880. if (entity.OrderState == 0)
  881. {
  882. returnErrorMsg("请先领单");
  883. return;
  884. }
  885. //撤销顺丰
  886. if (sfTagstr == "撤销顺丰")
  887. {
  888. entity.IsSF = 0;
  889. string reMsg = "";
  890. string oldmemo = entity.seller_memo;
  891. if (entity.OrderState < 5)
  892. {
  893. oldmemo = oldmemo.Replace("顺丰到付", "");
  894. oldmemo = oldmemo.Replace("顺丰寄付", "");
  895. entity.seller_memo = oldmemo;
  896. }
  897. else
  898. {
  899. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  900. {
  901. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  902. }
  903. }
  904. entity.Update();
  905. apiVo.orderNumber = entity.ctid;
  906. apiVo.actionName = "orderRemarks";
  907. apiVo.orderRemarks = entity.seller_memo;
  908. apiVo.isSf = entity.IsSF.ToString();
  909. designHelper.API_WorkCore(apiVo);//orderRemarks
  910. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  911. returnSuccessMsg("撤销成功!" + reMsg);
  912. return;
  913. }
  914. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  915. {
  916. //string oldmemo = entity.seller_memo;
  917. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  918. string sfStr = GetPostString("memotag");
  919. string smemo = entity.seller_memo;
  920. int kindex = smemo.IndexOf(")");
  921. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  922. if (lastoneStr != "-")
  923. {
  924. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  925. }
  926. string prememo = smemo.Substring(0, kindex + 2);
  927. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  928. int lastkindex = lastmemo.IndexOf("(");
  929. string newlastmemo = "";
  930. if (lastkindex == 0)
  931. {
  932. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  933. newlastmemo = "(" + sfStr + "." + useLastmemo;
  934. }
  935. else
  936. {
  937. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  938. }
  939. entity.seller_memo = prememo + newlastmemo;
  940. }
  941. string sfTagMSg = "";
  942. if (sfTagstr == "顺丰寄付")
  943. {
  944. entity.IsSF = 1;
  945. sfTagMSg = "顺丰寄付";
  946. }
  947. else if (sfTagstr == "顺丰到付")
  948. {
  949. entity.IsSF = 2;
  950. sfTagMSg = "顺丰到付";
  951. }
  952. entity.Update();
  953. apiVo = new ApiVo();
  954. apiVo.orderNumber = entity.ctid;
  955. apiVo.actionName = "orderRemarks";
  956. apiVo.orderRemarks = entity.seller_memo;
  957. apiVo.isSf = entity.IsSF.ToString();
  958. designHelper.API_WorkCore(apiVo);//orderRemarks
  959. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  960. returnSuccessMsg("标记成功!");
  961. return;
  962. }
  963. returnErrorMsg("找不到记录");
  964. }
  965. }
  966. public void upd_erp_ordertag()
  967. {
  968. if (UrlPostParmsCheck("ctid"))
  969. {
  970. string eid = GetPostString("ctid");
  971. CeErpTradeCell entity = null;
  972. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  973. if (entity != null)
  974. {
  975. int tag = GetPostInt("wechattag");
  976. //if(tag==4 && entity.IsSample == 2)
  977. //{
  978. // returnErrorMsg("补差价单不能标记微信单");
  979. // return;
  980. //}
  981. entity.wechatTag = tag;
  982. entity.Update();
  983. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  984. if (tag == 1)
  985. {
  986. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  987. if (cash == null)
  988. {
  989. CeErpTrade main = CeErpTrade.Get(entity.tid);
  990. cash = new CeErpReturnCash();
  991. cash.tid = entity.tid;
  992. cash.seller_nick = main.seller_nick;
  993. cash.payment = trade.payment;
  994. cash.buyer_nick = main.buyer_nick;
  995. cash.cashstate = 0;
  996. cash.rtype = "微信返现";
  997. cash.returnprice = 0;
  998. cash.created = DateTime.Now;
  999. cash.con = "订单标记微信单";
  1000. cash.img = "";
  1001. cash.applyuserid = CurrentUser.UserID;
  1002. cash.Create();
  1003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1004. }
  1005. else
  1006. {
  1007. cash.cashstate = 0;
  1008. cash.Update();
  1009. }
  1010. CeErpSukuraData.createInfo(entity.ctid, 9);
  1011. }
  1012. else if (tag == 2)
  1013. {
  1014. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1015. if (cash == null)
  1016. {
  1017. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1018. cash = new CeErpReturnCash();
  1019. cash.tid = entity.tid;
  1020. cash.seller_nick = main.seller_nick;
  1021. cash.payment = trade.payment;
  1022. cash.buyer_nick = main.buyer_nick;
  1023. cash.cashstate = 0;
  1024. cash.rtype = "推购返现";
  1025. cash.returnprice = 5;
  1026. cash.created = DateTime.Now;
  1027. cash.con = "订单标记推购单";
  1028. cash.img = "";
  1029. cash.applyuserid = CurrentUser.UserID;
  1030. cash.Create();
  1031. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1032. }
  1033. else
  1034. {
  1035. cash.cashstate = 0;
  1036. cash.Update();
  1037. }
  1038. CeErpSukuraData.createInfo(entity.ctid, 9);
  1039. }
  1040. else if (tag == 3)
  1041. {
  1042. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1043. if (pers == null)
  1044. {
  1045. pers = new CeErpPersuade();
  1046. pers.ctid = entity.ctid;
  1047. pers.pstate = 0;
  1048. pers.created = DateTime.Now;
  1049. pers.applyuserid = CurrentUser.UserID;
  1050. pers.Create();
  1051. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1052. }
  1053. else
  1054. {
  1055. pers.pstate = 0;
  1056. pers.Update();
  1057. }
  1058. }
  1059. else if (tag == 4 || tag == 5)
  1060. {
  1061. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1062. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1063. if (pers == null)
  1064. {
  1065. pers = new CeErpStayGoods();
  1066. pers.t_id = entity.tid;
  1067. pers.status = "待审核";
  1068. pers.audit_type = 0;
  1069. if (tag == 4)
  1070. {
  1071. pers.stay_type = "微信推购";
  1072. }
  1073. else
  1074. {
  1075. pers.stay_type = "旺旺推购";
  1076. }
  1077. if (entity.IsXianHuo == 0)
  1078. {
  1079. pers.product_id = entity.ProductId;
  1080. }
  1081. pers.wangwang = main.buyer_nick;
  1082. pers.shop_name = main.seller_nick;
  1083. pers.creata_time = DateTime.Now;
  1084. pers.create_u_id = CurrentUser.UserID;
  1085. pers.create_u_name = CurrentUser.UserName;
  1086. pers.Create();
  1087. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1088. }
  1089. else
  1090. {
  1091. pers.audit_type = 0;
  1092. pers.Update();
  1093. }
  1094. CeErpSukuraData.createInfo(entity.ctid, 10);
  1095. }
  1096. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1097. returnSuccessMsg("标记成功!");
  1098. return;
  1099. }
  1100. returnErrorMsg("找不到记录");
  1101. }
  1102. }
  1103. public void upd_erp_ordertag_cancel()
  1104. {
  1105. if (UrlPostParmsCheck("ctid"))
  1106. {
  1107. string eid = GetPostString("ctid");
  1108. CeErpTradeCell entity = null;
  1109. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1110. if (entity != null)
  1111. {
  1112. entity.wechatTag = 0;
  1113. entity.Update();
  1114. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1115. if (pers != null)
  1116. {
  1117. pers.status = "取消推购";
  1118. pers.audit_type = 3;
  1119. pers.Update();
  1120. }
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1122. returnSuccessMsg("标记成功!");
  1123. return;
  1124. }
  1125. returnErrorMsg("找不到记录");
  1126. }
  1127. }
  1128. public void upd_erp_addweichattag()
  1129. {
  1130. if (UrlPostParmsCheck("ctid"))
  1131. {
  1132. ;
  1133. string eid = GetPostString("ctid");
  1134. CeErpTradeCell entity = null;
  1135. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1136. if (entity != null)
  1137. {
  1138. if (entity.IsAddWechat > 0)
  1139. {
  1140. returnErrorMsg("此单已经标记过了");
  1141. return;
  1142. }
  1143. 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);
  1144. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1145. if (dt.Rows.Count > 0)
  1146. {
  1147. entity.IsAddWechat = 2;
  1148. }
  1149. else
  1150. {
  1151. entity.IsAddWechat = 1;
  1152. }
  1153. entity.Update();
  1154. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1155. returnSuccessMsg("标记成功!");
  1156. return;
  1157. }
  1158. returnErrorMsg("找不到记录");
  1159. }
  1160. }
  1161. public void upd_erp_getmyorder()
  1162. {
  1163. if (UrlPostParmsCheck("ctid"))
  1164. {
  1165. ;
  1166. string eid = GetPostString("ctid");
  1167. CeErpTradeCell entity = null;
  1168. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1169. if (entity != null)
  1170. {
  1171. if (entity.ctid.IndexOf("C") != -1)
  1172. {
  1173. StringBuilder sql = new StringBuilder();
  1174. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1175. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1176. if (dt.Rows.Count > 0)
  1177. {
  1178. decimal total = 0;
  1179. foreach (DataRow dr in dt.Rows)
  1180. {
  1181. total += Convert.ToDecimal(dr["payment"]);
  1182. }
  1183. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1184. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1185. {
  1186. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1187. return;
  1188. }
  1189. }
  1190. }
  1191. if (entity.OrderState == -1)
  1192. {
  1193. returnErrorMsg("待审核订单无法领取!");
  1194. return;
  1195. }
  1196. entity.CustomerUserId = CurrentUser.UserID;
  1197. if (entity.OrderState < 2)
  1198. {
  1199. entity.OrderState = 2;
  1200. if (entity.ShopId != 0)
  1201. {
  1202. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1203. }
  1204. }
  1205. entity.UpdateTime = DateTime.Now;
  1206. entity.Update();
  1207. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1208. returnSuccessMsg("领单成功!");
  1209. return;
  1210. }
  1211. returnErrorMsg("找不到记录");
  1212. }
  1213. }
  1214. public void getmyorder_from_init()
  1215. {
  1216. if (UrlPostParmsCheck("ctid"))
  1217. {
  1218. string eid = GetPostString("ctid");
  1219. CeErpTradeCell entity = null;
  1220. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1221. if (entity != null)
  1222. {
  1223. string sellerMemo = GetPostString("sellerMemo");
  1224. if (sellerMemo.Length > 0)
  1225. {
  1226. entity.seller_memo = sellerMemo;
  1227. }
  1228. string oterhMemo = GetPostString("otherMemo");
  1229. if (oterhMemo.Length > 0)
  1230. {
  1231. entity.OtherMemo = oterhMemo;
  1232. }
  1233. int urg = GetPostInt("urgency");
  1234. entity.IsUrgency = (urg == 1 ? true : false);
  1235. int wechat = GetPostInt("wechat");
  1236. int command = GetPostInt("command");
  1237. if (wechat == 1)
  1238. {
  1239. entity.wechatTag = 1;
  1240. }
  1241. if (command == 1)
  1242. {
  1243. entity.wechatTag = 2;
  1244. }
  1245. string pPro = GetPostString("pprofession");
  1246. if (pPro.Length > 0)
  1247. {
  1248. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1249. string spro = GetPostString("profession");
  1250. if (spro.Length > 0)
  1251. {
  1252. entity.ProfessionId = Convert.ToInt32(spro);
  1253. }
  1254. }
  1255. string proId = GetPostString("productId");
  1256. if (proId.Length > 0)
  1257. {
  1258. entity.ProductId = Convert.ToInt32(proId);
  1259. }
  1260. entity.Material = GetPostString("material");
  1261. entity.Craft = GetPostString("craft");
  1262. entity.CustomerUserId = CurrentUser.UserID;
  1263. if (entity.OrderState < 2)
  1264. {
  1265. entity.OrderState = 2;
  1266. if (entity.ShopId != 0)
  1267. {
  1268. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1269. }
  1270. }
  1271. entity.Update();
  1272. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1273. returnSuccessMsg("领单成功!");
  1274. return;
  1275. }
  1276. returnErrorMsg("找不到记录");
  1277. }
  1278. }
  1279. public void upd_erp_setrelationorder()
  1280. {
  1281. if (UrlPostParmsCheck("ctid"))
  1282. {
  1283. ;
  1284. string eid = GetPostString("ctid");
  1285. string ftid = GetPostString("ftid");
  1286. CeErpTradeCell entity = null;
  1287. CeErpTradeCell fentity = null;
  1288. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1289. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1290. if (fentity == null)
  1291. {
  1292. returnErrorMsg("找不到关联的主订单");
  1293. return;
  1294. }
  1295. if (entity != null)
  1296. {
  1297. if (entity.OrderState >= 5)
  1298. {
  1299. returnErrorMsg("本单已经设计完成无法关联");
  1300. return;
  1301. }
  1302. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1303. {
  1304. returnErrorMsg("线下单续审核后才能关联!");
  1305. return;
  1306. }
  1307. entity.ptid = ftid;
  1308. entity.OrderState = fentity.OrderState;
  1309. //entity.status = fentity.status;
  1310. entity.CustomerUserId = fentity.CustomerUserId;
  1311. entity.DesignUserId = fentity.DesignUserId;
  1312. entity.seller_memo = "补差价单:" + ftid;
  1313. entity.IsSample = 2;
  1314. entity.Update();
  1315. ApiVo apiVo = new ApiVo();
  1316. apiVo.orderNumber = ftid;
  1317. apiVo.payment = entity.payment;
  1318. apiVo.actionName = "repairDesign";
  1319. designHelper.API_WorkCore(apiVo);//repairDesign
  1320. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1321. returnSuccessMsg("关联成功!");
  1322. return;
  1323. }
  1324. else
  1325. returnErrorMsg("找不到记录");
  1326. }
  1327. }
  1328. public void download_erp_neworder()
  1329. {
  1330. string seller = GetPostString("seller_nick");
  1331. string tid = GetPostString("tid");
  1332. if (seller.Length <= 0 || tid.Length <= 0)
  1333. {
  1334. returnErrorMsg("数据错误");
  1335. }
  1336. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1337. //{
  1338. // returnErrorMsg("找不到店铺Sessionkey");
  1339. //}
  1340. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1341. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1342. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1343. if (res.IndexOf("refOid") == -1)
  1344. {
  1345. returnErrorMsg("下载订单数据失败");
  1346. return;
  1347. }
  1348. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1349. returnSuccessMsg("下载完成");
  1350. //tmcHelper.createNewOrder(res);
  1351. //CeErpTrade entr = null;
  1352. //entr = CeErpTrade.Get(tid);
  1353. //if (entr != null)
  1354. //{
  1355. // returnSuccess("下载成功");
  1356. // //下载成功之后,Cell表生成对应的订单;
  1357. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1358. //}
  1359. //else
  1360. //{
  1361. // returnErrorMsg("下载失败或者创建订单失败");
  1362. //}
  1363. }
  1364. public void set_erp_atersale()
  1365. {
  1366. if (UrlPostParmsCheck("ctid"))
  1367. {
  1368. string eid = GetPostString("ctid");
  1369. string reason = GetPostString("AfterSaleReason");
  1370. CeErpTradeCell entity = null;
  1371. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1372. if (entity != null)
  1373. {
  1374. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1375. {
  1376. returnErrorMsg("此订单已经在售后");
  1377. return;
  1378. }
  1379. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1380. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1381. entity.AfterSaleTime = DateTime.Now;
  1382. entity.Update();
  1383. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1384. returnSuccessMsg("转售后成功!");
  1385. return;
  1386. }
  1387. returnErrorMsg("找不到记录");
  1388. }
  1389. }
  1390. public void set_erp_withdraw()
  1391. {
  1392. if (UrlPostParmsCheck("ctid"))
  1393. {
  1394. try
  1395. {
  1396. string eid = GetPostString("ctid");//商品id
  1397. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1398. CeWithdraw ceWithdrawSelect = null;
  1399. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1400. if (ceWithdrawSelect != null)
  1401. {
  1402. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1403. {
  1404. ceWithdrawSelect.status = -1;
  1405. ceWithdrawSelect.Update();
  1406. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1407. returnSuccessMsg("重新发起审核成功");
  1408. return;
  1409. }
  1410. else
  1411. {
  1412. returnSuccessMsg("请勿重复申请!");
  1413. return;
  1414. }
  1415. }
  1416. else
  1417. {
  1418. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1419. if (string.IsNullOrEmpty(CustomerUserId))
  1420. {
  1421. CustomerUserId = "-1";
  1422. }
  1423. int Userid = CurrentUser.UserID;//用户id
  1424. CeWithdraw ceWithdraw = new CeWithdraw();
  1425. ceWithdraw.tid = eid;
  1426. ceWithdraw.userid = Userid;
  1427. ceWithdraw.providerid = CustomerUserId;
  1428. ceWithdraw.status = 3;
  1429. ceWithdraw.creationtime = DateTime.Now;
  1430. ceWithdraw.Create();
  1431. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1432. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1433. return;
  1434. }
  1435. }
  1436. catch
  1437. {
  1438. returnErrorMsg("申请撤回订单失败");
  1439. return;
  1440. }
  1441. }
  1442. }
  1443. public void ins_erp_billinfo()
  1444. {
  1445. if (UrlPostParmsCheck("ctid"))
  1446. {
  1447. string eid = GetPostString("ctid");
  1448. CeErpTradeCell entity = null;
  1449. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1450. if (entity != null)
  1451. {
  1452. CeErpBill bill = CeErpBill.GetByTid(eid);
  1453. bool isHave = false;
  1454. if (bill != null)
  1455. {
  1456. isHave = true;
  1457. if (bill.state != 4)
  1458. {
  1459. returnErrorMsg("此单已经申请过发票了");
  1460. return;
  1461. }
  1462. }
  1463. if (entity.IsNeedBill == 0)
  1464. {
  1465. entity.IsNeedBill = 1;
  1466. }
  1467. entity.Update();
  1468. string errjson = "";
  1469. try
  1470. {
  1471. CeErpBill bill_entity = new CeErpBill();
  1472. bill_entity.tid = entity.tid;
  1473. bill_entity.title = GetPostString("title");
  1474. string taxstr = GetPostString("tax");
  1475. taxstr = taxstr.Replace(" ", "");
  1476. bill_entity.tax = taxstr;
  1477. bill_entity.bank = GetPostString("bank");
  1478. string bankacstr = GetPostString("bankac");
  1479. bankacstr = bankacstr.Replace(" ", "");
  1480. bill_entity.bankac = bankacstr;
  1481. bill_entity.address = GetPostString("address");
  1482. bill_entity.phone = GetPostString("phone");
  1483. bill_entity.price = GetPostString("price");
  1484. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1485. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1486. {
  1487. billCount += 1;
  1488. }
  1489. string prebill = "ltb";
  1490. for (int idx = 1; idx <= billCount; idx++)
  1491. {
  1492. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1493. string billoid = prebill + idx + dtstr;
  1494. bill_entity.billOrderId += billoid;
  1495. if (idx < billCount)
  1496. {
  1497. bill_entity.billOrderId += ",";
  1498. }
  1499. }
  1500. bill_entity.productId = GetPostInt("ProductName");
  1501. bill_entity.num = GetPostInt("num");
  1502. bill_entity.unit = GetPostString("unit");
  1503. bill_entity.type = GetPostString("type");
  1504. bill_entity.sendType = GetPostString("SendType");
  1505. bill_entity.email = GetPostString("email");
  1506. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1507. bill_entity.shopName = GetPostString("ShopName");
  1508. bill_entity.applymemo = GetPostString("applyMemo");
  1509. bill_entity.createTime = DateTime.Now;
  1510. bill_entity.state = 0;
  1511. bill_entity.userId = CurrentUser.UserID;
  1512. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1513. bill_entity.Create();
  1514. }
  1515. catch (Exception ex)
  1516. {
  1517. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1518. returnErrorMsg("创建发票出错!");
  1519. return;
  1520. }
  1521. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1522. returnSuccessMsg("发票申请成功!");
  1523. return;
  1524. }
  1525. returnErrorMsg("找不到记录");
  1526. }
  1527. }
  1528. public void ins_erp_neworder()
  1529. {
  1530. if (UrlPostParmsCheck("receiver_name"))
  1531. {
  1532. CeErpTrade entity = new CeErpTrade();
  1533. string plat_form = GetPostString("platform");
  1534. string preStr = "N_";
  1535. if (plat_form == "拼多多")
  1536. {
  1537. preStr = "P_";
  1538. }
  1539. else if (plat_form == "阿里巴巴")
  1540. {
  1541. preStr = "A_";
  1542. }
  1543. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1544. entity.seller_nick = GetPostString("seller_nick");
  1545. entity.buyer_nick = GetPostString("buyer_nick");
  1546. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1547. entity.total_fee = entity.payment;
  1548. entity.pay_time = DateTime.Now;
  1549. entity.status = "NOT_SHIPPED";
  1550. entity.receiver_name = GetPostString("receiver_name");
  1551. entity.receiver_mobile = GetPostString("receiver_mobile");
  1552. entity.receiver_state = GetPostString("receiver_state");
  1553. entity.receiver_city = GetPostString("receiver_city");
  1554. entity.receiver_district = GetPostString("receiver_district");
  1555. entity.receiver_address = GetPostString("receiver_address");
  1556. if (entity.receiver_state == "" || entity.receiver_city == "")
  1557. {
  1558. returnErrorMsg("收件地址不能为空");
  1559. return;
  1560. }
  1561. int shopId = 0;
  1562. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1563. if (nShop != null)
  1564. {
  1565. shopId = nShop.ID;
  1566. }
  1567. if (shopId != 34 && entity.payment == 0)
  1568. {
  1569. returnErrorMsg("公司自用的单金额才能为0");
  1570. return;
  1571. }
  1572. entity.Create();
  1573. CeErpTradeCell entitycell = new CeErpTradeCell();
  1574. entitycell.ctid = entity.tid;
  1575. entitycell.tid = entity.tid;
  1576. entitycell.ShopId = shopId;
  1577. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1578. entitycell.OrderState = 0;
  1579. entitycell.pay_time = entity.pay_time;
  1580. entitycell.IsOffLineOrder = 1;
  1581. entitycell.Create();
  1582. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1583. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1584. return;
  1585. }
  1586. }
  1587. public void ins_erp_neworder2()
  1588. {
  1589. if (UrlPostParmsCheck("receiver_name"))
  1590. {
  1591. //string plat_form = GetPostString("platform");
  1592. string preStr = "X_";
  1593. string memo = GetPostString("memo");
  1594. string productId = GetPostString("productId");
  1595. string primg = GetPostString("proofimg");
  1596. string sellerNick = GetPostString("seller_nick");
  1597. string addFrom = GetPostString("addfrom");
  1598. if (addFrom == "1")
  1599. {
  1600. preStr = "N_";
  1601. }
  1602. int shopId = 0;
  1603. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1604. if (nShop != null)
  1605. {
  1606. shopId = nShop.ID;
  1607. }
  1608. else
  1609. {
  1610. returnErrorMsg("找不到对应店铺");
  1611. return;
  1612. }
  1613. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1614. {
  1615. returnErrorMsg("必须上传付款凭证");
  1616. return;
  1617. }
  1618. CeErpTrade entity = new CeErpTrade();
  1619. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1620. entity.seller_nick = sellerNick;
  1621. entity.buyer_nick = GetPostString("buyer_nick");
  1622. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1623. entity.total_fee = entity.payment;
  1624. entity.pay_time = DateTime.Now;
  1625. entity.status = "NOT_SHIPPED";
  1626. entity.receiver_name = GetPostString("receiver_name");
  1627. entity.receiver_mobile = GetPostString("receiver_mobile");
  1628. entity.receiver_state = GetPostString("receiver_state");
  1629. entity.receiver_city = GetPostString("receiver_city");
  1630. entity.receiver_district = GetPostString("receiver_district");
  1631. entity.receiver_address = GetPostString("receiver_address");
  1632. entity.seller_memo = memo;
  1633. entity.orderFrom = 20;
  1634. entity.orderType = 15;
  1635. if (entity.receiver_state == "" || entity.receiver_city == "")
  1636. {
  1637. returnErrorMsg("收件地址不能为空");
  1638. return;
  1639. }
  1640. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1641. {
  1642. returnErrorMsg("公司自用的单金额才能为0");
  1643. return;
  1644. }
  1645. entity.Create();
  1646. string toWhere = GetPostString("towhere");
  1647. CeErpTradeCell entitycell = new CeErpTradeCell();
  1648. entitycell.ctid = entity.tid;
  1649. //唯一标识
  1650. entitycell.OrderSn = entity.tid;
  1651. string orderSn = dataHelper.getSaleOrderSn();
  1652. if (orderSn != "")
  1653. {
  1654. entitycell.OrderSn = orderSn;
  1655. }
  1656. entitycell.tid = entity.tid;
  1657. //if (preStr == "X_")
  1658. //{
  1659. entitycell.IsOffLineOrder = 1;
  1660. //}
  1661. entitycell.CustomerUserId = CurrentUser.UserID;
  1662. entitycell.PayProofImg = primg;
  1663. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1664. entitycell.ProductId = Convert.ToInt32(productId);
  1665. entitycell.ShopId = shopId;
  1666. entitycell.UpdateTime = DateTime.Now;
  1667. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1668. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1669. {
  1670. entitycell.IsXianHuo = 1;
  1671. }
  1672. entitycell.pay_time = entity.pay_time;
  1673. if (toWhere == "1")
  1674. {
  1675. entitycell.OrderState = 2;
  1676. }
  1677. else
  1678. {
  1679. entitycell.OrderState = 6;
  1680. entitycell.FinishPlaceTime = entitycell.pay_time;
  1681. }
  1682. if (shopId == 94)
  1683. {
  1684. entitycell.OrderState = 4;
  1685. entitycell.WaitDesignTime = entitycell.pay_time;
  1686. entitycell.StartDesignTime = entitycell.pay_time;
  1687. entitycell.DesignUserId = 218;
  1688. }
  1689. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1690. {
  1691. entitycell.OrderState = -1;//修改12-5
  1692. CeWithdraw ceWithdraw = new CeWithdraw();
  1693. ceWithdraw.tid = entity.tid;
  1694. ceWithdraw.providerid = "-1";
  1695. ceWithdraw.status = -1;
  1696. ceWithdraw.creationtime = DateTime.Now;
  1697. ceWithdraw.userid = 1337;
  1698. ceWithdraw.Create();
  1699. }
  1700. entitycell.Create();
  1701. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1702. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1703. {
  1704. addPlaceRegist(entitycell, CurrentUser.UserID);
  1705. }
  1706. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1707. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1708. return;
  1709. }
  1710. }
  1711. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1712. {
  1713. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1714. entity.PlactTime = tradecell.pay_time;
  1715. entity.AddUserId = userid;
  1716. entity.FileName = tradecell.seller_memo;
  1717. entity.Supplier = 24;
  1718. entity.CreateTime = DateTime.Now;
  1719. entity.Did = tradecell.ctid;
  1720. entity.tid = tradecell.tid;
  1721. entity.splitTag = tradecell.SplitTag;
  1722. entity.CurState = "未完成";
  1723. entity.Create();
  1724. }
  1725. public void get_erp_offlinelist()
  1726. {
  1727. DataStruct dStruct = GetPostStruct();
  1728. List<string> lw = new List<string>();
  1729. string tid = GetPostString("ctid");
  1730. string date1 = GetPostString("date1");
  1731. string date2 = GetPostString("date2");
  1732. if (tid.Length > 0 || date1.Length > 0)
  1733. {
  1734. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1735. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1736. if (dw.Length > 0) lw.Add(dw);
  1737. }
  1738. else
  1739. {
  1740. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1741. }
  1742. string shopname = GetPostString("shopname");
  1743. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1744. string buyernick = GetPostString("buyer_nick");
  1745. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1746. string customer = GetPostString("customer");
  1747. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1748. string design = GetPostString("design");
  1749. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1750. string orderState = GetPostString("orderState");
  1751. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1752. string address = GetPostString("address");
  1753. 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));
  1754. string sellermemo = GetPostString("seller_memo");
  1755. if (sellermemo.Length > 0)
  1756. {
  1757. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1758. }
  1759. string price1 = GetPostString("price1");
  1760. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1761. string price2 = GetPostString("price2");
  1762. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1763. //if (PKey != "admin")
  1764. //{
  1765. // string usershop = CurrentUser.User.pemShop;
  1766. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1767. //}
  1768. //if (ex_psize > 0)
  1769. //{
  1770. dStruct.Order = "pay_time desc";
  1771. //}
  1772. //else
  1773. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1774. lw.Add(string.Format("IsOffLineOrder=1"));
  1775. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1776. DataTable dt = null;
  1777. dt = WebCache.GetData("view_erptradecell", dStruct);
  1778. writeGridDataTableJson(dStruct.TotalCount, dt);
  1779. }
  1780. public void get_erp_returncashrecord()
  1781. {
  1782. DataStruct dStruct = GetPostStruct();
  1783. List<string> lw = new List<string>();
  1784. string tid = GetPostString("ctid");
  1785. if (tid.Length > 0)
  1786. {
  1787. lw.Add(string.Format("tid like '%{0}%'", tid));
  1788. dStruct.Order = "id desc";
  1789. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1790. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1791. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1792. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1793. return;
  1794. }
  1795. returnErrorMsg("id数据错误!");
  1796. }
  1797. public void ins_erp_returncashrecord()
  1798. {
  1799. if (UrlPostParmsCheck("tid"))
  1800. {
  1801. string tid = GetPostString("tid");
  1802. string retype = GetPostString("type");
  1803. StringBuilder sql = new StringBuilder();
  1804. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1805. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1806. if (dt.Rows.Count > 0)
  1807. {
  1808. returnErrorMsg("相同返现类型记录已存在");
  1809. return;
  1810. }
  1811. CeErpReturnCash entity = new CeErpReturnCash();
  1812. entity.tid = tid;
  1813. entity.seller_nick = GetPostString("seller_nick");
  1814. string pment = GetPostString("payment");
  1815. if (pment.Length > 0)
  1816. {
  1817. entity.payment = Convert.ToDouble(pment);
  1818. }
  1819. entity.buyer_nick = GetPostString("buyer_nick");
  1820. entity.cashstate = 0;
  1821. entity.rtype = retype;
  1822. string rPrice = GetPostString("returnprice");
  1823. if (rPrice.Length > 0)
  1824. {
  1825. entity.returnprice = Convert.ToDouble(rPrice);
  1826. }
  1827. entity.created = DateTime.Now;
  1828. entity.con = GetPostString("con");
  1829. entity.img = GetPostString("img");
  1830. entity.applyuserid = CurrentUser.UserID;
  1831. entity.Create();
  1832. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1833. returnSuccessMsg("操作成功!");
  1834. return;
  1835. }
  1836. }
  1837. public void set_erp_predelivery()
  1838. {
  1839. if (UrlPostParmsCheck("ctid"))
  1840. {
  1841. string eid = GetPostString("ctid");
  1842. CeErpTradeCell entity = null;
  1843. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1844. if (entity != null)
  1845. {
  1846. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1847. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1848. //{
  1849. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1850. // return;
  1851. //}
  1852. entity.IsPreDelivery = 1;
  1853. entity.Update();
  1854. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1855. returnSuccessMsg("预发货成功!");
  1856. return;
  1857. //string shop = GetPostString("seller_nick");
  1858. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1859. //string comName = GetPostString("comName");
  1860. //string comCode = GetPostString("comCode");
  1861. //string outSid = GetPostString("outSid");//运单号
  1862. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1863. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1864. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1865. //string apires = "";
  1866. //if (deliveryType == "虚拟发货")
  1867. //{
  1868. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1869. //}
  1870. //else
  1871. //{
  1872. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1873. //}
  1874. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1875. ////{
  1876. //if (apires.IndexOf("发货成功") != -1)
  1877. //{
  1878. // if (deliveryType != "虚拟发货")
  1879. // {
  1880. // //还要插入快递信息到 快递信息表
  1881. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1882. // exinfo.tid = eid;
  1883. // exinfo.out_sid = outSid;
  1884. // exinfo.company_code = comCode;
  1885. // exinfo.company_name = comName;
  1886. // exinfo.delivery_memo = deliveryMemo;
  1887. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1888. // exinfo.deliveryType = deliveryType;
  1889. // exinfo.Create();
  1890. // }
  1891. // returnSuccessMsg("发货成功!");
  1892. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1893. //}
  1894. //else
  1895. //{
  1896. // returnErrorMsg("淘宝发货失败!!");
  1897. //}
  1898. //return;
  1899. }
  1900. returnErrorMsg("找不到订单记录");
  1901. }
  1902. }
  1903. public void get_erp_unusuallist()
  1904. {
  1905. DataStruct dStruct = GetPostStruct();
  1906. List<string> lw = new List<string>();
  1907. string tid = GetPostString("ctid");
  1908. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1909. string shopname = GetPostString("shopname");
  1910. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1911. string buyernick = GetPostString("buyer_nick");
  1912. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1913. string ResponsibleMan = GetPostString("responsible");
  1914. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1915. string date1 = GetPostString("date1");
  1916. string date2 = GetPostString("date2");
  1917. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1918. if (dw.Length > 0) lw.Add(dw);
  1919. string price1 = GetPostString("price1");
  1920. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1921. string price2 = GetPostString("price2");
  1922. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1923. string orderState = GetPostString("orderState");
  1924. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1925. string sellermemo = GetPostString("seller_memo");
  1926. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1927. lw.Add(string.Format("UnusualTag > 0"));
  1928. lw.Add(string.Format("IsRefund<={0}", 1));
  1929. dStruct.Order = "pay_time desc";
  1930. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1931. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1932. writeGridDataTableJson(dStruct.TotalCount, dt);
  1933. }
  1934. public void set_erp_unusualtonomal()
  1935. {
  1936. if (UrlPostParmsCheck("ctid"))
  1937. {
  1938. string eid = GetPostString("ctid");
  1939. CeErpTradeCell entity = null;
  1940. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1941. if (entity != null)
  1942. {
  1943. entity.UnusualTag = -1;
  1944. entity.Update();
  1945. returnSuccessMsg("忽略成功!");
  1946. return;
  1947. }
  1948. returnErrorMsg("找不到记录");
  1949. }
  1950. }
  1951. public void ins_erp_unusualreason()
  1952. {
  1953. if (UrlPostParmsCheck("ctid"))
  1954. {
  1955. string eid = GetPostString("ctid");
  1956. CeErpTradeCell entity = null;
  1957. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1958. if (entity != null)
  1959. {
  1960. entity.MemoOpt = 4;
  1961. entity.UnusualCon = GetPostString("con");
  1962. entity.Update();
  1963. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1964. if (trade != null)
  1965. {
  1966. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1967. }
  1968. //查货是否超时
  1969. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1970. if (ceErpTradeCellExtend == null)
  1971. {
  1972. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1973. ceErpTradeCellExtend.ctid = entity.ctid;
  1974. }
  1975. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1976. {
  1977. ceErpTradeCellExtend.CheckOut += 1;
  1978. }
  1979. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1980. if (ceErpTradeCellExtend.ID > 0)
  1981. {
  1982. ceErpTradeCellExtend.Update();
  1983. }
  1984. else
  1985. {
  1986. ceErpTradeCellExtend.Create();
  1987. }
  1988. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1989. returnSuccessMsg("操作成功!");
  1990. return;
  1991. }
  1992. returnErrorMsg("找不到记录");
  1993. }
  1994. }
  1995. public void upd_erp_sampleorder()
  1996. {
  1997. if (UrlPostParmsCheck("ctid"))
  1998. {
  1999. string eid = GetPostString("ctid");
  2000. string[] eArr = eid.Split(',');
  2001. if (eArr.Length > 1)
  2002. {
  2003. List<string> eLst = new List<string>();
  2004. for (int i = 0; i < eArr.Length; i++)
  2005. {
  2006. eLst.Add("'" + eArr[i] + "'");
  2007. }
  2008. eid = string.Join(",", eLst.ToArray());
  2009. }
  2010. else
  2011. {
  2012. eid = "'" + eid + "'";
  2013. }
  2014. StringBuilder sql = new StringBuilder();
  2015. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2016. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2017. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2018. if (dt.Rows.Count > 0)
  2019. {
  2020. string errmsg = "";
  2021. foreach (DataRow dr in dt.Rows)
  2022. {
  2023. StringBuilder sqlsb = new StringBuilder();
  2024. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2025. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2026. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2027. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2028. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2029. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2030. {
  2031. continue;
  2032. }
  2033. else
  2034. {
  2035. string emsg = commonHelper.KeepChinese(apires);
  2036. errmsg += emsg;
  2037. }
  2038. }
  2039. if (errmsg.Length > 0)
  2040. {
  2041. returnErrorMsg(errmsg);
  2042. return;
  2043. }
  2044. returnSuccessMsg("操作成功");
  2045. return;
  2046. }
  2047. returnErrorMsg("找不到记录");
  2048. }
  2049. }
  2050. public void upd_erp_transcustomer()
  2051. {
  2052. if (UrlPostParmsCheck("ctid"))
  2053. {
  2054. string eid = GetPostString("ctid");
  2055. int userid = GetPostInt("CustomerUserId");
  2056. CeErpTradeCell entity = null;
  2057. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2058. if (entity != null)
  2059. {
  2060. //string[] mlist = entity.seller_memo.Split('-');
  2061. //string sql = "select * from view_erpuser where id=" + userid;
  2062. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2063. //if (dt != null && dt.Rows.Count > 0)
  2064. //{
  2065. // string nmemo = "";
  2066. // for(int i = 0; i < mlist.Length - 1; i++)
  2067. // {
  2068. // nmemo += mlist[i];
  2069. // nmemo += "-";
  2070. // }
  2071. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2072. // entity.seller_memo = nmemo;
  2073. //}
  2074. entity.CustomerUserId = userid;
  2075. entity.Update();
  2076. returnSuccessMsg("操作成功!");
  2077. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2078. return;
  2079. }
  2080. returnErrorMsg("找不到记录");
  2081. }
  2082. }
  2083. public void upd_erp_transdesigner()
  2084. {
  2085. if (UrlPostParmsCheck("ctid"))
  2086. {
  2087. string eids = GetPostString("ctid");
  2088. string[] ctidList = eids.Split(',');
  2089. int userid = GetPostInt("DesignUserId");
  2090. foreach (string ctid in ctidList)
  2091. {
  2092. CeErpTradeCell entity = null;
  2093. CeErpDesignerBill entitys = null;
  2094. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2095. entitys = CeErpDesignerBill.GetByTid(ctid);
  2096. if (entity != null)
  2097. {
  2098. if (entity.OrderState > 4)
  2099. {
  2100. continue;
  2101. }
  2102. //存在退款不能流转
  2103. if (entity.IsRefund > 0)
  2104. {
  2105. continue;
  2106. }
  2107. entity.DesignUserId = userid;
  2108. entity.WaitDesignTime = DateTime.Now;
  2109. entity.Update();
  2110. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2111. }
  2112. }
  2113. returnSuccessMsg("操作成功!");
  2114. }
  2115. }
  2116. public void upd_erp_distributedesigner()
  2117. {
  2118. if (UrlPostParmsCheck("ctid"))
  2119. {
  2120. string eid = GetPostString("ctid");
  2121. int userid = GetPostInt("DesignUserId");
  2122. string[] idlist = eid.Split(',');
  2123. if (idlist.Length <= 0)
  2124. {
  2125. returnErrorMsg("订单不能为空");
  2126. return;
  2127. }
  2128. foreach (string ctid in idlist)
  2129. {
  2130. CeErpTradeCell entity = null;
  2131. CeErpDesignerBill entitys = null;
  2132. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2133. else continue;
  2134. if (entity != null)
  2135. {
  2136. if (userid == 2125 || userid == 3542)
  2137. { }
  2138. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2139. {
  2140. returnErrorMsg("金额错误的订单无法指派");
  2141. return;
  2142. }
  2143. if (entity.OrderState >= 5)
  2144. {
  2145. returnErrorMsg("已经设计完成无法指派");
  2146. return;
  2147. }
  2148. if (entity.OrderState == -1)
  2149. {
  2150. returnErrorMsg("审核中的订单无法指派");
  2151. return;
  2152. }
  2153. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2154. {
  2155. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2156. return;
  2157. }
  2158. //157赖橙帆 159林晨
  2159. 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)
  2160. {
  2161. returnErrorMsg("指派设计共创无法再次指派!");
  2162. return;
  2163. }
  2164. entity.OrderState = 3;
  2165. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2166. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2167. {
  2168. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2169. entity.SupplierId = suid;
  2170. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2171. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2172. }
  2173. if (userid == 2125 && entity.seller_memo != "")
  2174. {
  2175. apiDesign.API_GetPrintData_CreateOrder(entity);
  2176. }
  2177. if (userid == 3542 && entity.seller_memo != "")
  2178. {
  2179. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2180. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2181. if (response.msg != "设计共创:成功")
  2182. {
  2183. returnErrorMsg(response.msg);
  2184. return;
  2185. }
  2186. entity.DispatchSort = 2;
  2187. }
  2188. else
  2189. {
  2190. if (entity.DispatchSort == 2)
  2191. {
  2192. ApiVo apiVo = new ApiVo();
  2193. apiVo.actionName = "closeDesign";
  2194. apiVo.orderNumber = entity.ctid;
  2195. designHelper.API_WorkCore(apiVo);//closeDesign
  2196. }
  2197. entity.DispatchSort = 0;
  2198. }
  2199. entity.DesignUserId = userid;
  2200. entity.WaitDesignTime = DateTime.Now;
  2201. entity.UpdateTime = DateTime.Now;
  2202. entity.Update();
  2203. string name = commonHelper.getUserNameById(userid);
  2204. commonHelper.UpdateRelationOrder(entity.ctid);
  2205. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2206. }
  2207. }
  2208. returnSuccessMsg("操作成功!");
  2209. return;
  2210. }
  2211. }
  2212. public string getTidByCtid(string ctid)
  2213. {
  2214. string tid = "";
  2215. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2216. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2217. if (dataTable != null && dataTable.Rows.Count > 0)
  2218. {
  2219. tid = dataTable.Rows[0]["tid"].ToString();
  2220. }
  2221. return tid;
  2222. }
  2223. public List<string> getTidByCtidLike(string ctid)
  2224. {
  2225. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2226. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2227. List<string> list = new List<string>();
  2228. if (dataTable != null && dataTable.Rows.Count > 0)
  2229. {
  2230. foreach (DataRow item in dataTable.Rows)
  2231. {
  2232. list.Add("'" + item["tid"].ToString() + "'");
  2233. }
  2234. }
  2235. return list;
  2236. }
  2237. public void get_erp_myorderlist()
  2238. {
  2239. DataStruct dStruct = GetPostStruct();
  2240. List<string> lw = new List<string>();
  2241. string tid = GetPostString("ctid");
  2242. if (tid.Length > 0)
  2243. {
  2244. string select_tid = getTidByCtid(tid);
  2245. lw.Add(string.Format("tid='{0}'", select_tid));
  2246. }
  2247. else
  2248. {
  2249. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2250. }
  2251. //12-1 修改
  2252. string urgent = GetPostString("urgent");
  2253. string back = GetPostString("back");
  2254. string offlineSearch = GetPostString("offlineSearch");
  2255. if (!string.IsNullOrWhiteSpace(urgent))
  2256. {
  2257. if (urgent.Equals("true"))
  2258. {
  2259. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2260. }
  2261. }
  2262. if (!string.IsNullOrWhiteSpace(back))
  2263. {
  2264. if (back.Equals("true"))
  2265. {
  2266. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2267. }
  2268. }
  2269. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2270. {
  2271. if (offlineSearch.Equals("true"))
  2272. {
  2273. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2274. }
  2275. }
  2276. //end
  2277. string shopname = GetPostString("shopname");
  2278. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2279. string buyernick = GetPostString("buyer_nick");
  2280. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2281. string design = GetPostString("design");
  2282. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2283. string orderState = GetPostString("orderState");
  2284. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2285. string sellermemo = GetPostString("seller_memo");
  2286. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2287. string date1 = GetPostString("date1");
  2288. string date2 = GetPostString("date2");
  2289. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2290. if (dw.Length > 0) lw.Add(dw);
  2291. string price1 = GetPostString("price1");
  2292. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2293. string price2 = GetPostString("price2");
  2294. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2295. string urgency = GetPostString("urgency");
  2296. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2297. string after = GetPostString("after");
  2298. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2299. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2300. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2301. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2302. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2303. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2304. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2305. if (dt != null && dt.Rows.Count > 0)
  2306. {
  2307. foreach (DataRow dr in dt.Rows)
  2308. {
  2309. try
  2310. {
  2311. // 对象操作
  2312. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2313. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2314. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2315. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2316. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2317. if (dStruct.PageSize != 100000)
  2318. {
  2319. if (dr["DispatchSort"].ToString() == "2")
  2320. {
  2321. dr["gongchuang"] = 200;
  2322. }
  2323. else
  2324. {
  2325. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2326. dr["gongchuang"] = response.code;
  2327. }
  2328. }
  2329. }
  2330. catch (NullReferenceException ex)
  2331. {
  2332. }
  2333. }
  2334. }
  2335. writeGridDataTableJson(dStruct.TotalCount, dt);
  2336. }
  2337. public void get_erp_myreturnorderlist()
  2338. {
  2339. DataStruct dStruct = GetPostStruct();
  2340. List<string> lw = new List<string>();
  2341. string tid = GetPostString("ctid");
  2342. if (tid.Length > 0)
  2343. {
  2344. string select_tid = getTidByCtid(tid);
  2345. lw.Add(string.Format("tid='{0}'", select_tid));
  2346. }
  2347. else
  2348. {
  2349. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2350. }
  2351. string shopname = GetPostString("shopname");
  2352. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2353. string buyernick = GetPostString("buyer_nick");
  2354. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2355. string design = GetPostString("design");
  2356. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2357. string orderState = GetPostString("orderState");
  2358. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2359. string sellermemo = GetPostString("seller_memo");
  2360. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2361. string date1 = GetPostString("date1");
  2362. string date2 = GetPostString("date2");
  2363. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2364. if (dw.Length > 0) lw.Add(dw);
  2365. string price1 = GetPostString("price1");
  2366. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2367. string price2 = GetPostString("price2");
  2368. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2369. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2370. {
  2371. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2372. }
  2373. else
  2374. {
  2375. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2376. }
  2377. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2378. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2379. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2380. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2381. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2382. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2383. if (dt != null && dt.Rows.Count > 0)
  2384. {
  2385. foreach (DataRow dr in dt.Rows)
  2386. {
  2387. try
  2388. {
  2389. // 对象操作
  2390. if (dStruct.PageSize != 100000)
  2391. {
  2392. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2393. dr["gongchuang"] = response.code;
  2394. }
  2395. }
  2396. catch (NullReferenceException ex)
  2397. {
  2398. // 处理空引用异常
  2399. }
  2400. }
  2401. }
  2402. writeGridDataTableJson(dStruct.TotalCount, dt);
  2403. }
  2404. public void get_erp_myorderlist_pregather()
  2405. {
  2406. string date1 = GetPostString("date1");
  2407. string date2 = GetPostString("date2");
  2408. int userId = CurrentUser.UserID; //客服id
  2409. string orderWhere = "";
  2410. List<string> lw = new List<string>();
  2411. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2412. if (dw.Length > 0) lw.Add(dw);
  2413. lw.Add(string.Format("CustomerUserId={0}", userId));
  2414. lw.Add(string.Format("OrderState<9"));
  2415. orderWhere = string.Join(" and ", lw.ToArray());
  2416. string orderWhere2 = "";
  2417. List<string> lw2 = new List<string>();
  2418. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2419. if (dw2.Length > 0) lw2.Add(dw2);
  2420. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2421. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2422. string sql = string.Format("select *" +
  2423. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2424. "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 " +
  2425. "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 " +
  2426. "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");
  2427. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2428. //writeGridDataTableJson(dt.Rows.Count, dt);
  2429. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2430. }
  2431. public void upd_erp_publishorder()
  2432. {
  2433. if (UrlPostParmsCheck("ctid"))
  2434. {
  2435. string eid = GetPostString("ctid");
  2436. CeErpTradeCell entity = null;
  2437. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2438. if (entity != null)
  2439. {
  2440. entity.OrderState = 0; //发布后,变为待抢单
  2441. entity.Update();
  2442. commonHelper.UpdateRelationOrder(entity.ctid);
  2443. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2444. returnSuccessMsg("发布成功!");
  2445. return;
  2446. }
  2447. returnErrorMsg("找不到记录");
  2448. }
  2449. }
  2450. public void get_erp_my_tiporder()
  2451. {
  2452. StringBuilder sql = new StringBuilder();
  2453. int userId = 0;
  2454. if (CurrentUser != null) userId = CurrentUser.UserID;
  2455. string posCode = CurrentUser.UserPost.Post.Code;
  2456. string isTipedAfterSaleVerify = GetPostString("af");
  2457. DataTable dt = new DataTable();
  2458. if (posCode != "Supplier")
  2459. {
  2460. if (posCode == "CustomerService" || posCode == "Director")
  2461. {
  2462. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2463. }
  2464. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2465. {
  2466. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2467. }
  2468. else
  2469. {
  2470. string teamIds = CurrentUser.User.TeamIds;
  2471. if (teamIds == "")
  2472. {
  2473. teamIds = "0";
  2474. }
  2475. 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);
  2476. }
  2477. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2478. }
  2479. if (dt.Rows.Count <= 0)
  2480. {
  2481. string key = "aftersale_order_" + userId;
  2482. if (RedisHelper.HasKey(key))
  2483. {
  2484. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2485. dt.Columns.Add("ctid", typeof(string));
  2486. dt.Columns.Add("IsReadTag", typeof(int));
  2487. foreach (var i in list)
  2488. {
  2489. DataRow data = dt.NewRow();
  2490. data["ctid"] = i;
  2491. data["IsReadTag"] = 4;
  2492. dt.Rows.Add(data);
  2493. }
  2494. RedisHelper.StringDelete(key);
  2495. }
  2496. }
  2497. if (dt.Rows.Count <= 0)
  2498. {
  2499. sql = new StringBuilder();
  2500. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2501. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2502. }
  2503. if (posCode == "Supplier")
  2504. {
  2505. string ids = CurrentUser.User.pemVend;
  2506. if (ids != null && ids.Length > 0)
  2507. {
  2508. string[] ids_list = ids.Split(',');
  2509. foreach (var item in ids_list)
  2510. {
  2511. string key = "return_order_" + item;
  2512. if (RedisHelper.HasKey(key))
  2513. {
  2514. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2515. dt.Columns.Add("ctid", typeof(string));
  2516. dt.Columns.Add("IsReadTag", typeof(int));
  2517. foreach (var i in list)
  2518. {
  2519. DataRow data = dt.NewRow();
  2520. data["ctid"] = i;
  2521. data["IsReadTag"] = 1;
  2522. dt.Rows.Add(data);
  2523. }
  2524. RedisHelper.StringDelete(key);
  2525. }
  2526. }
  2527. }
  2528. if (dt.Rows.Count <= 0)
  2529. {
  2530. sql = new StringBuilder();
  2531. 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);
  2532. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2533. }
  2534. }
  2535. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2536. }
  2537. public void reset_erp_tiporder()
  2538. {
  2539. string ids = GetPostString("ids");
  2540. string[] ctidList = ids.Split(',');
  2541. foreach (string ctid in ctidList)
  2542. {
  2543. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2544. if (enty != null)
  2545. {
  2546. enty.IsReadTag = 0;
  2547. enty.Update();
  2548. }
  2549. }
  2550. returnSuccessMsg("成功!");
  2551. return;
  2552. }
  2553. public void get_erp_designlist()
  2554. {
  2555. DataStruct dStruct = GetPostStruct();
  2556. List<string> lw = new List<string>();
  2557. string tid = GetPostString("ctid");
  2558. if (tid.Length > 0)
  2559. {
  2560. string select_tid = getTidByCtid(tid);
  2561. lw.Add(string.Format("tid='{0}'", select_tid));
  2562. }
  2563. string shopname = GetPostString("shopname");
  2564. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2565. string buyernick = GetPostString("buyer_nick");
  2566. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2567. string customer = GetPostString("customer");
  2568. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2569. string design = GetPostString("design");
  2570. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2571. string orderState = GetPostString("orderState");
  2572. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2573. lw.Add(string.Format("OrderState<6"));
  2574. string address = GetPostString("address");
  2575. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2576. string sellermemo = GetPostString("seller_memo");
  2577. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2578. string date1 = GetPostString("date1");
  2579. string date2 = GetPostString("date2");
  2580. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2581. if (dw.Length > 0) lw.Add(dw);
  2582. string apdate1 = GetPostString("apdate1");
  2583. string apdate2 = GetPostString("apdate2");
  2584. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2585. if (dwap.Length > 0) lw.Add(dwap);
  2586. string price1 = GetPostString("price1");
  2587. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2588. string price2 = GetPostString("price2");
  2589. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2590. string designTime = GetPostString("designtime");
  2591. if (designTime.Length > 0)
  2592. {
  2593. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2594. }
  2595. string usershop = CurrentUser.User.pemShop;
  2596. if (usershop.Length > 0)
  2597. {
  2598. lw.Add(string.Format("shopId in ({0})", usershop));
  2599. }
  2600. int myOrgid = CurrentUser.UserPost.OrgID;
  2601. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2602. if (myOrgCode.IndexOf("Designer") != -1)
  2603. {
  2604. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2605. {
  2606. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2607. }
  2608. else
  2609. {
  2610. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2611. }
  2612. }
  2613. else
  2614. {
  2615. string orgId = GetPostString("designerhd");
  2616. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2617. }
  2618. if (tid.Length > 0 || buyernick.Length > 0)
  2619. {
  2620. lw.Add(string.Format("OrderState >= 3"));
  2621. }
  2622. else
  2623. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2624. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2625. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2626. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2627. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2628. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2629. if (dt != null && dt.Rows.Count > 0)
  2630. {
  2631. foreach (DataRow dr in dt.Rows)
  2632. {
  2633. try
  2634. {
  2635. // 对象操作
  2636. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2637. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2638. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2639. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2640. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2641. if (dStruct.PageSize != 100000)
  2642. {
  2643. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2644. dr["gongchuang"] = response.code;
  2645. }
  2646. }
  2647. catch (NullReferenceException ex)
  2648. {
  2649. }
  2650. }
  2651. }
  2652. writeGridDataTableJson(dStruct.TotalCount, dt);
  2653. }
  2654. public void get_erp_mydesignlist()
  2655. {
  2656. DataStruct dStruct = GetPostStruct();
  2657. List<string> lw = new List<string>();
  2658. string tid = GetPostString("ctid");
  2659. if (tid.Length > 0)
  2660. {
  2661. string select_tid = getTidByCtid(tid);
  2662. lw.Add(string.Format("tid='{0}'", select_tid));
  2663. }
  2664. string shopname = GetPostString("shopname");
  2665. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2666. string buyernick = GetPostString("buyer_nick");
  2667. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2668. string customer = GetPostString("customer");
  2669. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2670. string orderState = GetPostString("orderState");
  2671. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2672. //lw.Add(string.Format("OrderState<6"));
  2673. string date1 = GetPostString("date1");
  2674. string date2 = GetPostString("date2");
  2675. string dw = GetDateWhere("pay_time", date1, date2);
  2676. if (dw.Length > 0) lw.Add(dw);
  2677. string apdate1 = GetPostString("apdate1");
  2678. string apdate2 = GetPostString("apdate2");
  2679. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2680. if (dwap.Length > 0) lw.Add(dwap);
  2681. string price1 = GetPostString("price1");
  2682. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2683. string price2 = GetPostString("price2");
  2684. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2685. string olddownload = GetPostString("olddown");
  2686. if (olddownload == "1")
  2687. {
  2688. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2689. }
  2690. else if (olddownload == "2")
  2691. {
  2692. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2693. }
  2694. string sellermemo = GetPostString("seller_memo");
  2695. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2696. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2697. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2698. {
  2699. if (CurrentUser.User.TeamIds.Length > 0)
  2700. {
  2701. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2702. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2703. else
  2704. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2705. }
  2706. else
  2707. {
  2708. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2709. }
  2710. }
  2711. if (tid.Length <= 0)
  2712. {
  2713. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2714. }
  2715. lw.Add(string.Format("IsReturn!=3"));
  2716. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2717. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2718. string teamids = CurrentUser.User.TeamIds.ToString();
  2719. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2720. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2721. if (dt != null && dt.Rows.Count > 0)
  2722. {
  2723. foreach (DataRow dr in dt.Rows)
  2724. {
  2725. try
  2726. {
  2727. // 对象操作
  2728. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2729. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2730. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2731. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2732. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2733. if (dStruct.PageSize != 100000)
  2734. {
  2735. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2736. dr["gongchuang"] = response.code;
  2737. }
  2738. }
  2739. catch (NullReferenceException ex)
  2740. {
  2741. }
  2742. }
  2743. }
  2744. writeGridDataTableJson(dStruct.TotalCount, dt);
  2745. }
  2746. public void set_erp_startdesign()
  2747. {
  2748. if (UrlPostParmsCheck("ctid"))
  2749. {
  2750. string eid = GetPostString("ctid");
  2751. CeErpTradeCell entity = null;
  2752. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2753. if (entity != null)
  2754. {
  2755. if (entity.OrderState != 3)
  2756. {
  2757. returnErrorMsg("请刷新,订单已经设计了");
  2758. return;
  2759. }
  2760. entity.StartDesignTime = DateTime.Now;
  2761. entity.OrderState = 4;
  2762. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2763. {
  2764. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2765. entity.SupplierId = suid;
  2766. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2767. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2768. }
  2769. entity.UpdateTime = DateTime.Now;
  2770. //entity.MakeSupplier = suname;
  2771. entity.Update();
  2772. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2773. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2774. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2775. commonHelper.getCytPrice(entity);
  2776. returnSuccessMsg("操作成功!");
  2777. return;
  2778. }
  2779. returnErrorMsg("找不到记录");
  2780. }
  2781. }
  2782. public void ins_erp_designselfmemo()
  2783. {
  2784. if (UrlPostParmsCheck("ctid"))
  2785. {
  2786. string eid = GetPostString("ctid");
  2787. string con = GetPostString("con");
  2788. CeErpTradeCell entity = null;
  2789. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2790. if (entity != null)
  2791. {
  2792. entity.DesignSelfMemo = con;
  2793. entity.Update();
  2794. returnSuccessMsg("操作成功!");
  2795. return;
  2796. }
  2797. returnErrorMsg("找不到记录");
  2798. }
  2799. }
  2800. public void ins_erp_designprice()
  2801. {
  2802. if (UrlPostParmsCheck("ctid"))
  2803. {
  2804. string eid = GetPostString("ctid");
  2805. int uid = CurrentUser.UserID;
  2806. string userName = CurrentUser.UserName;
  2807. CeErpTradeCell entity = null;
  2808. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2809. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2810. if (entitys == null)
  2811. {
  2812. entitys = new CeErpDesignerBill();
  2813. }
  2814. if (entity != null)
  2815. {
  2816. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2817. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2818. entity.StartDesignTime = DateTime.Now;
  2819. entity.OrderState = 4;
  2820. string suname = "";
  2821. if (entity.SupplierId == 0)
  2822. {
  2823. int sid = commonHelper.autoDistributeToSupplier(entity);
  2824. entity.SupplierId = sid;
  2825. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2826. }
  2827. entity.Update();
  2828. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2829. if (ceErpUserPost != null)
  2830. {
  2831. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2832. if (ceErpPost != null)
  2833. {
  2834. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2835. {
  2836. entitys.tid = entity.ctid;
  2837. entitys.oid = entity.tid;
  2838. entitys.uid = uid;
  2839. entitys.userName = userName;
  2840. entitys.designerType = 1;
  2841. entitys.designerTypeText = "内部设计师";
  2842. entitys.price = Convert.ToDouble(GetPostString("price"));
  2843. entitys.designNum = GetPostInt("designNum");
  2844. entitys.modifyNum = GetPostInt("modifyNum");
  2845. entitys.designSize = GetPostString("designSize");
  2846. entitys.modifySize = GetPostString("modifySize");
  2847. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2848. {
  2849. entitys.create_time = DateTime.Now;
  2850. entitys.create_u_id = uid;
  2851. entitys.create_u_name = userName;
  2852. entitys.Save();
  2853. }
  2854. else
  2855. {
  2856. entitys.update_time = DateTime.Now;
  2857. entitys.update_u_id = uid;
  2858. entitys.update_u_name = userName;
  2859. entitys.Update();
  2860. }
  2861. }
  2862. }
  2863. }
  2864. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2865. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2866. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2867. if (suname != "")
  2868. {
  2869. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2870. }
  2871. commonHelper.getCytPrice(entity);
  2872. returnSuccessMsg("操作成功!");
  2873. return;
  2874. }
  2875. returnErrorMsg("找不到记录");
  2876. }
  2877. }
  2878. public void upload_erp_filecomplete()
  2879. {
  2880. if (UrlPostParmsCheck("ctid"))
  2881. {
  2882. string eid = GetPostString("ctid");
  2883. CeErpTradeCell entity = null;
  2884. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2885. if (entity != null)
  2886. {
  2887. entity.OrderState = 5; //设计完成
  2888. entity.Update();
  2889. returnSuccessMsg(eid + "上传成功,设计完成!");
  2890. return;
  2891. }
  2892. returnErrorMsg("找不到订单记录");
  2893. }
  2894. }
  2895. public void get_erp_designovertimelist()
  2896. {
  2897. DataStruct dStruct = GetPostStruct();
  2898. List<string> lw = new List<string>();
  2899. string tid = GetPostString("ctid");
  2900. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2901. string shopname = GetPostString("shopname");
  2902. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2903. string buyernick = GetPostString("buyer_nick");
  2904. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2905. string ResponsibleMan = GetPostString("responsible");
  2906. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2907. string date1 = GetPostString("date1");
  2908. string date2 = GetPostString("date2");
  2909. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2910. if (dw.Length > 0) lw.Add(dw);
  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 orderState = GetPostString("orderState");
  2916. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2917. string sellermemo = GetPostString("seller_memo");
  2918. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2919. lw.Add(string.Format("UnusualTag=3"));
  2920. lw.Add(string.Format("IsRefund<={0}", 1));
  2921. dStruct.Order = "WaitDesignTime desc";
  2922. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2923. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2924. writeGridDataTableJson(dStruct.TotalCount, dt);
  2925. }
  2926. //设计管理 获取抢单大厅列表
  2927. public void get_erp_grabinglist()
  2928. {
  2929. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2930. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2931. bool oldOrder = false;
  2932. if (org != null)
  2933. {
  2934. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2935. }
  2936. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2937. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2938. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2939. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2940. //先处理订单数据
  2941. if (dt.Rows.Count > 0)
  2942. {
  2943. Dictionary<string, int> design = null;
  2944. int count = 0;
  2945. foreach (DataRow row in dt.Rows)
  2946. {
  2947. if (map.ContainsKey(row["ShopId"].ToString()))
  2948. {
  2949. map.TryGetValue(row["ShopId"].ToString(), out design);
  2950. }
  2951. else
  2952. {
  2953. design = new Dictionary<string, int>();
  2954. }
  2955. if (design.ContainsKey(row["ProductId"].ToString()))
  2956. {
  2957. design.TryGetValue(row["ProductId"].ToString(), out count);
  2958. }
  2959. count++;
  2960. design[row["ProductId"].ToString()] = count;
  2961. map[row["ShopId"].ToString()] = design;
  2962. }
  2963. }
  2964. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2965. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2966. //把店铺排序和技能排序分类
  2967. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2968. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2969. if (design_dt.Rows.Count > 0)
  2970. {
  2971. Dictionary<string, string> design = null;
  2972. List<string> shopIds = null;
  2973. foreach (DataRow row in design_dt.Rows)
  2974. {
  2975. if ("0".Equals(row["designId"].ToString()))
  2976. {
  2977. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2978. {
  2979. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2980. }
  2981. else
  2982. {
  2983. shopIds = new List<string>();
  2984. }
  2985. shopIds.Add(row["shopId"].ToString());
  2986. shop_orders[row["orders"].ToString()] = shopIds;
  2987. }
  2988. else
  2989. {
  2990. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2991. {
  2992. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2993. }
  2994. else
  2995. {
  2996. design = new Dictionary<string, string>();
  2997. }
  2998. design[row["orders"].ToString()] = row["designId"].ToString();
  2999. design_orders[row["shopId"].ToString()] = design;
  3000. }
  3001. }
  3002. //处理成key value后根据key排序
  3003. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3004. foreach (List<string> val in shop_orders.Values)
  3005. {
  3006. if (val != null)
  3007. {
  3008. foreach (string key in val)
  3009. {
  3010. if (design_orders.ContainsKey(key.ToString()))
  3011. {
  3012. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3013. }
  3014. }
  3015. }
  3016. }
  3017. }
  3018. //校验哪个优先级有订单
  3019. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3020. foreach (string key in shop_orders.Keys)
  3021. {
  3022. List<string> ids = null;
  3023. shop_orders.TryGetValue(key, out ids);
  3024. //id为shopid
  3025. foreach (string id in ids)
  3026. {
  3027. Dictionary<string, int> list = null;
  3028. Dictionary<string, string> desing = null;
  3029. map.TryGetValue(id, out list);
  3030. design_orders.TryGetValue(id, out desing);
  3031. if (list != null && desing != null)
  3032. {
  3033. foreach (var item in desing)
  3034. {
  3035. int count = 0;
  3036. if (list.ContainsKey(item.Value))
  3037. {
  3038. list.TryGetValue(item.Value, out count);
  3039. if (count > 0)
  3040. {
  3041. designIds[id] = item.Value;
  3042. break;
  3043. }
  3044. }
  3045. }
  3046. }
  3047. }
  3048. if (designIds.Count > 0)
  3049. {
  3050. break;
  3051. }
  3052. }
  3053. DataTable table = new DataTable();
  3054. table.Columns.Add("tid", typeof(string));
  3055. table.Columns.Add("ctid", typeof(string));
  3056. table.Columns.Add("seller_nick", typeof(string));
  3057. table.Columns.Add("productName", typeof(string));
  3058. table.Columns.Add("pay_time", typeof(string));
  3059. table.Columns.Add("seller_memo", typeof(string));
  3060. if (designIds.Count > 0)
  3061. {
  3062. string shopId = "";
  3063. string productId = "";
  3064. foreach (var designInfo in designIds)
  3065. {
  3066. shopId = designInfo.Key;
  3067. productId = designInfo.Value;
  3068. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3069. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3070. if (dt.Rows.Count > 0)
  3071. {
  3072. foreach (DataRow row in dt.Rows)
  3073. {
  3074. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3075. {
  3076. DataRow data = table.NewRow();
  3077. data["ctid"] = row["ctid"].ToString();
  3078. data["tid"] = row["tid"].ToString();
  3079. data["seller_nick"] = ceErpShop.ShopName;
  3080. data["pay_time"] = row["pay_time"].ToString();
  3081. data["seller_memo"] = row["seller_memo"].ToString();
  3082. data["productName"] = ceErpProduct.PType;
  3083. table.Rows.Add(data);
  3084. }
  3085. }
  3086. }
  3087. }
  3088. }
  3089. writeGridDataTableJson(table.Rows.Count, table);
  3090. }
  3091. private object rushLockObject = new object();
  3092. public void set_erp_grabingorder()
  3093. {
  3094. if (UrlPostParmsCheck("ctid"))
  3095. {
  3096. int total = CurrentUser.User.Person.Total;
  3097. int userId = CurrentUser.User.ID;
  3098. int noFinish = CurrentUser.User.Person.NoFinish;
  3099. int finalization = CurrentUser.User.Person.Finalization;
  3100. string eids = GetPostString("ctid");
  3101. string key = "RushKey_" + userId;
  3102. int count = 0;
  3103. if (erpRedis.RedisHelper.KeyExists(key))
  3104. {
  3105. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3106. if (redisCount != null)
  3107. {
  3108. count = Convert.ToInt32(redisCount);
  3109. }
  3110. }
  3111. if (count >= total)
  3112. {
  3113. returnErrorMsg("半小时内已经抢" + total + "单");
  3114. return;
  3115. }
  3116. string[] ctidlist = eids.Split(',');
  3117. if (count + ctidlist.Length > total)
  3118. {
  3119. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3120. return;
  3121. }
  3122. int itag = 0;
  3123. lock (rushLockObject)
  3124. {
  3125. if (ctidlist.Length > 0)
  3126. {
  3127. string[] dtList = new string[ctidlist.Length];
  3128. for (int i = 0; i < ctidlist.Length; i++)
  3129. {
  3130. dtList[i] = "'" + ctidlist[i] + "'";
  3131. }
  3132. 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"));
  3133. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3134. if (dt_user.Rows.Count > 0)
  3135. {
  3136. int doing = 0;//未定稿
  3137. int finish = 0;//已完成
  3138. foreach (DataRow dr in dt_user.Rows)
  3139. {
  3140. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3141. {
  3142. doing++;
  3143. }
  3144. else
  3145. {
  3146. finish++;
  3147. }
  3148. }
  3149. if (doing >= noFinish)
  3150. {
  3151. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3152. return;
  3153. }
  3154. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3155. {
  3156. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3157. return;
  3158. }
  3159. }
  3160. //校验选择单子状态
  3161. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3162. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3163. if (dt.Rows.Count > 0)
  3164. {
  3165. List<string> list = new List<string>();
  3166. foreach (DataRow dr in dt.Rows)
  3167. {
  3168. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3169. {
  3170. list.Add(dr["ctid"].ToString());
  3171. }
  3172. }
  3173. if (list.Count > 0)
  3174. {
  3175. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3176. return;
  3177. }
  3178. }
  3179. foreach (string ctid in ctidlist)
  3180. {
  3181. CeErpTradeCell entity = null;
  3182. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3183. if (entity != null)
  3184. {
  3185. entity.OrderState = 3;
  3186. entity.DesignUserId = CurrentUser.UserID;
  3187. entity.WaitDesignTime = DateTime.Now;
  3188. entity.StartDesignTime = DateTime.Now;
  3189. entity.Update();
  3190. commonHelper.UpdateRelationOrder(entity.ctid);
  3191. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3192. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3193. itag++;
  3194. }
  3195. }
  3196. }
  3197. }
  3198. count += ctidlist.Length;
  3199. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3200. if (itag == 0)
  3201. returnErrorMsg("没有找到相关订单");
  3202. else
  3203. returnSuccessMsg("抢单成功!");
  3204. return;
  3205. }
  3206. }
  3207. public void get_erp_waitorderlist()
  3208. {
  3209. DataStruct dStruct = GetPostStruct();
  3210. List<string> lw = new List<string>();
  3211. string tid = GetPostString("ctid");
  3212. if (tid.Length > 0)
  3213. {
  3214. string select_tid = getTidByCtid(tid);
  3215. lw.Add(string.Format("tid='{0}'", select_tid));
  3216. }
  3217. string shopname = GetPostString("shopname");
  3218. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3219. string buyernick = GetPostString("buyer_nick");
  3220. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3221. string customer = GetPostString("customer");
  3222. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3223. string design = GetPostString("design");
  3224. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3225. string orderState = GetPostString("orderState");
  3226. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3227. string supplier = GetPostString("supplier");
  3228. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3229. string sellermemo = GetPostString("seller_memo");
  3230. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3231. string otherMemo = GetPostString("otherMemo");
  3232. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3233. string address = GetPostString("address");
  3234. 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));
  3235. string date1 = GetPostString("date1");
  3236. string date2 = GetPostString("date2");
  3237. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3238. if (dw.Length > 0) lw.Add(dw);
  3239. string price1 = GetPostString("price1");
  3240. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3241. string price2 = GetPostString("price2");
  3242. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3243. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3244. lw.Add(string.Format("IsSample != 2 "));
  3245. lw.Add(string.Format("OrderState = 5 "));
  3246. lw.Add(string.Format("IsRefund<={0}", 1));
  3247. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3248. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3249. string pagesize = GetPostString("pagesize");
  3250. if (pagesize != null)
  3251. {
  3252. dStruct.PageSize = 200;
  3253. }
  3254. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3255. if (dt != null)
  3256. {
  3257. foreach (DataRow dr in dt.Rows)
  3258. {
  3259. 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();
  3260. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3261. {
  3262. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3263. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3264. entity.SupplierId = suid;
  3265. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3266. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3267. entity.Update();
  3268. }
  3269. }
  3270. }
  3271. writeGridDataTableJson(dStruct.TotalCount, dt);
  3272. }
  3273. public void get_erp_supplierwaitorderlist()
  3274. {
  3275. DataStruct dStruct = GetPostStruct();
  3276. List<string> lw = new List<string>();
  3277. string tid = GetPostString("ctid");
  3278. if (tid.Length > 0)
  3279. {
  3280. string select_tid = getTidByCtid(tid);
  3281. lw.Add(string.Format("tid='{0}'", select_tid));
  3282. }
  3283. string shopname = GetPostString("shopname");
  3284. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3285. string sellermemo = GetPostString("seller_memo");
  3286. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3287. string date1 = GetPostString("date1");
  3288. string date2 = GetPostString("date2");
  3289. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3290. if (dw.Length > 0) lw.Add(dw);
  3291. lw.Add(string.Format("OrderState = 5 "));
  3292. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3293. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3294. {
  3295. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3296. }
  3297. string supplier = GetPostString("supplier");
  3298. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3299. {
  3300. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3301. }
  3302. lw.Add(string.Format("IsRefund<={0}", 1));
  3303. dStruct.Order = "FinishDesignTime desc";
  3304. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3305. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3306. if (dt != null)
  3307. {
  3308. foreach (DataRow dr in dt.Rows)
  3309. {
  3310. 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();
  3311. }
  3312. }
  3313. writeGridDataTableJson(dStruct.TotalCount, dt);
  3314. }
  3315. public void upd_erp_verifytosupplier()
  3316. {
  3317. if (UrlPostParmsCheck("ctid"))
  3318. {
  3319. string eids = GetPostString("ctid");
  3320. CeErpTradeCell entity = null;
  3321. string[] eidsList = eids.Split(',');
  3322. if (eidsList.Length <= 0)
  3323. {
  3324. returnErrorMsg("订单号不能空");
  3325. return;
  3326. }
  3327. List<string> tLst = new List<string>();
  3328. foreach (string ctidstr in eidsList)
  3329. {
  3330. tLst.Add("'" + ctidstr + "'");
  3331. CeErpDataSendOrderInfo.createObject(ctidstr);
  3332. }
  3333. string needtids = string.Join(",", tLst.ToArray());
  3334. StringBuilder sql = new StringBuilder();
  3335. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3336. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3337. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3338. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3339. returnSuccessMsg("操作成功!");
  3340. return;
  3341. /**foreach (string ctidstr in eidsList)
  3342. {
  3343. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3344. if (entity != null)
  3345. {
  3346. if (entity.SupplierId == 0)
  3347. {
  3348. continue;
  3349. }
  3350. entity.IsVerifyToSupplier = true;
  3351. if (entity.IsReturn == 1) //1是供应商打回
  3352. {
  3353. entity.IsReturn = 0;
  3354. }
  3355. entity.FinishPlaceTime = DateTime.Now;
  3356. entity.PlaceUserId = CurrentUser.UserID;
  3357. entity.Update();
  3358. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3359. }
  3360. }
  3361. returnSuccessMsg("操作成功!");
  3362. return;**/
  3363. }
  3364. }
  3365. public void upd_erp_supplierback()
  3366. {
  3367. if (UrlPostParmsCheck("ctid"))
  3368. {
  3369. string eid = GetPostString("ctid");
  3370. string reason = GetPostString("returnreason");
  3371. CeErpTradeCell entity = null;
  3372. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3373. if (entity != null)
  3374. {
  3375. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3376. {
  3377. string key = "return_order_" + entity.SupplierId;
  3378. List<string> list = new List<string>();
  3379. if (RedisHelper.HasKey(key))
  3380. {
  3381. object data = RedisHelper.StringGet(key);
  3382. list = Convert.ToString(data).Split(',').ToList();
  3383. }
  3384. list.Add(eid);
  3385. RedisHelper.StringSet(key, string.Join(",", list));
  3386. }
  3387. entity.IsVerifyToSupplier = false;
  3388. entity.IsReturn = 1;
  3389. entity.ReturnTime = DateTime.Now;
  3390. entity.ReturnReason = reason;
  3391. if (entity.OrderState == 6)
  3392. {
  3393. entity.OrderState = 5;
  3394. }
  3395. entity.Update();
  3396. CeErpSukuraData.createInfo(entity.ctid, 5);
  3397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3398. returnSuccessMsg("操作成功!");
  3399. return;
  3400. }
  3401. returnErrorMsg("找不到订单记录");
  3402. }
  3403. }
  3404. public void upd_erp_toaftersaleorder()
  3405. {
  3406. if (UrlPostParmsCheck("ctid"))
  3407. {
  3408. string eid = GetPostString("ctid");
  3409. string reason = GetPostString("returnreason");
  3410. CeErpTradeCell entity = null;
  3411. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3412. if (entity != null)
  3413. {
  3414. if (entity.isAfterSaleOrder != 1)
  3415. {
  3416. returnErrorMsg("带S的售后单才能打回给售后");
  3417. return;
  3418. }
  3419. if (entity.OrderState >= 5)
  3420. {
  3421. returnErrorMsg("已经设计完成了不能打回给售后");
  3422. return;
  3423. }
  3424. entity.OrderState = 0;
  3425. entity.IsReturn = 3;
  3426. entity.ReturnTime = DateTime.Now;
  3427. entity.UpdateTime = DateTime.Now;
  3428. entity.ReturnReason = reason;
  3429. entity.Update();
  3430. CeErpSukuraData.createInfo(entity.ctid, 5);
  3431. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3432. returnSuccessMsg("操作成功!");
  3433. return;
  3434. }
  3435. returnErrorMsg("找不到订单记录");
  3436. }
  3437. }
  3438. public void upd_erp_aftersaletodesign()
  3439. {
  3440. if (UrlPostParmsCheck("ctid"))
  3441. {
  3442. string eid = GetPostString("ctid");
  3443. CeErpTradeCell entity = null;
  3444. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3445. if (entity != null)
  3446. {
  3447. entity.OrderState = 3;
  3448. entity.IsReturn = 0;
  3449. entity.UpdateTime = DateTime.Now;
  3450. entity.Update();
  3451. CeErpSukuraData.createInfo(entity.ctid, 5);
  3452. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3453. returnSuccessMsg("操作成功!");
  3454. return;
  3455. }
  3456. returnErrorMsg("找不到订单记录");
  3457. }
  3458. }
  3459. public void assign_erp_supplier()
  3460. {
  3461. if (UrlPostParmsCheck("ctid"))
  3462. {
  3463. string eids = GetPostString("ctid");
  3464. int sid = GetPostInt("SupplierName");
  3465. string fromTag = GetPostString("tag");
  3466. string[] eidList = eids.Split(',');
  3467. if (eidList.Length <= 0)
  3468. {
  3469. returnErrorMsg("指派不能为空");
  3470. return;
  3471. }
  3472. string errMsg = "";
  3473. string suname = commonHelper.getSupplierNameById(sid);
  3474. foreach (string ctid in eidList)
  3475. {
  3476. CeErpTradeCell entity = null;
  3477. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3478. if (entity != null)
  3479. {
  3480. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3481. {
  3482. errMsg += (ctid + "指派失败!!!");
  3483. continue;
  3484. }
  3485. entity.SupplierId = sid;
  3486. entity.Update();
  3487. commonHelper.UpdateRelationOrder(entity.ctid);
  3488. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3489. if (entity.OrderState >= 6)
  3490. {
  3491. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3492. //{
  3493. // string msl = entity.MakeSupplier;
  3494. // string[] mslist = msl.Split(',');
  3495. // 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);
  3496. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3497. //}
  3498. //else
  3499. //{
  3500. StringBuilder sql = new StringBuilder();
  3501. 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);
  3502. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3503. //}
  3504. }
  3505. }
  3506. else
  3507. {
  3508. continue;
  3509. }
  3510. }
  3511. if (errMsg.Length > 0)
  3512. {
  3513. returnErrorMsg(errMsg);
  3514. return;
  3515. }
  3516. returnSuccessMsg("操作成功!");
  3517. return;
  3518. }
  3519. }
  3520. public void assign_erp_makesupplier()
  3521. {
  3522. if (UrlPostParmsCheck("ctid"))
  3523. {
  3524. string eids = GetPostString("ctid");
  3525. string sname = GetPostString("SupplierName");
  3526. string[] eidList = eids.Split(',');
  3527. if (eidList.Length <= 0)
  3528. {
  3529. returnErrorMsg("指派不能为空");
  3530. return;
  3531. }
  3532. List<string> tLst = new List<string>();
  3533. foreach (string ctid in eidList)
  3534. {
  3535. CeErpTradeCell entity = null;
  3536. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3537. if (entity != null)
  3538. {
  3539. entity.MakeSupplier = sname;
  3540. entity.Update();
  3541. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3542. tLst.Add("'" + ctid + "'");
  3543. }
  3544. else
  3545. {
  3546. continue;
  3547. }
  3548. }
  3549. string ctids = string.Join(",", tLst.ToArray());
  3550. StringBuilder sql2 = new StringBuilder();
  3551. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3552. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3553. returnSuccessMsg("操作成功!");
  3554. return;
  3555. }
  3556. }
  3557. public void ins_erp_returnreason()
  3558. {
  3559. if (UrlPostParmsCheck("ctid"))
  3560. {
  3561. string eid = GetPostString("ctid");
  3562. CeErpTradeCell entity = null;
  3563. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3564. string userpost = CurrentUser.UserPost.Post.Code;
  3565. if (entity != null)
  3566. {
  3567. bool isPlace = false;
  3568. if (entity.OrderState > 6)
  3569. {
  3570. returnErrorMsg("已发货无法打回!");
  3571. return;
  3572. }
  3573. if (entity.OrderState == 6)
  3574. {
  3575. isPlace = true;
  3576. }
  3577. bool isNeedUpdateCell2 = false;
  3578. if (entity.OrderState >= 6)
  3579. {
  3580. isNeedUpdateCell2 = true;
  3581. }
  3582. int returnTag = 2;
  3583. if (userpost == "Supplier")
  3584. {
  3585. returnTag = 1;
  3586. }
  3587. int toType = GetPostInt("totype");
  3588. string fromType = "3";
  3589. if (entity.OrderState < 5)
  3590. {
  3591. fromType = "3";
  3592. }
  3593. else
  3594. {
  3595. fromType = "4";
  3596. }
  3597. if (entity.IsXianHuo == 0)
  3598. {
  3599. if (returnTag == 2)
  3600. {
  3601. if (toType == 1)
  3602. {
  3603. entity.OrderState = 0;
  3604. entity.ReturnUserType = 1;
  3605. string clearman = GetPostString("clearman");
  3606. if (!string.IsNullOrEmpty(clearman))
  3607. {
  3608. entity.DesignUserId = 0;
  3609. }
  3610. }
  3611. else
  3612. {
  3613. entity.OrderState = 3;
  3614. entity.ReturnUserType = 2;
  3615. }
  3616. entity.IsReadTag = 1;
  3617. }
  3618. else if (returnTag == 1)
  3619. {
  3620. entity.OrderState = 5;
  3621. }
  3622. entity.IsVerifyToSupplier = false;
  3623. }
  3624. if (entity.IsXianHuo == 1)
  3625. {
  3626. entity.OrderState = 5;
  3627. }
  3628. entity.UnusualTag = 0;
  3629. entity.UnusualTime = null;
  3630. entity.UnusualCon = "";
  3631. entity.IsReturn = returnTag;
  3632. entity.ReturnTime = DateTime.Now;
  3633. entity.UpdateTime = DateTime.Now;
  3634. entity.ReturnReason = GetPostString("returnreason");
  3635. entity.Update();
  3636. if (entity.OrderState == 3)
  3637. {
  3638. ApiVo apiVo = new ApiVo();
  3639. apiVo.orderNumber = entity.ctid;
  3640. apiVo.actionName = "rebutDesign";
  3641. apiVo.orderRemarks = entity.ReturnReason;
  3642. designHelper.API_WorkCore(apiVo);//rebutDesign
  3643. }
  3644. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3645. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3646. {
  3647. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3648. }
  3649. CeErpSukuraData.createInfo(entity.ctid, 5);
  3650. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3651. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3652. if (isPlace)
  3653. {
  3654. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3655. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3656. if (dth != null && dth.Rows.Count > 0)
  3657. {
  3658. dataSendOrderBean dataSendOrderBean = null;
  3659. foreach (DataRow item in dth.Rows)
  3660. {
  3661. try
  3662. {
  3663. dataSendOrderBean = new dataSendOrderBean();
  3664. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3665. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3666. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3667. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3668. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3669. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3670. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3671. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3672. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3673. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3674. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3675. dataSendOrderBean.Radio1723534706288 = "打回";
  3676. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3677. if (result != null)
  3678. {
  3679. if ("0".Equals(result.errcode))
  3680. {
  3681. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3682. }
  3683. else
  3684. {
  3685. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3686. }
  3687. }
  3688. }
  3689. catch (Exception ex)
  3690. {
  3691. }
  3692. }
  3693. }
  3694. }
  3695. if (isNeedUpdateCell2)
  3696. {
  3697. if (entity.MakeSupplier.IndexOf(",") != -1)
  3698. {
  3699. StringBuilder sql2 = new StringBuilder();
  3700. 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);
  3701. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3702. }
  3703. else
  3704. {
  3705. StringBuilder sql2 = new StringBuilder();
  3706. 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);
  3707. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3708. }
  3709. }
  3710. returnSuccessMsg("操作成功!");
  3711. return;
  3712. }
  3713. returnErrorMsg("找不到订单记录");
  3714. }
  3715. }
  3716. public void cyt_erp_returnreason()
  3717. {
  3718. if (UrlPostParmsCheck("ctid"))
  3719. {
  3720. string eid = GetPostString("ctid");
  3721. CeErpTradeCell entity = null;
  3722. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3723. string userpost = CurrentUser.UserPost.Post.Code;
  3724. if (entity != null)
  3725. {
  3726. if (entity.OrderState > 6)
  3727. {
  3728. returnErrorMsg("已发货无法打回!");
  3729. return;
  3730. }
  3731. JObject jsonObject = new JObject
  3732. {
  3733. { "Userid", "77886" },
  3734. { "Pwd", "lt666888" },
  3735. { "LTOrderId",eid }
  3736. };
  3737. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3738. JObject jsonObjects = JObject.Parse(response);
  3739. string msg = (string)jsonObjects["msg"];
  3740. if (msg != "取消成功")
  3741. {
  3742. returnErrorMsg(msg);
  3743. return;
  3744. }
  3745. bool isNeedUpdateCell2 = false;
  3746. if (entity.OrderState >= 6)
  3747. {
  3748. isNeedUpdateCell2 = true;
  3749. }
  3750. int returnTag = 2;
  3751. if (userpost == "Supplier")
  3752. {
  3753. returnTag = 1;
  3754. }
  3755. if (entity.IsXianHuo == 0)
  3756. {
  3757. if (returnTag == 2)
  3758. {
  3759. int toType = GetPostInt("totype");
  3760. if (toType == 1)
  3761. {
  3762. entity.OrderState = 0;
  3763. entity.ReturnUserType = 1;
  3764. }
  3765. else
  3766. {
  3767. entity.OrderState = 4;
  3768. entity.ReturnUserType = 2;
  3769. }
  3770. entity.IsReadTag = 1;
  3771. }
  3772. else if (returnTag == 1)
  3773. {
  3774. entity.OrderState = 5;
  3775. }
  3776. entity.IsVerifyToSupplier = false;
  3777. }
  3778. entity.UnusualTag = 0;
  3779. entity.UnusualTime = null;
  3780. entity.UnusualCon = "";
  3781. entity.IsReturn = returnTag;
  3782. entity.ReturnTime = DateTime.Now;
  3783. entity.ReturnReason = GetPostString("returnreason");
  3784. entity.Update();
  3785. if (entity.OrderState == 4)
  3786. {
  3787. ApiVo apiVo = new ApiVo();
  3788. apiVo.orderNumber = entity.ctid;
  3789. apiVo.actionName = "rebutDesign";
  3790. apiVo.orderRemarks = entity.ReturnReason;
  3791. designHelper.API_WorkCore(apiVo);//rebutDesign
  3792. }
  3793. CeErpSukuraData.createInfo(entity.ctid, 5);
  3794. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3795. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3796. if (isNeedUpdateCell2)
  3797. {
  3798. if (entity.MakeSupplier.IndexOf(",") != -1)
  3799. {
  3800. StringBuilder sql2 = new StringBuilder();
  3801. 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);
  3802. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3803. }
  3804. else
  3805. {
  3806. StringBuilder sql2 = new StringBuilder();
  3807. 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);
  3808. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3809. }
  3810. }
  3811. returnSuccessMsg("操作成功!");
  3812. return;
  3813. }
  3814. returnErrorMsg("找不到订单记录");
  3815. }
  3816. }
  3817. public void upd_erp_xianhuoreturntag()
  3818. {
  3819. if (UrlPostParmsCheck("ctid"))
  3820. {
  3821. string eids = GetPostString("ctid");
  3822. string[] ctids = eids.Split(',');
  3823. foreach (string ctid in ctids)
  3824. {
  3825. CeErpTradeCell entity = null;
  3826. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3827. if (entity != null)
  3828. {
  3829. entity.IsReturn = 0;
  3830. entity.Update();
  3831. CeErpSukuraData.createInfo(entity.ctid, 5);
  3832. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3833. }
  3834. }
  3835. returnSuccessMsg("操作成功!");
  3836. return;
  3837. }
  3838. }
  3839. public void get_erp_waitdeliverylist()
  3840. {
  3841. DataStruct dStruct = GetPostStruct();
  3842. List<string> lw = new List<string>();
  3843. string tid = GetPostString("ctid");
  3844. if (tid.Length > 0)
  3845. {
  3846. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3847. if (tid.Length > 5)
  3848. {
  3849. List<string> tids = getTidByCtidLike(tid);
  3850. if (tids.Count > 0 && tids.Count < 10)
  3851. {
  3852. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3853. }
  3854. }
  3855. lw.Add(tid_sql);
  3856. }
  3857. string shopname = GetPostString("shopname");
  3858. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3859. string buyernick = GetPostString("buyer_nick");
  3860. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3861. //if (tid.Length == 0 && buyernick.Length == 0)
  3862. //{
  3863. // lw.Add(string.Format("IsRefund<={0}", 1));
  3864. //}
  3865. string customer = GetPostString("customer");
  3866. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3867. string design = GetPostString("design");
  3868. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3869. string orderState = GetPostString("orderState");
  3870. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3871. string address = GetPostString("address");
  3872. 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));
  3873. string sellermemo = GetPostString("seller_memo");
  3874. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3875. string supplier = GetPostString("supplier");
  3876. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3877. string OrderArea = GetPostString("order_area");
  3878. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3879. string placedate1 = GetPostString("placedate1");
  3880. string placedate2 = GetPostString("placedate2");
  3881. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3882. if (fdw.Length > 0) lw.Add(fdw);
  3883. string price1 = GetPostString("price1");
  3884. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3885. string price2 = GetPostString("price2");
  3886. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3887. string unusualCon = GetPostString("unusualcon");
  3888. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3889. string otherMemo = GetPostString("otherMemo");
  3890. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3891. string posTag = CurrentUser.UserPost.Post.Code;
  3892. if (posTag == "Supplier")
  3893. {
  3894. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3895. }
  3896. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3897. lw.Add(string.Format("type != 'PDD' "));
  3898. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3899. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3900. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3901. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3902. writeGridDataTableJson(dStruct.TotalCount, dt);
  3903. }
  3904. public void get_erp_changedeliverylist()
  3905. {
  3906. DataStruct dStruct = GetPostStruct();
  3907. List<string> lw = new List<string>();
  3908. string tid = GetPostString("ctid");
  3909. if (tid.Length > 0)
  3910. {
  3911. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3912. if (tid.Length > 5)
  3913. {
  3914. List<string> tids = getTidByCtidLike(tid);
  3915. if (tids.Count > 0 && tids.Count < 10)
  3916. {
  3917. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3918. }
  3919. }
  3920. lw.Add(tid_sql);
  3921. }
  3922. string shopname = GetPostString("shopname");
  3923. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3924. string buyernick = GetPostString("buyer_nick");
  3925. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3926. //if (tid.Length == 0 && buyernick.Length == 0)
  3927. //{
  3928. // lw.Add(string.Format("IsRefund<={0}", 1));
  3929. //}
  3930. string customer = GetPostString("customer");
  3931. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3932. string design = GetPostString("design");
  3933. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3934. string orderState = GetPostString("orderState");
  3935. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3936. string address = GetPostString("address");
  3937. 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));
  3938. string sellermemo = GetPostString("seller_memo");
  3939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3940. string supplier = GetPostString("supplier");
  3941. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3942. string OrderArea = GetPostString("order_area");
  3943. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3944. string placedate1 = GetPostString("placedate1");
  3945. string placedate2 = GetPostString("placedate2");
  3946. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3947. if (fdw.Length > 0) lw.Add(fdw);
  3948. string price1 = GetPostString("price1");
  3949. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3950. string price2 = GetPostString("price2");
  3951. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3952. string unusualCon = GetPostString("unusualcon");
  3953. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3954. string otherMemo = GetPostString("otherMemo");
  3955. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3956. string posTag = CurrentUser.UserPost.Post.Code;
  3957. if (posTag == "Supplier")
  3958. {
  3959. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3960. }
  3961. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3962. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3963. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3964. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3965. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3966. /*if (tid.Length > 0)
  3967. {
  3968. List<string> tids = new List<string>();
  3969. if (dt != null && dt.Rows.Count > 0)
  3970. {
  3971. foreach (DataRow item in dt.Rows)
  3972. {
  3973. tids.Add("'" + item["tid"] + "'");
  3974. }
  3975. }
  3976. if (tids.Count > 0)
  3977. {
  3978. lw.RemoveAt(0);
  3979. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3980. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3981. dt = WebCache.GetData("view_erptradecell", dStruct);
  3982. }
  3983. }*/
  3984. writeGridDataTableJson(dStruct.TotalCount, dt);
  3985. }
  3986. public void get_erp_pddderiving()
  3987. {
  3988. DataStruct dStruct = GetPostStruct();
  3989. List<string> lw = new List<string>();
  3990. string tid = GetPostString("ctid");
  3991. if (tid.Length > 0)
  3992. {
  3993. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3994. if (tid.Length > 5)
  3995. {
  3996. List<string> tids = getTidByCtidLike(tid);
  3997. if (tids.Count > 0 && tids.Count < 10)
  3998. {
  3999. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4000. }
  4001. }
  4002. lw.Add(tid_sql);
  4003. }
  4004. string shopname = GetPostString("shopname");
  4005. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4006. string buyernick = GetPostString("buyer_nick");
  4007. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4008. //if (tid.Length == 0 && buyernick.Length == 0)
  4009. //{
  4010. // lw.Add(string.Format("IsRefund<={0}", 1));
  4011. //}
  4012. string customer = GetPostString("customer");
  4013. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4014. string design = GetPostString("design");
  4015. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4016. string orderState = GetPostString("orderState");
  4017. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4018. string address = GetPostString("address");
  4019. 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));
  4020. string sellermemo = GetPostString("seller_memo");
  4021. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4022. string supplier = GetPostString("supplier");
  4023. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4024. string OrderArea = GetPostString("order_area");
  4025. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4026. string placedate1 = GetPostString("placedate1");
  4027. string placedate2 = GetPostString("placedate2");
  4028. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4029. if (fdw.Length > 0) lw.Add(fdw);
  4030. string price1 = GetPostString("price1");
  4031. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4032. string price2 = GetPostString("price2");
  4033. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4034. string unusualCon = GetPostString("unusualcon");
  4035. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4036. string posTag = CurrentUser.UserPost.Post.Code;
  4037. if (posTag == "Supplier")
  4038. {
  4039. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4040. }
  4041. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4042. lw.Add(string.Format("type = 'PDD' "));
  4043. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4044. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4045. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4046. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4047. /*if (tid.Length > 0)
  4048. {
  4049. List<string> tids = new List<string>();
  4050. if (dt != null && dt.Rows.Count > 0)
  4051. {
  4052. foreach (DataRow item in dt.Rows)
  4053. {
  4054. tids.Add("'" + item["tid"] + "'");
  4055. }
  4056. }
  4057. if (tids.Count > 0)
  4058. {
  4059. lw.RemoveAt(0);
  4060. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4061. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4062. dt = WebCache.GetData("view_erptradecell", dStruct);
  4063. }
  4064. }*/
  4065. writeGridDataTableJson(dStruct.TotalCount, dt);
  4066. }
  4067. public void get_erp_jdderiving()
  4068. {
  4069. DataStruct dStruct = GetPostStruct();
  4070. List<string> lw = new List<string>();
  4071. string tid = GetPostString("ctid");
  4072. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4073. string shopname = GetPostString("shopname");
  4074. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4075. string buyernick = GetPostString("buyer_nick");
  4076. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4077. //if (tid.Length == 0 && buyernick.Length == 0)
  4078. //{
  4079. // lw.Add(string.Format("IsRefund<={0}", 1));
  4080. //}
  4081. string customer = GetPostString("customer");
  4082. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4083. string design = GetPostString("design");
  4084. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4085. string orderState = GetPostString("orderState");
  4086. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4087. string address = GetPostString("address");
  4088. 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));
  4089. string sellermemo = GetPostString("seller_memo");
  4090. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4091. string supplier = GetPostString("supplier");
  4092. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4093. string OrderArea = GetPostString("order_area");
  4094. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4095. string placedate1 = GetPostString("placedate1");
  4096. string placedate2 = GetPostString("placedate2");
  4097. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4098. if (fdw.Length > 0) lw.Add(fdw);
  4099. string price1 = GetPostString("price1");
  4100. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4101. string price2 = GetPostString("price2");
  4102. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4103. string unusualCon = GetPostString("unusualcon");
  4104. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4105. string posTag = CurrentUser.UserPost.Post.Code;
  4106. if (posTag == "Supplier")
  4107. {
  4108. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4109. }
  4110. lw.Add(string.Format("OrderState = 6 "));
  4111. lw.Add(string.Format("type = 'JD' "));
  4112. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4113. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4114. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4115. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4116. writeGridDataTableJson(dStruct.TotalCount, dt);
  4117. }
  4118. public void get_erp_demoorderlist()
  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 select_tid = getTidByCtid(tid);
  4126. lw.Add(string.Format("tid='{0}'", select_tid));
  4127. }
  4128. string shopname = GetPostString("shopname");
  4129. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4130. string buyernick = GetPostString("buyer_nick");
  4131. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4132. string customer = GetPostString("customer");
  4133. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4134. string design = GetPostString("design");
  4135. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4136. string orderState = GetPostString("orderState");
  4137. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4138. string address = GetPostString("address");
  4139. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4140. string sellermemo = GetPostString("seller_memo");
  4141. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4142. string supplier = GetPostString("supplier");
  4143. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4144. string OrderArea = GetPostString("order_area");
  4145. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4146. string date1 = GetPostString("date1");
  4147. string date2 = GetPostString("date2");
  4148. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4149. if (dw.Length > 0) lw.Add(dw);
  4150. string price1 = GetPostString("price1");
  4151. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4152. string price2 = GetPostString("price2");
  4153. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4154. string posTag = CurrentUser.UserPost.Post.Code;
  4155. if (posTag == "Supplier")
  4156. {
  4157. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4158. }
  4159. //lw.Add(string.Format("OrderState = 6 "));
  4160. lw.Add(string.Format("IsSample={0}", 3));
  4161. lw.Add(string.Format("IsRefund<={0}", 1));
  4162. dStruct.Order = "pay_time desc";
  4163. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4164. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4165. writeGridDataTableJson(dStruct.TotalCount, dt);
  4166. }
  4167. public void save_erp_checkmemo()
  4168. {
  4169. if (UrlPostParmsCheck("ctid"))
  4170. {
  4171. string ctid = GetPostString("ctid");
  4172. CeErpTradeCell entity = null;
  4173. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4174. if (entity != null)
  4175. {
  4176. entity.CheckMemo = GetPostString("CheckMemo");
  4177. entity.Update();
  4178. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4179. if (trade != null)
  4180. {
  4181. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4182. }
  4183. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4184. returnSuccessMsg("保存成功!");
  4185. return;
  4186. }
  4187. returnErrorMsg("找不到记录");
  4188. }
  4189. }
  4190. public void get_erp_returnlist()
  4191. {
  4192. DataStruct dStruct = GetPostStruct();
  4193. List<string> lw = new List<string>();
  4194. string tid = GetPostString("ctid");
  4195. if (tid.Length > 0)
  4196. {
  4197. string select_tid = getTidByCtid(tid);
  4198. lw.Add(string.Format("tid='{0}'", select_tid));
  4199. }
  4200. string shopname = GetPostString("shopname");
  4201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4202. string buyernick = GetPostString("buyer_nick");
  4203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4204. string customer = GetPostString("customer");
  4205. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4206. string design = GetPostString("design");
  4207. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4208. string orderState = GetPostString("orderState");
  4209. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4210. string address = GetPostString("address");
  4211. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4212. string sellermemo = GetPostString("seller_memo");
  4213. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4214. string supplier = GetPostString("supplier");
  4215. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4216. string date1 = GetPostString("date1");
  4217. string date2 = GetPostString("date2");
  4218. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4219. if (dw.Length > 0) lw.Add(dw);
  4220. string bdate1 = GetPostString("backdate1");
  4221. string bdate2 = GetPostString("backdate2");
  4222. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4223. if (dw_back.Length > 0) lw.Add(dw_back);
  4224. string price1 = GetPostString("price1");
  4225. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4226. string price2 = GetPostString("price2");
  4227. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4228. lw.Add(string.Format("IsReturn>0"));
  4229. lw.Add(string.Format("IsXianHuo=0"));
  4230. lw.Add(string.Format("IsReturn!=3"));
  4231. string backtype = GetPostString("backtype");
  4232. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4233. dStruct.Order = "FinishDesignTime desc";
  4234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4235. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4236. writeGridDataTableJson(dStruct.TotalCount, dt);
  4237. }
  4238. public void get_erp_today_sumreturn()
  4239. {
  4240. DataStruct dStruct = GetPostStruct();
  4241. List<string> lw = new List<string>();
  4242. string bdate1 = GetPostString("returnTimeS");
  4243. string bdate2 = GetPostString("returnTimeE");
  4244. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4245. if (dw_back.Length > 0) lw.Add(dw_back);
  4246. lw.Add(string.Format("IsReturn=0"));
  4247. lw.Add(string.Format("IsXianHuo=0"));
  4248. string mainWhere = string.Join(" and ", lw.ToArray());
  4249. string sql = "";
  4250. if (dw_back.Length > 0)
  4251. {
  4252. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4253. }
  4254. else
  4255. {
  4256. 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 + "'";
  4257. }
  4258. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4259. decimal total = 0, today_finish = 0;
  4260. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4261. {
  4262. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4263. }
  4264. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4265. {
  4266. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4267. }
  4268. var res = new
  4269. {
  4270. data = total,
  4271. data1 = today_finish,
  4272. };
  4273. string ro_jsond = JsonConvert.SerializeObject(res);
  4274. returnSuccess(ro_jsond);
  4275. return;
  4276. }
  4277. public void get_erp_allreturnlist()
  4278. {
  4279. DataStruct dStruct = GetPostStruct();
  4280. List<string> lw = new List<string>();
  4281. string tid = GetPostString("ctid");
  4282. if (tid.Length > 0)
  4283. {
  4284. string select_tid = getTidByCtid(tid);
  4285. lw.Add(string.Format("tid='{0}'", select_tid));
  4286. }
  4287. string shopname = GetPostString("shopname");
  4288. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4289. string buyernick = GetPostString("buyer_nick");
  4290. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4291. string customer = GetPostString("customer");
  4292. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4293. string design = GetPostString("design");
  4294. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4295. string orderState = GetPostString("orderState");
  4296. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4297. string address = GetPostString("address");
  4298. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4299. string sellermemo = GetPostString("seller_memo");
  4300. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4301. string supplier = GetPostString("supplier");
  4302. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4303. string date1 = GetPostString("date1");
  4304. string date2 = GetPostString("date2");
  4305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4306. if (dw.Length > 0) lw.Add(dw);
  4307. string bdate1 = GetPostString("backdate1");
  4308. string bdate2 = GetPostString("backdate2");
  4309. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4310. if (dw_back.Length > 0) lw.Add(dw_back);
  4311. string price1 = GetPostString("price1");
  4312. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4313. string price2 = GetPostString("price2");
  4314. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4315. string backreason = GetPostString("backreason");
  4316. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4317. lw.Add(string.Format("IsXianHuo=0"));
  4318. lw.Add(string.Format("ReturnTime != ''"));
  4319. string backtype = GetPostString("backtype");
  4320. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4321. dStruct.Order = "FinishDesignTime desc";
  4322. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4323. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4324. writeGridDataTableJson(dStruct.TotalCount, dt);
  4325. }
  4326. public void get_erp_aftersalereturnlist()
  4327. {
  4328. DataStruct dStruct = GetPostStruct();
  4329. List<string> lw = new List<string>();
  4330. string tid = GetPostString("ctid");
  4331. if (tid.Length > 0)
  4332. {
  4333. string select_tid = getTidByCtid(tid);
  4334. lw.Add(string.Format("tid='{0}'", select_tid));
  4335. }
  4336. string shopname = GetPostString("shopname");
  4337. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4338. string buyernick = GetPostString("buyer_nick");
  4339. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4340. string customer = GetPostString("customer");
  4341. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4342. string design = GetPostString("design");
  4343. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4344. string orderState = GetPostString("orderState");
  4345. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4346. string address = GetPostString("address");
  4347. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4348. string sellermemo = GetPostString("seller_memo");
  4349. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4350. string supplier = GetPostString("supplier");
  4351. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4352. string date1 = GetPostString("date1");
  4353. string date2 = GetPostString("date2");
  4354. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4355. if (dw.Length > 0) lw.Add(dw);
  4356. string bdate1 = GetPostString("backdate1");
  4357. string bdate2 = GetPostString("backdate2");
  4358. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4359. if (dw_back.Length > 0) lw.Add(dw_back);
  4360. string price1 = GetPostString("price1");
  4361. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4362. string price2 = GetPostString("price2");
  4363. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4364. lw.Add(string.Format("IsReturn=3"));
  4365. string backtype = GetPostString("backtype");
  4366. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4367. string backreason = GetPostString("backreason");
  4368. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4369. dStruct.Order = "ReturnTime desc";
  4370. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4371. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4372. writeGridDataTableJson(dStruct.TotalCount, dt);
  4373. }
  4374. public void get_erp_xianhuoreturnlist()
  4375. {
  4376. DataStruct dStruct = GetPostStruct();
  4377. List<string> lw = new List<string>();
  4378. string tid = GetPostString("ctid");
  4379. if (tid.Length > 0)
  4380. {
  4381. string select_tid = getTidByCtid(tid);
  4382. lw.Add(string.Format("tid='{0}'", select_tid));
  4383. }
  4384. string shopname = GetPostString("shopname");
  4385. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4386. string buyernick = GetPostString("buyer_nick");
  4387. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4388. string customer = GetPostString("customer");
  4389. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4390. string design = GetPostString("design");
  4391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4392. string orderState = GetPostString("orderState");
  4393. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4394. string address = GetPostString("address");
  4395. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4396. string sellermemo = GetPostString("seller_memo");
  4397. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4398. string supplier = GetPostString("supplier");
  4399. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4400. string OrderArea = GetPostString("order_area");
  4401. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4402. string date1 = GetPostString("date1");
  4403. string date2 = GetPostString("date2");
  4404. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4405. if (dw.Length > 0) lw.Add(dw);
  4406. string price1 = GetPostString("price1");
  4407. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4408. string price2 = GetPostString("price2");
  4409. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4410. string posTag = CurrentUser.UserPost.Post.Code;
  4411. if (posTag == "Supplier")
  4412. {
  4413. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4414. }
  4415. lw.Add(string.Format("OrderState=6 "));
  4416. lw.Add(string.Format("IsXianHuo=1 "));
  4417. lw.Add(string.Format("IsReturn>0 "));
  4418. lw.Add(string.Format("IsReturn!=3"));
  4419. lw.Add(string.Format("IsRefund<={0}", 1));
  4420. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4421. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4422. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4423. writeGridDataTableJson(dStruct.TotalCount, dt);
  4424. }
  4425. public void set_erp_orderdelivery()
  4426. {
  4427. if (UrlPostParmsCheck("ctid"))
  4428. {
  4429. string eid = GetPostString("ctid");
  4430. CeErpTradeCell entity = null;
  4431. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4432. if (entity != null)
  4433. {
  4434. if (entity.OrderState >= 7)
  4435. {
  4436. returnErrorMsg("此单已发货,无需重复发货");
  4437. return;
  4438. }
  4439. if (entity.OrderState != 6)
  4440. {
  4441. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4442. return;
  4443. }
  4444. string shop = GetPostString("seller_nick");
  4445. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4446. string comName = GetPostString("comName");
  4447. string comCode = GetPostString("comCode");
  4448. string outSid = GetPostString("outSid");
  4449. string deliveryType = GetPostString("deliveryType");
  4450. string deliveryMemo = GetPostString("deliveryMemo");
  4451. outSid = outSid.Trim();
  4452. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4453. if (mainEn == null)
  4454. {
  4455. returnErrorMsg("找不到原始订单记录");
  4456. return;
  4457. }
  4458. bool isInitOrderDeliv = false;
  4459. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4460. {
  4461. isInitOrderDeliv = true;
  4462. }
  4463. string apires = "";
  4464. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4465. 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)
  4466. {
  4467. apires = "发货成功true";
  4468. }
  4469. else
  4470. {
  4471. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4472. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4473. }
  4474. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4475. {
  4476. entity.OrderState = 7;//发货后订单已发货
  4477. entity.OutSid = outSid;
  4478. entity.MemoOpt = 0;
  4479. entity.UpdateTime = DateTime.Now;
  4480. entity.FinishDeliveryTime = DateTime.Now;
  4481. entity.Update();
  4482. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4483. commonHelper.UpdateRelationOrder(entity.ctid);
  4484. //还要插入快递信息到 快递信息表
  4485. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4486. exinfo.tid = eid;
  4487. exinfo.out_sid = outSid;
  4488. exinfo.company_code = comCode;
  4489. exinfo.company_name = comName;
  4490. exinfo.delivery_memo = deliveryMemo;
  4491. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4492. exinfo.deliveryType = deliveryType;
  4493. exinfo.Create();
  4494. returnSuccessMsg("发货操作成功!");
  4495. commonHelper.UpdateRelationOrder(entity.ctid);
  4496. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4497. CeErpSukuraData.createInfo(entity.ctid, 4);
  4498. if (entity.SupplierId == 64)
  4499. {
  4500. commonHelper.sendCytExpress(exinfo);
  4501. }
  4502. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4503. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4504. }
  4505. else
  4506. {
  4507. string errmsg = commonHelper.KeepChinese(apires);
  4508. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4509. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4510. }
  4511. return;
  4512. }
  4513. returnErrorMsg("找不到订单记录");
  4514. }
  4515. }
  4516. public void set_erp_multidelivery()
  4517. {
  4518. string eids = GetPostString("tids");
  4519. string[] eidList = eids.Split(',');
  4520. if (eidList.Length <= 0)
  4521. {
  4522. returnErrorMsg("发货不能为空");
  4523. return;
  4524. }
  4525. foreach (string ctid in eidList)
  4526. {
  4527. if (ctid.Length <= 0) continue;
  4528. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4529. if (expInfo != null)
  4530. {
  4531. StringBuilder sql = new StringBuilder();
  4532. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4533. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4534. if (dt.Rows.Count > 0)
  4535. {
  4536. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4537. {
  4538. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4539. expInfo.state = "异常";
  4540. expInfo.isMultiDelivery = 1;
  4541. expInfo.Update();
  4542. continue;
  4543. }
  4544. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4545. {
  4546. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4547. expInfo.state = "异常";
  4548. expInfo.Update();
  4549. continue;
  4550. }
  4551. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4552. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4553. bool isInitOrderDeliv = false;
  4554. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4555. {
  4556. isInitOrderDeliv = true;
  4557. expInfo.isMultiDelivery = 1;
  4558. }
  4559. if (ctid.IndexOf("N") != -1)
  4560. {
  4561. StringBuilder sqlbucha = new StringBuilder();
  4562. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4563. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4564. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4565. commonHelper.UpdateRelationOrder(ctid);
  4566. expInfo.delivery_memo = "发货成功";
  4567. expInfo.state = "发货成功";
  4568. expInfo.isMultiDelivery = 1;
  4569. expInfo.Update();
  4570. }
  4571. else
  4572. {
  4573. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4574. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4575. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4576. {
  4577. expInfo.delivery_memo = "发货成功";
  4578. expInfo.state = "发货成功";
  4579. expInfo.isMultiDelivery = 1;
  4580. expInfo.Update();
  4581. commonHelper.UpdateRelationOrder(ctid);
  4582. CeErpSukuraData.createInfo(ctid, 4);
  4583. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4584. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4585. }
  4586. else
  4587. {
  4588. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4589. expInfo.state = "异常";
  4590. expInfo.Update();
  4591. }
  4592. }
  4593. }
  4594. }
  4595. }
  4596. returnSuccessMsg("操作完成");
  4597. }
  4598. public void reset_erp_memoopt()
  4599. {
  4600. if (UrlPostParmsCheck("ctid"))
  4601. {
  4602. string eid = GetPostString("ctid");
  4603. CeErpTradeCell entity = null;
  4604. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4605. if (entity != null)
  4606. {
  4607. string stropt = "";
  4608. if (entity.MemoOpt == 1)
  4609. {
  4610. stropt = "“改稿”";
  4611. }
  4612. else if (entity.MemoOpt == 2)
  4613. {
  4614. stropt = "“定稿”";
  4615. }
  4616. else if (entity.MemoOpt == 3)
  4617. {
  4618. stropt = "“完成查货”";
  4619. CeErpSukuraData.createInfo(entity.ctid, 6);
  4620. }
  4621. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4622. entity.UpdateTime = DateTime.Now;
  4623. entity.MemoOpt = 0;
  4624. entity.Update();
  4625. returnSuccessMsg("操作成功!");
  4626. return;
  4627. }
  4628. returnErrorMsg("找不到记录");
  4629. }
  4630. }
  4631. public void get_erp_deliveryunusual()
  4632. {
  4633. DataStruct dStruct = GetPostStruct();
  4634. List<string> lw = new List<string>();
  4635. string tid = GetPostString("ctid");
  4636. if (tid.Length > 0)
  4637. {
  4638. string select_tid = getTidByCtid(tid);
  4639. lw.Add(string.Format("tid='{0}'", select_tid));
  4640. }
  4641. string shopname = GetPostString("shopname");
  4642. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4643. string buyernick = GetPostString("buyer_nick");
  4644. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4645. string customer = GetPostString("customer");
  4646. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4647. string design = GetPostString("design");
  4648. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4649. string sellermemo = GetPostString("seller_memo");
  4650. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4651. string supplier = GetPostString("supplier");
  4652. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4653. string date1 = GetPostString("date1");
  4654. string date2 = GetPostString("date2");
  4655. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4656. if (dw.Length > 0) lw.Add(dw);
  4657. string placedate1 = GetPostString("placedate1");
  4658. string placedate2 = GetPostString("placedate2");
  4659. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4660. if (dw_place.Length > 0) lw.Add(dw_place);
  4661. string price1 = GetPostString("price1");
  4662. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4663. string price2 = GetPostString("price2");
  4664. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4665. string unusualCon = GetPostString("unusualcon");
  4666. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4667. string posTag = CurrentUser.UserPost.Post.Code;
  4668. if (posTag == "Supplier")
  4669. {
  4670. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4671. }
  4672. lw.Add(string.Format("OrderState = 6"));
  4673. lw.Add(string.Format("UnusualTag = 5"));
  4674. lw.Add(string.Format("IsRefund<={0}", 1));
  4675. dStruct.Order = "FinishPlaceTime desc";
  4676. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4677. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4678. writeGridDataTableJson(dStruct.TotalCount, dt);
  4679. }
  4680. public void get_erp_deliveryedlist()
  4681. {
  4682. DataStruct dStruct = GetPostStruct();
  4683. List<string> lw = new List<string>();
  4684. string tid = GetPostString("ctid");
  4685. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4686. string shopname = GetPostString("shopname");
  4687. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4688. string buyernick = GetPostString("buyer_nick");
  4689. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4690. string customer = GetPostString("customer");
  4691. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4692. string design = GetPostString("design");
  4693. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4694. string sellermemo = GetPostString("seller_memo");
  4695. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4696. string logistics = GetPostString("logistics");
  4697. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4698. string date1 = GetPostString("date1");
  4699. string date2 = GetPostString("date2");
  4700. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4701. //if (dw.Length > 0) lw.Add(dw);
  4702. string placedate1 = GetPostString("placedate1");
  4703. string placedate2 = GetPostString("placedate2");
  4704. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4705. if (fdw.Length > 0) lw.Add(fdw);
  4706. string devdate1 = GetPostString("deliverydate1");
  4707. string devdate2 = GetPostString("deliverydate2");
  4708. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4709. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4710. string price1 = GetPostString("price1");
  4711. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4712. string price2 = GetPostString("price2");
  4713. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4714. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4715. {
  4716. if (tid.Length > 0)
  4717. {
  4718. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4719. if (tid.Length > 5)
  4720. {
  4721. List<string> tids = getTidByCtidLike(tid);
  4722. if (tids.Count > 0 && tids.Count < 10)
  4723. {
  4724. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4725. }
  4726. }
  4727. lw.Add(tid_sql);
  4728. }
  4729. if (buyernick.Length > 0)
  4730. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4731. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4732. if (dw.Length > 0) lw.Add(dw);
  4733. }
  4734. else
  4735. {
  4736. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4737. }
  4738. string posTag = CurrentUser.UserPost.Post.Code;
  4739. if (posTag == "Supplier")
  4740. {
  4741. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4742. }
  4743. else
  4744. {
  4745. string supplier = GetPostString("supplier");
  4746. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4747. }
  4748. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4749. lw.Add(string.Format("type != 'PDD' "));
  4750. lw.Add(string.Format("IsRefund!={0}", 2));
  4751. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4752. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4753. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4754. /*if (tid.Length > 0)
  4755. {
  4756. List<string> tids = new List<string>();
  4757. if (dt != null && dt.Rows.Count > 0)
  4758. {
  4759. foreach (DataRow item in dt.Rows)
  4760. {
  4761. tids.Add("'" + item["tid"] + "'");
  4762. }
  4763. }
  4764. if (tids.Count > 0)
  4765. {
  4766. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4767. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4768. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4769. dt = WebCache.GetData("view_erptradecell", dStruct);
  4770. }
  4771. }*/
  4772. if (dt != null)
  4773. {
  4774. foreach (DataRow dr in dt.Rows)
  4775. {
  4776. 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();
  4777. }
  4778. }
  4779. writeGridDataTableJson(dStruct.TotalCount, dt);
  4780. }
  4781. public void get_erp_pdddeliveryed()
  4782. {
  4783. DataStruct dStruct = GetPostStruct();
  4784. List<string> lw = new List<string>();
  4785. string tid = GetPostString("ctid");
  4786. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4787. string shopname = GetPostString("shopname");
  4788. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4789. string buyernick = GetPostString("buyer_nick");
  4790. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4791. string customer = GetPostString("customer");
  4792. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4793. string design = GetPostString("design");
  4794. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4795. string sellermemo = GetPostString("seller_memo");
  4796. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4797. string logistics = GetPostString("logistics");
  4798. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4799. string date1 = GetPostString("date1");
  4800. string date2 = GetPostString("date2");
  4801. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4802. //if (dw.Length > 0) lw.Add(dw);
  4803. string placedate1 = GetPostString("placedate1");
  4804. string placedate2 = GetPostString("placedate2");
  4805. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4806. if (fdw.Length > 0) lw.Add(fdw);
  4807. string devdate1 = GetPostString("deliverydate1");
  4808. string devdate2 = GetPostString("deliverydate2");
  4809. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4810. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4811. string price1 = GetPostString("price1");
  4812. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4813. string price2 = GetPostString("price2");
  4814. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4815. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4816. {
  4817. if (tid.Length > 0)
  4818. {
  4819. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4820. if (tid.Length > 5)
  4821. {
  4822. List<string> tids = getTidByCtidLike(tid);
  4823. if (tids.Count > 0 && tids.Count < 10)
  4824. {
  4825. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4826. }
  4827. }
  4828. lw.Add(tid_sql);
  4829. }
  4830. if (buyernick.Length > 0)
  4831. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4832. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4833. if (dw.Length > 0) lw.Add(dw);
  4834. }
  4835. else
  4836. {
  4837. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4838. }
  4839. string posTag = CurrentUser.UserPost.Post.Code;
  4840. if (posTag == "Supplier")
  4841. {
  4842. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4843. }
  4844. else
  4845. {
  4846. string supplier = GetPostString("supplier");
  4847. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4848. }
  4849. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4850. lw.Add(string.Format("type = 'PDD' "));
  4851. lw.Add(string.Format("IsRefund!={0}", 2));
  4852. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4854. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4855. /* if (tid.Length > 0)
  4856. {
  4857. List<string> tids = new List<string>();
  4858. if (dt != null && dt.Rows.Count > 0)
  4859. {
  4860. foreach (DataRow item in dt.Rows)
  4861. {
  4862. tids.Add("'" + item["tid"] + "'");
  4863. }
  4864. }
  4865. if (tids.Count > 0)
  4866. {
  4867. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4868. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4869. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4870. dt = WebCache.GetData("view_erptradecell", dStruct);
  4871. }
  4872. }*/
  4873. foreach (DataRow dr in dt.Rows)
  4874. {
  4875. 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();
  4876. }
  4877. writeGridDataTableJson(dStruct.TotalCount, dt);
  4878. }
  4879. public void get_erp_jddeliveryed()
  4880. {
  4881. DataStruct dStruct = GetPostStruct();
  4882. List<string> lw = new List<string>();
  4883. string tid = GetPostString("ctid");
  4884. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4885. string shopname = GetPostString("shopname");
  4886. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4887. string buyernick = GetPostString("buyer_nick");
  4888. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4889. string customer = GetPostString("customer");
  4890. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4891. string design = GetPostString("design");
  4892. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4893. string sellermemo = GetPostString("seller_memo");
  4894. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4895. string date1 = GetPostString("date1");
  4896. string date2 = GetPostString("date2");
  4897. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4898. //if (dw.Length > 0) lw.Add(dw);
  4899. string placedate1 = GetPostString("placedate1");
  4900. string placedate2 = GetPostString("placedate2");
  4901. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4902. if (fdw.Length > 0) lw.Add(fdw);
  4903. string devdate1 = GetPostString("deliverydate1");
  4904. string devdate2 = GetPostString("deliverydate2");
  4905. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4906. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4907. string price1 = GetPostString("price1");
  4908. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4909. string price2 = GetPostString("price2");
  4910. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4911. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4912. {
  4913. if (tid.Length > 0)
  4914. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4915. if (buyernick.Length > 0)
  4916. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4917. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4918. if (dw.Length > 0) lw.Add(dw);
  4919. }
  4920. else
  4921. {
  4922. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4923. }
  4924. string posTag = CurrentUser.UserPost.Post.Code;
  4925. if (posTag == "Supplier")
  4926. {
  4927. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4928. }
  4929. else
  4930. {
  4931. string supplier = GetPostString("supplier");
  4932. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4933. }
  4934. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4935. lw.Add(string.Format("type = 'JD' "));
  4936. lw.Add(string.Format("IsRefund!={0}", 2));
  4937. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4938. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4939. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4940. foreach (DataRow dr in dt.Rows)
  4941. {
  4942. 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();
  4943. }
  4944. writeGridDataTableJson(dStruct.TotalCount, dt);
  4945. }
  4946. public void get_erp_allplacelist()
  4947. {
  4948. DataStruct dStruct = GetPostStruct();
  4949. List<string> lw = new List<string>();
  4950. string tid = GetPostString("ctid");
  4951. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4952. string shopname = GetPostString("shopname");
  4953. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4954. string buyernick = GetPostString("buyer_nick");
  4955. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4956. string customer = GetPostString("customer");
  4957. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4958. string design = GetPostString("design");
  4959. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4960. string sellermemo = GetPostString("seller_memo");
  4961. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4962. string supplier = GetPostString("supplier");
  4963. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4964. string date1 = GetPostString("date1");
  4965. string date2 = GetPostString("date2");
  4966. string pldate1 = GetPostString("placedate1");
  4967. string pldate2 = GetPostString("placedate2");
  4968. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4969. //if (dw.Length > 0) lw.Add(dw);
  4970. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4971. {
  4972. if (tid.Length > 0)
  4973. {
  4974. string select_tid = getTidByCtid(tid);
  4975. lw.Add(string.Format("tid='{0}'", select_tid));
  4976. }
  4977. if (buyernick.Length > 0)
  4978. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4979. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4980. if (dw.Length > 0) lw.Add(dw);
  4981. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4982. if (dw_place.Length > 0) lw.Add(dw_place);
  4983. }
  4984. else
  4985. {
  4986. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4987. {
  4988. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4989. }
  4990. }
  4991. string price1 = GetPostString("price1");
  4992. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4993. string price2 = GetPostString("price2");
  4994. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4995. string posTag = CurrentUser.UserPost.Post.Code;
  4996. if (posTag == "Supplier")
  4997. {
  4998. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4999. }
  5000. lw.Add(string.Format("OrderState >= 6"));
  5001. lw.Add(string.Format("IsSample != 2 "));
  5002. //lw.Add(string.Format("isDianziOrder = 0 "));
  5003. lw.Add(string.Format("SupplierId > 0 "));
  5004. //lw.Add(string.Format("IsRefund<={0}", 1));
  5005. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5006. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5007. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5008. foreach (DataRow dr in dt.Rows)
  5009. {
  5010. 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();
  5011. }
  5012. writeGridDataTableJson(dStruct.TotalCount, dt);
  5013. }
  5014. public void get_erp_financeallplacelist()
  5015. {
  5016. DataStruct dStruct = GetPostStruct();
  5017. List<string> lw = new List<string>();
  5018. string tid = GetPostString("ctid");
  5019. string shopname = GetPostString("shopname");
  5020. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5021. string buyernick = GetPostString("buyer_nick");
  5022. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5023. string customer = GetPostString("customer");
  5024. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5025. string design = GetPostString("design");
  5026. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5027. string sellermemo = GetPostString("seller_memo");
  5028. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5029. string supplier = GetPostString("supplier");
  5030. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5031. string date1 = GetPostString("date1");
  5032. string date2 = GetPostString("date2");
  5033. string pldate1 = GetPostString("placedate1");
  5034. string pldate2 = GetPostString("placedate2");
  5035. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5036. {
  5037. if (tid.Length > 0)
  5038. {
  5039. string select_tid = getTidByCtid(tid);
  5040. lw.Add(string.Format("tid='{0}'", select_tid));
  5041. }
  5042. if (buyernick.Length > 0)
  5043. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5044. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5045. if (dw.Length > 0) lw.Add(dw);
  5046. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5047. if (dw_place.Length > 0) lw.Add(dw_place);
  5048. }
  5049. else
  5050. {
  5051. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5052. {
  5053. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5054. }
  5055. }
  5056. string price1 = GetPostString("price1");
  5057. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5058. string price2 = GetPostString("price2");
  5059. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5060. string posTag = CurrentUser.UserPost.Post.Code;
  5061. if (posTag == "Supplier")
  5062. {
  5063. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5064. }
  5065. //lw.Add(string.Format("OrderState >= 6"));
  5066. lw.Add(string.Format("IsSample != 2 "));
  5067. lw.Add(string.Format("isDianziOrder = 0 "));
  5068. //lw.Add(string.Format("IsRefund<={0}", 1));
  5069. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5071. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5072. foreach (DataRow dr in dt.Rows)
  5073. {
  5074. 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();
  5075. }
  5076. writeGridDataTableJson(dStruct.TotalCount, dt);
  5077. }
  5078. public void get_erp_expresslist()
  5079. {
  5080. int listtype = GetInt("ltype");
  5081. DataStruct dStruct = GetPostStruct();
  5082. List<string> lw = new List<string>();
  5083. string tid = GetPostString("tid");
  5084. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5085. string outsid = GetPostString("out_sid");
  5086. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5087. string importer = GetPostString("ImportUserName");
  5088. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5089. string file = GetPostString("import_file");
  5090. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5091. string printman = GetPostString("printman");
  5092. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5093. string date1 = GetPostString("date1");
  5094. string date2 = GetPostString("date2");
  5095. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5096. if (dw.Length > 0) lw.Add(dw);
  5097. string fdate1 = GetPostString("finishdate1");
  5098. string fdate2 = GetPostString("finishdate2");
  5099. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5100. if (fdw.Length > 0) lw.Add(fdw);
  5101. string supplierId = GetPostString("supplierId");
  5102. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5103. if (listtype == 1)
  5104. {
  5105. lw.Add(string.Format("importUserId !=0"));
  5106. }
  5107. string posTag = CurrentUser.UserPost.Post.Code;
  5108. if (posTag == "Supplier")
  5109. {
  5110. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5111. }
  5112. if (dStruct.PageSize != 100000)
  5113. {
  5114. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5115. }
  5116. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5117. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5118. writeGridDataTableJson(dStruct.TotalCount, dt);
  5119. }
  5120. public void set_erp_buchaorderdelivery()
  5121. {
  5122. if (UrlPostParmsCheck("ctid"))
  5123. {
  5124. string eid = GetPostString("ctid");
  5125. CeErpTradeCell entity = null;
  5126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5127. if (entity != null)
  5128. {
  5129. if (entity.IsSample != 2)
  5130. {
  5131. returnErrorMsg("补差价单才能标记为已发货");
  5132. return;
  5133. }
  5134. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5135. entity.OrderState = 7;
  5136. entity.Update();
  5137. returnSuccessMsg("操作成功!");
  5138. return;
  5139. }
  5140. returnErrorMsg("找不到记录");
  5141. }
  5142. }
  5143. public void get_stdtemplates()
  5144. {
  5145. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5146. //string res = taobaoHelper.test();
  5147. string res = apiHelper.API_PrintTemplate();
  5148. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5149. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5150. {
  5151. int sidx = res.IndexOf("error_code");
  5152. int eidx = res.IndexOf("success");
  5153. string msg = res.Substring(sidx, eidx - sidx);
  5154. returnErrorMsg(msg);
  5155. return;
  5156. }
  5157. if (res.Length <= 0)
  5158. {
  5159. returnErrorMsg("模板数据为空!");
  5160. return;
  5161. }
  5162. ReturnSuccess(res);
  5163. }
  5164. public void cancel_print_order()
  5165. {
  5166. if (UrlPostParmsCheck("ctid"))
  5167. {
  5168. string ctid = GetPostString("ctid");
  5169. CeErpTradeCell entity = null;
  5170. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5171. if (entity != null)
  5172. {
  5173. string res = "";
  5174. string code = entity.LastBillWaybillCode;
  5175. if (code == "")
  5176. {
  5177. code = entity.OutSid;
  5178. }
  5179. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5180. XLog.SaveLog(0, "取消面单" + res);
  5181. }
  5182. }
  5183. }
  5184. public void set_erp_printwaybill()
  5185. {
  5186. if (UrlPostParmsCheck("ctid"))
  5187. {
  5188. string ctid = GetPostString("ctid");
  5189. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5190. string cpName = GetPostString("cpname");
  5191. string isTogether = GetPostString("together");
  5192. //var res_obj = new
  5193. //{
  5194. // restype = 1,
  5195. // 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\"}"
  5196. //};
  5197. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5198. //ReturnSuccess(ro_json);
  5199. //return;
  5200. bool isUseLastWayBillCode = false;
  5201. CeErpTradeCell entity = null;
  5202. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5203. if (entity != null)
  5204. {
  5205. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5206. {
  5207. isUseLastWayBillCode = true;
  5208. }
  5209. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5210. {
  5211. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5212. return;
  5213. }
  5214. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5215. {
  5216. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5217. return;
  5218. }
  5219. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5220. {
  5221. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5222. return;
  5223. }
  5224. }
  5225. string res = "";
  5226. Api_waybill_code_response_Obj fullObj = null;
  5227. string pData_str = "";
  5228. string curUseWayBillCode = "";
  5229. if (isUseLastWayBillCode == false)
  5230. {
  5231. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5232. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5233. if (res.IndexOf("failure") != -1)
  5234. {
  5235. //int idx = res.IndexOf("sub_message");
  5236. //int idx2 = res.IndexOf("flag");
  5237. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5238. string errMsgNeed = commonHelper.KeepChinese(res);
  5239. var res_objd = new
  5240. {
  5241. restype = 0,
  5242. data = "获取面单失败" + errMsgNeed
  5243. };
  5244. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5245. returnSuccess(ro_jsond);
  5246. if (res.IndexOf("停发") != -1)
  5247. {
  5248. entity.UnusualCon = "物流停发";
  5249. entity.Update();
  5250. }
  5251. //returnErrorMsg("获取面单失败,"+emsg);
  5252. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5253. return;
  5254. }
  5255. else if (res.IndexOf("errorMsg") != -1)
  5256. {
  5257. //int idx = res.IndexOf("errorMsg");
  5258. //int idx2 = res.IndexOf("}]}");
  5259. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5260. string errMsgNeed = commonHelper.KeepChinese(res);
  5261. var res_objf = new
  5262. {
  5263. restype = 0,
  5264. data = "获取面单失败2" + errMsgNeed
  5265. };
  5266. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5267. if (res.IndexOf("停发") != -1)
  5268. {
  5269. entity.UnusualCon = "物流停发";
  5270. entity.Update();
  5271. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5272. if (trade != null)
  5273. {
  5274. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5275. }
  5276. }
  5277. returnSuccess(ro_jsonf);
  5278. //returnErrorMsg("获取面单失败," + emsg);
  5279. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5280. return;
  5281. }
  5282. try
  5283. {
  5284. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5285. //res = res.Replace(" ", "");
  5286. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5287. }
  5288. catch (Exception ex)
  5289. {
  5290. XLog.SaveLog(0, "生成fullObj" + res);
  5291. var res_objf = new
  5292. {
  5293. restype = 0,
  5294. data = "生成fullObj发生错误" + ex.Message
  5295. };
  5296. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5297. returnSuccess(ro_jsonf);
  5298. return;
  5299. }
  5300. if (fullObj.response.data.content.Count > 0)
  5301. {
  5302. ContentItem codeObj = fullObj.response.data.content[0];
  5303. if (cpCode.IndexOf("SFFQ-") != -1)
  5304. {
  5305. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5306. }
  5307. else
  5308. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5309. curUseWayBillCode = codeObj.waybillCode;
  5310. }
  5311. else
  5312. {
  5313. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5314. var res_objf = new
  5315. {
  5316. restype = 0,
  5317. data = "生成fullObj找不到快递单号waybillCode"
  5318. };
  5319. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5320. returnSuccess(ro_jsonf);
  5321. return;
  5322. }
  5323. }
  5324. else
  5325. {
  5326. //使用上次打印的快递单号
  5327. if (cpCode == "SFFQ-LY")
  5328. {
  5329. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5330. }
  5331. else
  5332. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5333. curUseWayBillCode = entity.LastBillWaybillCode;
  5334. }
  5335. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5336. {
  5337. var res_obje = new
  5338. {
  5339. restype = 0,
  5340. data = "获取加密打印数据失败"
  5341. };
  5342. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5343. returnSuccess(ro_jsone);
  5344. entity.LastBillCpCode = cpCode;
  5345. entity.LastBillWaybillCode = curUseWayBillCode;
  5346. entity.Update();
  5347. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5348. //returnErrorMsg("获取加密打印数据失败");
  5349. return;
  5350. }
  5351. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5352. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5353. string btnType = "";
  5354. string errorMsg = "";
  5355. if (entity != null)
  5356. {
  5357. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5358. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5359. //cpcode是 YTO-CAINIAO
  5360. //string comCode = cpCode.Split('-')[0].ToString();
  5361. string apires = "";
  5362. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5363. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5364. {
  5365. if (ctid.IndexOf("N") != -1)
  5366. {
  5367. apires = "发货成功";
  5368. }
  5369. else
  5370. {
  5371. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5372. }
  5373. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5374. //打单后发货
  5375. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5376. {
  5377. try
  5378. {
  5379. btnType = "待发货";
  5380. entity.OutSid = curUseWayBillCode;
  5381. entity.OrderState = 7;
  5382. entity.IsUrgency = false;
  5383. entity.LastBillCpCode = "";
  5384. entity.LastBillWaybillCode = "";
  5385. entity.FinishDeliveryTime = DateTime.Now;
  5386. entity.IsReturn = 0;
  5387. entity.MemoOpt = 0;
  5388. entity.UpdateTime = DateTime.Now;
  5389. entity.Update();
  5390. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5391. //还要插入快递信息到 快递信息表
  5392. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5393. exinfo.tid = entity.ctid;
  5394. exinfo.out_sid = curUseWayBillCode;
  5395. exinfo.company_code = cpCode;
  5396. exinfo.company_name = cpName;
  5397. exinfo.supplierUserName = supplierName;
  5398. exinfo.deliveryType = "发货成功";
  5399. exinfo.print_time = DateTime.Now;
  5400. exinfo.printUser = CurrentUser.UserName;
  5401. exinfo.postData = pData_str;
  5402. exinfo.Create();
  5403. commonHelper.UpdateRelationOrder(entity.ctid);
  5404. CeErpSukuraData.createInfo(ctid, 4);
  5405. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5406. if (entity.SupplierId == 64)
  5407. {
  5408. commonHelper.sendCytExpress(exinfo);
  5409. }
  5410. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5411. if (!string.IsNullOrEmpty(isTogether))
  5412. {
  5413. if (Convert.ToInt32(isTogether) > 0)
  5414. {
  5415. StringBuilder sqlsb = new StringBuilder();
  5416. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5417. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5418. }
  5419. }
  5420. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5421. }
  5422. catch (Exception ex)
  5423. {
  5424. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5425. }
  5426. }
  5427. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5428. {
  5429. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5430. if (entity.OrderState == 6)
  5431. {
  5432. entity.OrderState = 7;
  5433. }
  5434. entity.UpdateTime = DateTime.Now;
  5435. entity.FinishDeliveryTime = DateTime.Now;
  5436. btnType = "已发货";
  5437. entity.Update();
  5438. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5439. exinfo.tid = entity.ctid;
  5440. exinfo.out_sid = curUseWayBillCode;
  5441. exinfo.company_code = cpCode;
  5442. exinfo.company_name = cpName;
  5443. exinfo.supplierUserName = supplierName;
  5444. exinfo.deliveryType = "发货成功";
  5445. exinfo.print_time = DateTime.Now;
  5446. exinfo.printUser = CurrentUser.UserName;
  5447. exinfo.postData = pData_str;
  5448. exinfo.Create();
  5449. commonHelper.UpdateRelationOrder(entity.ctid);
  5450. CeErpSukuraData.createInfo(entity.ctid, 4);
  5451. if (entity.SupplierId == 64)
  5452. {
  5453. commonHelper.sendCytExpress(exinfo);
  5454. }
  5455. if (!string.IsNullOrEmpty(isTogether))
  5456. {
  5457. if (Convert.ToInt32(isTogether) > 0)
  5458. {
  5459. StringBuilder sqlsb = new StringBuilder();
  5460. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE() where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5461. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5462. }
  5463. }
  5464. //不处理
  5465. }
  5466. else
  5467. {
  5468. entity.UpdateTime = DateTime.Now;
  5469. entity.LastBillCpCode = cpCode;
  5470. entity.LastBillWaybillCode = curUseWayBillCode;
  5471. entity.Update();
  5472. string errmsg = commonHelper.KeepChinese(apires);
  5473. var res_objz = new
  5474. {
  5475. restype = 0,
  5476. data = "打单后发货失败"
  5477. };
  5478. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5479. returnSuccess(ro_jsonz);
  5480. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5481. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5482. return;
  5483. }
  5484. }
  5485. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5486. {
  5487. StringBuilder allSql = new StringBuilder();
  5488. allSql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,tid from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
  5489. if (string.IsNullOrEmpty(mainEn.receiverId))
  5490. {
  5491. allSql.AppendFormat(" and (tid='{0}');", entity.tid);
  5492. }
  5493. else
  5494. {
  5495. //查询同车间同状态下的收货地址相同的单子
  5496. allSql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}') );", entity.tid, mainEn.receiverId, entity.IsSF);
  5497. }
  5498. DataTable dt = DbHelper.DbConn.ExecuteDataset(allSql.ToString()).Tables[0];
  5499. List<string> list = new List<string>();
  5500. List<string> send_list = new List<string>();
  5501. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5502. CeErpTrade ceErpTrade = new CeErpTrade();
  5503. foreach (DataRow row in dt.Rows)
  5504. {
  5505. list.Add("'" + row["ctid"] + "'");
  5506. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5507. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5508. if (ctid.IndexOf("N") != -1)
  5509. {
  5510. apires = "发货成功";
  5511. }
  5512. else
  5513. {
  5514. if (!send_list.Contains(ceErpTrade.tid))
  5515. {
  5516. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5517. }
  5518. else
  5519. {
  5520. apires = "发货成功";
  5521. }
  5522. }
  5523. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5524. {
  5525. send_list.Add(ceErpTrade.tid);
  5526. try
  5527. {
  5528. btnType = "待发货";
  5529. ceErpTradeCell.OutSid = curUseWayBillCode;
  5530. ceErpTradeCell.OrderState = 7;
  5531. ceErpTradeCell.IsUrgency = false;
  5532. ceErpTradeCell.LastBillCpCode = "";
  5533. ceErpTradeCell.LastBillWaybillCode = "";
  5534. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5535. ceErpTradeCell.IsReturn = 0;
  5536. ceErpTradeCell.MemoOpt = 0;
  5537. ceErpTradeCell.UpdateTime = DateTime.Now;
  5538. ceErpTradeCell.Update();
  5539. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5540. //还要插入快递信息到 快递信息表
  5541. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5542. exinfo.tid = ceErpTradeCell.ctid;
  5543. exinfo.out_sid = curUseWayBillCode;
  5544. exinfo.company_code = cpCode;
  5545. exinfo.company_name = cpName;
  5546. exinfo.supplierUserName = supplierName;
  5547. exinfo.deliveryType = "发货成功";
  5548. exinfo.print_time = DateTime.Now;
  5549. exinfo.printUser = CurrentUser.UserName;
  5550. exinfo.postData = pData_str;
  5551. exinfo.Create();
  5552. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5553. CeErpSukuraData.createInfo(ctid, 4);
  5554. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5555. if (ceErpTradeCell.SupplierId == 64)
  5556. {
  5557. commonHelper.sendCytExpress(exinfo);
  5558. }
  5559. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5560. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5561. }
  5562. catch (Exception ex)
  5563. {
  5564. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5565. }
  5566. }
  5567. else
  5568. {
  5569. ceErpTradeCell.UpdateTime = DateTime.Now;
  5570. ceErpTradeCell.LastBillCpCode = cpCode;
  5571. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5572. ceErpTradeCell.Update();
  5573. string errmsg = commonHelper.KeepChinese(apires);
  5574. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5575. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5576. }
  5577. }
  5578. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5579. }
  5580. }
  5581. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5582. var res_obj = new
  5583. {
  5584. restype = 1,
  5585. data = pData_str,
  5586. errorMsg
  5587. };
  5588. string ro_json = JsonConvert.SerializeObject(res_obj);
  5589. ReturnSuccess(ro_json);
  5590. return;
  5591. }
  5592. }
  5593. private string GetUTF8String(byte[] vs)
  5594. {
  5595. throw new NotImplementedException();
  5596. }
  5597. public void set_erp_printwaybill_cn()
  5598. {
  5599. if (UrlPostParmsCheck("ctid"))
  5600. {
  5601. string ctid = GetPostString("ctid");
  5602. string cpCode = GetPostString("cpcode");
  5603. string cpName = GetPostString("cpname");
  5604. string tempUrl = GetPostString("tempurl");
  5605. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5606. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5607. //string res = taobaoHelper.test();
  5608. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5609. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5610. {
  5611. int sidx = res.IndexOf("errorMsg");
  5612. int eidx = res.IndexOf("}");
  5613. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5614. var res_objzxx = new
  5615. {
  5616. restype = 0,
  5617. data = msg
  5618. };
  5619. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5620. returnSuccess(ro_jsonzxx);
  5621. //returnErrorMsg(msg);
  5622. return;
  5623. }
  5624. int idx = res.IndexOf("waybillCode");
  5625. int idx2 = res.IndexOf("printData");
  5626. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5627. string eid = GetPostString("ctid");
  5628. CeErpTradeCell entity = null;
  5629. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5630. if (entity != null)
  5631. {
  5632. string osid = entity.OutSid;
  5633. entity.OutSid = osid + "," + outsid;
  5634. entity.FinishDeliveryTime = DateTime.Now;
  5635. entity.OrderState = 7;
  5636. entity.UpdateTime = DateTime.Now;
  5637. entity.IsReturn = 0;
  5638. entity.Update();
  5639. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5640. exinfo.tid = entity.ctid;
  5641. exinfo.out_sid = outsid;
  5642. exinfo.company_code = cpCode;
  5643. exinfo.company_name = cpName;
  5644. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5645. exinfo.deliveryType = "发货成功";
  5646. exinfo.print_time = DateTime.Now;
  5647. exinfo.printUser = CurrentUser.UserName;
  5648. exinfo.Create();
  5649. if (entity.SupplierId == 64)
  5650. {
  5651. commonHelper.sendCytExpress(exinfo);
  5652. }
  5653. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5654. }
  5655. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5656. var res_objz = new
  5657. {
  5658. restype = 1,
  5659. data = res
  5660. };
  5661. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5662. returnSuccess(ro_jsonz);
  5663. //ReturnSuccess(res);
  5664. }
  5665. }
  5666. ////打单,打印面单 获取面单号
  5667. //public void set_erp_printwaybill()
  5668. //{
  5669. // if (UrlPostParmsCheck("ctid"))
  5670. // {
  5671. // string ctid = GetPostString("ctid");
  5672. // string cpCode = GetPostString("cpcode");
  5673. // string tempUrl = GetPostString("tempurl");
  5674. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5675. // //string res = taobaoHelper.test();
  5676. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5677. // if (res.IndexOf("error_response") != -1)
  5678. // {
  5679. // int sidx = res.IndexOf("sub_msg");
  5680. // int eidx = res.IndexOf("request_id");
  5681. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5682. // returnErrorMsg(msg);
  5683. // return;
  5684. // }
  5685. // int idx = res.IndexOf("waybill_code");
  5686. // int idx2 = res.IndexOf("}]}");
  5687. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5688. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5689. // ReturnSuccess(res);
  5690. // }
  5691. //}
  5692. public void cancel_erp_aftersale()
  5693. {
  5694. if (UrlPostParmsCheck("ctid"))
  5695. {
  5696. string eid = GetPostString("ctid");
  5697. CeErpTradeCell entity = null;
  5698. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5699. if (entity != null)
  5700. {
  5701. //有过处理的售后,取消也不能删除 售 字,保留
  5702. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5703. {
  5704. entity.AfterSaleState = 4;
  5705. }
  5706. else
  5707. entity.AfterSaleState = 0;
  5708. entity.UpdateTime = DateTime.Now;
  5709. entity.Update();
  5710. returnSuccessMsg("操作成功!");
  5711. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5712. return;
  5713. }
  5714. returnErrorMsg("找不到订单记录");
  5715. }
  5716. }
  5717. public void get_erp_aftersalelist()
  5718. {
  5719. DataStruct dStruct = GetPostStruct();
  5720. List<string> lw = new List<string>();
  5721. int st = GetInt("st");
  5722. string tid = GetPostString("ctid");
  5723. if (st == 3)
  5724. {
  5725. if (tid.Length > 0)
  5726. {
  5727. string select_tid = getTidByCtid(tid);
  5728. lw.Add(string.Format("tid='{0}'", select_tid));
  5729. }
  5730. }
  5731. else
  5732. {
  5733. if (tid.Length > 0)
  5734. {
  5735. string select_tid = getTidByCtid(tid);
  5736. lw.Add(string.Format("tid='{0}'", select_tid));
  5737. }
  5738. }
  5739. string shopname = GetPostString("shopname");
  5740. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5741. string buyernick = GetPostString("buyer_nick");
  5742. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5743. string sellermemo = GetPostString("seller_memo");
  5744. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5745. string orderState = GetPostString("orderState");
  5746. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5747. string afterState = GetPostString("afterstate");
  5748. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5749. string date1 = GetPostString("date1");
  5750. string date2 = GetPostString("date2");
  5751. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5752. if (dw.Length > 0) lw.Add(dw);
  5753. string price1 = GetPostString("price1");
  5754. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5755. string price2 = GetPostString("price2");
  5756. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5757. //lw.Add(string.Format("IsRefund!={0}", 1));
  5758. string reason = GetPostString("reason");
  5759. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5760. string method = GetPostString("method");
  5761. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5762. string handler = GetPostString("handler");
  5763. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5764. string handledate1 = GetPostString("handledate1");
  5765. string handledate2 = GetPostString("handledate2");
  5766. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5767. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5768. string finish1 = GetPostString("finishdate1");
  5769. string finish2 = GetPostString("finishdate2");
  5770. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5771. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5772. string afterdate1 = GetPostString("afterdate1");
  5773. string afterdate2 = GetPostString("afterdate2");
  5774. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5775. if (afterDate.Length > 0) lw.Add(afterDate);
  5776. string supplier = GetPostString("supplier");
  5777. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5778. string responsible = GetPostString("responsibleman");
  5779. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5780. string customer = GetPostString("customer");
  5781. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5782. string design = GetPostString("design");
  5783. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5784. string afterMemoType = GetPostString("aftermemotype");
  5785. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5786. string posCode = CurrentUser.UserPost.Post.Code;
  5787. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5788. //{
  5789. // string vstate = GetPostString("vstate");
  5790. // if (vstate.Length > 0)
  5791. // {
  5792. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5793. // }
  5794. // if (posCode == "Supplier")
  5795. // {
  5796. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5797. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5798. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5799. // }
  5800. // else
  5801. // {
  5802. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5803. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5804. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5805. // {
  5806. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5807. // }
  5808. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5809. // {
  5810. // int orgid = CurrentUser.UserPost.OrgID;
  5811. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5812. // }
  5813. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5814. // {
  5815. // string shopid = CurrentUser.User.pemShop;
  5816. // lw.Add(string.Format("shopId in ({0})", shopid));
  5817. // }
  5818. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5819. // //{
  5820. // // int org_id = CurrentUser.UserPost.OrgID;
  5821. // // lw.Add(string.Format("OrgID={0}", org_id));
  5822. // //}
  5823. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5824. // }
  5825. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5826. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5827. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5828. //}
  5829. if (st == 5)
  5830. {
  5831. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5832. {
  5833. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5834. {
  5835. string shopid = CurrentUser.User.pemShop;
  5836. lw.Add(string.Format("shopId in ({0})", shopid));
  5837. }
  5838. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5839. {
  5840. int mrOrgid = CurrentUser.UserPost.OrgID;
  5841. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5842. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5843. }
  5844. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5845. //{
  5846. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5847. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5848. //}
  5849. else
  5850. {
  5851. string userIdStr = "";
  5852. if (posCode == "CustomerService")
  5853. {
  5854. userIdStr = CurrentUser.UserID + "_k";
  5855. }
  5856. else if (posCode == "Designer" || posCode == "wxDesigner")
  5857. {
  5858. userIdStr = CurrentUser.UserID + "_s";
  5859. }
  5860. else if (posCode == "Place")
  5861. {
  5862. userIdStr = CurrentUser.UserID + "_x";
  5863. }
  5864. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5865. }
  5866. }
  5867. string placedate1 = GetPostString("placedate1");
  5868. string placedate2 = GetPostString("placedate2");
  5869. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5870. if (dwplace.Length > 0) lw.Add(dwplace);
  5871. string supState = GetPostString("supState");
  5872. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5873. string searchType = GetPostString("searchType");
  5874. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5875. {
  5876. lw.Add(string.Format("BackNum>1"));
  5877. }
  5878. lw.Add(string.Format("AfterSaleState>0"));
  5879. if (ex_psize > 0)
  5880. {
  5881. if (CurrentUser.UserPost.Post.Code == "Finance")
  5882. dStruct.Order = "pay_time desc";
  5883. else
  5884. dStruct.Order = "HandleTime desc";
  5885. }
  5886. else
  5887. dStruct.Order = "HandleTime desc";
  5888. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5889. DataTable dt = WebCache.GetData("view_test", dStruct);
  5890. writeGridDataTableJson(dStruct.TotalCount, dt);
  5891. }
  5892. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5893. //{
  5894. // lw.Add(string.Format("AfterSaleState=4"));
  5895. // string code = CurrentUser.UserPost.Post.Code;
  5896. // if (code == "CustomerService")
  5897. // {
  5898. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5899. // }
  5900. // else if (code == "Designer" || code == "DesignerMr")
  5901. // {
  5902. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5903. // }
  5904. // else if (code == "Place" || code == "PlaceMr")
  5905. // {
  5906. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5907. // }
  5908. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5909. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5910. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5911. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5912. //}
  5913. //else //处理中的售后,待处理和处理中合并
  5914. //{
  5915. // if (afterState.Length <= 0)
  5916. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5917. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5918. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5919. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5920. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5921. //}
  5922. }
  5923. public void get_erp_disagreeftersalelist()
  5924. {
  5925. DataStruct dStruct = GetPostStruct();
  5926. List<string> lw = new List<string>();
  5927. int st = 2;
  5928. string tid = GetPostString("ctid");
  5929. if (tid.Length > 0)
  5930. {
  5931. string select_tid = getTidByCtid(tid);
  5932. lw.Add(string.Format("tid='{0}'", select_tid));
  5933. }
  5934. string shopname = GetPostString("shopname");
  5935. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5936. string buyernick = GetPostString("buyer_nick");
  5937. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5938. string sellermemo = GetPostString("seller_memo");
  5939. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5940. string orderState = GetPostString("orderState");
  5941. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5942. string afterState = GetPostString("afterstate");
  5943. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5944. string date1 = GetPostString("date1");
  5945. string date2 = GetPostString("date2");
  5946. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5947. if (dw.Length > 0) lw.Add(dw);
  5948. string price1 = GetPostString("price1");
  5949. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5950. string price2 = GetPostString("price2");
  5951. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5952. //lw.Add(string.Format("IsRefund!={0}", 1));
  5953. string reason = GetPostString("reason");
  5954. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5955. string method = GetPostString("method");
  5956. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5957. string handler = GetPostString("handler");
  5958. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5959. string handledate1 = GetPostString("handledate1");
  5960. string handledate2 = GetPostString("handledate2");
  5961. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5962. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5963. string afterdate1 = GetPostString("afterdate1");
  5964. string afterdate2 = GetPostString("afterdate2");
  5965. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5966. if (afterDate.Length > 0) lw.Add(afterDate);
  5967. string backdate1 = GetPostString("backdate1");
  5968. string backdate2 = GetPostString("backdate2");
  5969. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5970. if (backDate.Length > 0) lw.Add(backDate);
  5971. string supplier = GetPostString("supplier");
  5972. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5973. string responsible = GetPostString("responsibleman");
  5974. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5975. string customer = GetPostString("customer");
  5976. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5977. string design = GetPostString("design");
  5978. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5979. string afterSaleMemo = GetPostString("afterSaleMemo");
  5980. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5981. string afterMemoType = GetPostString("aftermemotype");
  5982. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5983. string aftersakereason = GetPostString("aftersakereason");
  5984. if (aftersakereason.Length > 0)
  5985. {
  5986. if (aftersakereason == "1")
  5987. {
  5988. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5989. }
  5990. if (aftersakereason == "2")
  5991. {
  5992. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5993. }
  5994. }
  5995. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5996. string poscode = CurrentUser.UserPost.Post.Code;
  5997. if (poscode != "SysAdmin")
  5998. {
  5999. string shopid = CurrentUser.User.pemShop;
  6000. lw.Add(string.Format("shopId in ({0})", shopid));
  6001. }
  6002. string searchType = GetPostString("searchType");
  6003. if (searchType == "wait")
  6004. {
  6005. lw.Add(string.Format("HandleTime is null"));
  6006. }
  6007. if (searchType == "handling")
  6008. {
  6009. lw.Add(string.Format("HandleTime is not null "));
  6010. }
  6011. if (searchType == "back" || searchType == "puBack")
  6012. {
  6013. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6014. }
  6015. if (searchType == "reBack")
  6016. {
  6017. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6018. }
  6019. if (searchType == "moreBack")
  6020. {
  6021. lw.Add(string.Format("backNum > 1"));
  6022. }
  6023. lw.Add(string.Format("(AfterSaleState=5)"));
  6024. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6025. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6026. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6027. writeGridDataTableJson(dStruct.TotalCount, dt);
  6028. }
  6029. public void get_erp_handlingaftersalelist()
  6030. {
  6031. DataStruct dStruct = GetPostStruct();
  6032. List<string> lw = new List<string>();
  6033. int st = 2;
  6034. string tid = GetPostString("ctid");
  6035. if (tid.Length > 0)
  6036. {
  6037. string select_tid = getTidByCtid(tid);
  6038. lw.Add(string.Format("tid='{0}'", select_tid));
  6039. }
  6040. string shopname = GetPostString("shopname");
  6041. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6042. string buyernick = GetPostString("buyer_nick");
  6043. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6044. string sellermemo = GetPostString("seller_memo");
  6045. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6046. string orderState = GetPostString("orderState");
  6047. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6048. string afterState = GetPostString("afterstate");
  6049. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6050. string date1 = GetPostString("date1");
  6051. string date2 = GetPostString("date2");
  6052. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6053. if (dw.Length > 0) lw.Add(dw);
  6054. string price1 = GetPostString("price1");
  6055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6056. string price2 = GetPostString("price2");
  6057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6058. //lw.Add(string.Format("IsRefund!={0}", 1));
  6059. string reason = GetPostString("reason");
  6060. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6061. string method = GetPostString("method");
  6062. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6063. string handler = GetPostString("handler");
  6064. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6065. string handledate1 = GetPostString("handledate1");
  6066. string handledate2 = GetPostString("handledate2");
  6067. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6068. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6069. string afterdate1 = GetPostString("afterdate1");
  6070. string afterdate2 = GetPostString("afterdate2");
  6071. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6072. if (afterDate.Length > 0) lw.Add(afterDate);
  6073. string supplier = GetPostString("supplier");
  6074. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6075. string responsible = GetPostString("responsibleman");
  6076. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6077. string customer = GetPostString("customer");
  6078. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6079. string design = GetPostString("design");
  6080. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6081. string afterSaleMemo = GetPostString("afterSaleMemo");
  6082. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6083. string afterMemoType = GetPostString("aftermemotype");
  6084. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6085. string afterresult = GetPostString("afterresult");
  6086. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6087. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6088. string poscode = CurrentUser.UserPost.Post.Code;
  6089. if (poscode != "SysAdmin")
  6090. {
  6091. string shopid = CurrentUser.User.pemShop;
  6092. lw.Add(string.Format("shopId in ({0})", shopid));
  6093. }
  6094. string searchType = GetPostString("searchType");
  6095. if (searchType == "wait")
  6096. {
  6097. lw.Add(string.Format("HandleTime is null"));
  6098. }
  6099. if (searchType == "documentary")
  6100. {
  6101. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6102. }
  6103. if (searchType == "handling")
  6104. {
  6105. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6106. }
  6107. if (searchType == "back" || searchType == "puBack")
  6108. {
  6109. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6110. }
  6111. if (searchType == "reBack")
  6112. {
  6113. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6114. }
  6115. if (afterState.Length <= 0)
  6116. {
  6117. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6118. }
  6119. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6120. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6121. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6122. writeGridDataTableJson(dStruct.TotalCount, dt);
  6123. }
  6124. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6125. //public void get_erp_back_handlingaftersalelist()
  6126. //{
  6127. // DataStruct dStruct = GetPostStruct();
  6128. // List<string> lw = new List<string>();
  6129. // string tid = GetPostString("ctid");
  6130. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6131. // string shopname = GetPostString("shopname");
  6132. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6133. // string buyernick = GetPostString("buyer_nick");
  6134. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6135. // string sellermemo = GetPostString("seller_memo");
  6136. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6137. // string orderState = GetPostString("orderState");
  6138. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6139. // string afterState = GetPostString("afterstate");
  6140. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6141. // string date1 = GetPostString("date1");
  6142. // string date2 = GetPostString("date2");
  6143. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6144. // if (dw.Length > 0) lw.Add(dw);
  6145. // string price1 = GetPostString("price1");
  6146. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6147. // string price2 = GetPostString("price2");
  6148. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6149. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6150. // string reason = GetPostString("reason");
  6151. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6152. // string method = GetPostString("method");
  6153. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6154. // string handler = GetPostString("handler");
  6155. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6156. // string handledate1 = GetPostString("handledate1");
  6157. // string handledate2 = GetPostString("handledate2");
  6158. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6159. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6160. // string afterdate1 = GetPostString("afterdate1");
  6161. // string afterdate2 = GetPostString("afterdate2");
  6162. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6163. // if (afterDate.Length > 0) lw.Add(afterDate);
  6164. // string supplier = GetPostString("supplier");
  6165. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6166. // string responsible = GetPostString("responsibleman");
  6167. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6168. // string customer = GetPostString("customer");
  6169. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6170. // string design = GetPostString("design");
  6171. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6172. // string afterMemoType = GetPostString("aftermemotype");
  6173. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6174. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6175. // if (afterState.Length <= 0)
  6176. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6177. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6178. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6179. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6180. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6181. //}
  6182. public void get_erp_aftersaleverifylist()
  6183. {
  6184. DataStruct dStruct = GetPostStruct();
  6185. List<string> lw = new List<string>();
  6186. string tid = GetPostString("ctid");
  6187. if (tid.Length > 0)
  6188. {
  6189. string select_tid = getTidByCtid(tid);
  6190. lw.Add(string.Format("tid='{0}'", select_tid));
  6191. }
  6192. string shopname = GetPostString("shopname");
  6193. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6194. string buyernick = GetPostString("buyer_nick");
  6195. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6196. string sellermemo = GetPostString("seller_memo");
  6197. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6198. string orderState = GetPostString("orderState");
  6199. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6200. //lw.Add(string.Format("IsRefund!={0}", 1));
  6201. string reason = GetPostString("reason");
  6202. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6203. string method = GetPostString("method");
  6204. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6205. string handler = GetPostString("handler");
  6206. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6207. string handledate1 = GetPostString("handledate1");
  6208. string handledate2 = GetPostString("handledate2");
  6209. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6210. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6211. string finish1 = GetPostString("finishdate1");
  6212. string finish2 = GetPostString("finishdate2");
  6213. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6214. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6215. string supplier = GetPostString("supplier");
  6216. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6217. string responsible = GetPostString("responsibleman");
  6218. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6219. string posCode = CurrentUser.UserPost.Post.Code;
  6220. string vstate = GetPostString("vstate");
  6221. if (vstate.Length > 0)
  6222. {
  6223. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6224. }
  6225. if (posCode == "Supplier")
  6226. {
  6227. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6228. lw.Add(string.Format("VerifyState = 0"));
  6229. lw.Add("type = 1");
  6230. lw.Add(string.Format("AfterSaleState={0}", 3));
  6231. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6232. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6234. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6235. writeGridDataTableJson(dStruct.TotalCount, dt);
  6236. }
  6237. else if (posCode == "logistics")
  6238. {
  6239. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6240. lw.Add(string.Format("VerifyState = 0"));
  6241. lw.Add("type = 2");
  6242. lw.Add(string.Format("AfterSaleState={0}", 3));
  6243. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6244. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6245. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6246. writeGridDataTableJson(dStruct.TotalCount, dt);
  6247. }
  6248. else
  6249. {
  6250. lw.Add(string.Format("(AfterSaleState = 3)"));
  6251. string reasonState = GetPostString("reasonState");
  6252. lw.Add("type = 0");
  6253. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6254. || posCode == "Summarize" || posCode == "Finance")
  6255. {
  6256. if (reasonState == "2")
  6257. {
  6258. lw.Add("VerifyState = 3");
  6259. }
  6260. else if (reasonState == "1")
  6261. {
  6262. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6263. }
  6264. else
  6265. {
  6266. lw.Add("VerifyState in (0,3)");
  6267. }
  6268. //不加条件,可以看全部
  6269. }
  6270. 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")
  6271. {
  6272. int orgid = CurrentUser.UserPost.OrgID;
  6273. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6274. if (string.IsNullOrEmpty(manageOrgId))
  6275. {
  6276. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6277. }
  6278. else
  6279. {
  6280. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6281. }
  6282. if (reasonState == "1")
  6283. {
  6284. lw.Add("VerifyState = 3");
  6285. }
  6286. else if (reasonState == "2")
  6287. {
  6288. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6289. }
  6290. else
  6291. {
  6292. }
  6293. }
  6294. else
  6295. {
  6296. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6297. }
  6298. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6299. //{
  6300. // int org_id = CurrentUser.UserPost.OrgID;
  6301. // lw.Add(string.Format("OrgID={0}", org_id));
  6302. //}
  6303. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6304. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6305. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6306. writeGridDataTableJson(dStruct.TotalCount, dt);
  6307. }
  6308. }
  6309. public void get_erp_finishaftersalelist()
  6310. {
  6311. DataStruct dStruct = GetPostStruct();
  6312. List<string> lw = new List<string>();
  6313. int st = 4;
  6314. string tid = GetPostString("ctid");
  6315. if (tid.Length > 0)
  6316. {
  6317. string select_tid = getTidByCtid(tid);
  6318. lw.Add(string.Format("tid='{0}'", select_tid));
  6319. }
  6320. string shopname = GetPostString("shopname");
  6321. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6322. //lw.Add(string.Format("IsRefund!={0}", 1));
  6323. string reason = GetPostString("reason");
  6324. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6325. string method = GetPostString("method");
  6326. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6327. string buyernick = GetPostString("buyer_nick");
  6328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6329. string handler = GetPostString("handler");
  6330. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6331. string handledate1 = GetPostString("handledate1");
  6332. string handledate2 = GetPostString("handledate2");
  6333. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6334. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6335. string finish1 = GetPostString("finishdate1");
  6336. string finish2 = GetPostString("finishdate2");
  6337. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6338. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6339. string supplier = GetPostString("supplier");
  6340. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6341. string responsible = GetPostString("responsibleman");
  6342. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6343. string vstate = GetPostString("vstate");
  6344. if (vstate.Length > 0)
  6345. {
  6346. if ("3".Equals(vstate))
  6347. {
  6348. lw.Add(string.Format("IsTem=1"));
  6349. }
  6350. else
  6351. {
  6352. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6353. }
  6354. }
  6355. lw.Add(string.Format("AfterSaleState=4"));
  6356. string code = CurrentUser.UserPost.Post.Code;
  6357. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6358. {
  6359. //不加条件,可以看全部
  6360. }
  6361. else if (code == "Supplier")
  6362. {
  6363. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6364. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6365. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6366. }
  6367. else if (code == "logistics")
  6368. {
  6369. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6370. lw.Add("type = 2");
  6371. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6372. }
  6373. 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")
  6374. {
  6375. int orgid = CurrentUser.UserPost.OrgID;
  6376. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6377. if (string.IsNullOrEmpty(manageOrgIds))
  6378. {
  6379. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6380. }
  6381. else
  6382. {
  6383. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6384. }
  6385. }
  6386. else
  6387. {
  6388. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6389. }
  6390. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6391. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6392. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6393. writeGridDataTableJson(dStruct.TotalCount, dt);
  6394. }
  6395. public void handle_erp_aftersale()
  6396. {
  6397. if (UrlPostParmsCheck("ctid"))
  6398. {
  6399. string eid = GetPostString("ctid");
  6400. string responStr = GetPostString("AfterSaleResponsible");
  6401. if (responStr.Length <= 0)
  6402. {
  6403. returnErrorMsg("售后责任人不能为空");
  6404. return;
  6405. }
  6406. bool isDesign = false;
  6407. double designFree = 0.00;
  6408. int responsibleId = 0;
  6409. CeErpTradeCell entity = null;
  6410. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6411. if (entity != null)
  6412. {
  6413. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6414. string afterMethod = GetPostString("AfterSaleMethod");
  6415. if (isNeedNewOrder == 1)
  6416. {
  6417. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6418. bool ishav = true;
  6419. if (newentity == null)
  6420. {
  6421. newentity = entity.Clone() as CeErpTradeCell;
  6422. ishav = false;
  6423. newentity.ctid = "S_" + entity.ctid;
  6424. newentity.OrderState = 0;
  6425. //唯一标识
  6426. newentity.OrderSn = newentity.ctid;
  6427. string orderSn = dataHelper.getSaleOrderSn();
  6428. if (orderSn != "")
  6429. {
  6430. newentity.OrderSn = orderSn;
  6431. }
  6432. }
  6433. newentity.UpdateTime = DateTime.Now;
  6434. newentity.AfterSaleState = 0;
  6435. newentity.AfterSaleMethod = afterMethod;
  6436. if (!ishav)
  6437. {
  6438. string memo_str = newentity.seller_memo;
  6439. memo_str = memo_str.Replace("(", "(");
  6440. memo_str = memo_str.Replace(")", ")");
  6441. int sIndex = memo_str.IndexOf("(");
  6442. int eIndex = memo_str.IndexOf(")");
  6443. if (sIndex == -1 || eIndex == -1)
  6444. {
  6445. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6446. return;
  6447. }
  6448. string first = memo_str.Substring(0, sIndex + 1);
  6449. string memoCtid = newentity.OrderSn;
  6450. //if (memoCtid.IndexOf("C") != -1)
  6451. //{
  6452. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6453. //if (CIdx.IndexOf("+") != -1)
  6454. //{
  6455. //CIdx = "C" + CIdx.Split('+')[1];
  6456. //}
  6457. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6458. //}
  6459. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6460. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6461. string newMemo = first + memoCtid + last;
  6462. newentity.seller_memo = newMemo;
  6463. newentity.FinishPlaceTime = null;
  6464. newentity.UnusualTag = 0;
  6465. newentity.UnusualCon = "";
  6466. newentity.UnusualTime = null;
  6467. newentity.AfterSaleMemo = "";
  6468. newentity.AfterSaleMethod = afterMethod;
  6469. newentity.AfterSalePreTime = null;
  6470. newentity.AfterSaleReason = "";
  6471. newentity.AfterSaleResponsible = "";
  6472. newentity.AfterSaleState = 0;
  6473. newentity.AfterSaleTime = null;
  6474. newentity.AfterSaleUserId = 0;
  6475. newentity.AfterSaleSupplierState = 0;
  6476. newentity.LastBillWaybillCode = "";
  6477. newentity.LastBillCpCode = "";
  6478. newentity.FinishAfterSaleTime = null;
  6479. newentity.HandleTime = null;
  6480. newentity.IsSF = 0;
  6481. newentity.IsOldCustomer = 0;
  6482. newentity.UrgencyTime = null;
  6483. newentity.ResponsibleUserId = "";
  6484. newentity.IsVerifyToSupplier = false;
  6485. newentity.payment = 0;
  6486. newentity.CheckMemo = "";
  6487. newentity.OutSid = "";
  6488. newentity.CheckOrderTime = null;
  6489. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6490. }
  6491. newentity.isAfterSaleOrder = 1;
  6492. newentity.IsRefund = 0;
  6493. string receiveMobile = GetPostString("receiver_mobile");
  6494. if (receiveMobile.Length > 0)
  6495. {
  6496. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6497. if (trade != null)
  6498. {
  6499. trade.receiver_name = GetPostString("receiver_name");
  6500. trade.receiver_mobile = receiveMobile;
  6501. trade.receiver_state = GetPostString("receiver_state");
  6502. trade.receiver_city = GetPostString("receiver_city");
  6503. trade.receiver_district = GetPostString("receiver_district");
  6504. trade.receiver_address = GetPostString("receiver_address");
  6505. newentity.IsOffLineOrder = 1;
  6506. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6507. }
  6508. }
  6509. string st = GetPostString("ToState");
  6510. if (st.Length > 0)
  6511. {
  6512. if (newentity.OrderState <= 3)
  6513. {
  6514. newentity.WaitDesignTime = DateTime.Now;
  6515. newentity.StartDesignTime = null;
  6516. newentity.FinishDesignTime = null;
  6517. newentity.OrderState = 3;
  6518. if (st == "下单员")
  6519. {
  6520. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6521. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6522. {
  6523. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6524. }
  6525. }
  6526. else
  6527. {
  6528. newentity.WaitDesignTime = DateTime.Now;
  6529. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6530. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6531. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6532. {
  6533. DataRow user = dt1.Rows[0];
  6534. //找主管
  6535. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6536. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6537. if (dt != null && dt.Rows.Count > 0)
  6538. {
  6539. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6540. newentity.DesignUserId = designMr;
  6541. string key = "aftersale_order_" + designMr;
  6542. if (RedisHelper.HasKey(key))
  6543. {
  6544. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6545. list.Add(newentity.ctid);
  6546. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6547. }
  6548. }
  6549. //账号正常
  6550. if (user["State"].ToString() == "0")
  6551. {
  6552. newentity.DesignUserId = entity.DesignUserId;
  6553. string key = "aftersale_order_" + entity.DesignUserId;
  6554. if (RedisHelper.HasKey(key))
  6555. {
  6556. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6557. list.Add(newentity.ctid);
  6558. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6559. }
  6560. }
  6561. }
  6562. }
  6563. }
  6564. if (entity.IsXianHuo == 1)
  6565. {
  6566. newentity.OrderState = 6;
  6567. entity.FinishPlaceTime = DateTime.Now;
  6568. }
  6569. }
  6570. if (ishav)
  6571. {
  6572. newentity.Update();
  6573. }
  6574. else
  6575. {
  6576. newentity.Create();
  6577. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6578. newCellExtend.ctid = newentity.ctid;
  6579. newCellExtend.orderFrom = 20;
  6580. newCellExtend.orderType = 30;
  6581. if (st == "下单员")
  6582. {
  6583. }
  6584. else
  6585. {
  6586. newCellExtend.ReprintTime = DateTime.Now;
  6587. }
  6588. newCellExtend.Create();
  6589. }
  6590. if (st != "下单员")
  6591. {
  6592. designHelper.API_GetPrintData_CreateOrder(newentity);
  6593. }
  6594. }
  6595. //处理售后扩展
  6596. string resIdStr = GetPostString("ResponsibleUserId");
  6597. string refundFees = GetPostString("refundFrees");
  6598. int IsComplain = GetPostInt("isComplain");
  6599. int IsBad = GetPostInt("isBad");
  6600. string IsOriginal = GetPostString("isOriginal");
  6601. double diffResultPrice = GetPostDouble("diffResultPrice");
  6602. string textResult = GetPostString("textResult");
  6603. string supplierResponsible = GetPostString("supplierResponsible");
  6604. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6605. if (ceErpTradeAfterSaleExtend == null)
  6606. {
  6607. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6608. ceErpTradeAfterSaleExtend.tid = eid;
  6609. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6610. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6611. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6612. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6613. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6614. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6615. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6616. ceErpTradeAfterSaleExtend.Create();
  6617. }
  6618. else
  6619. {
  6620. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6621. {
  6622. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6623. }
  6624. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6625. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6626. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6627. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6628. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6629. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6630. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6631. ceErpTradeAfterSaleExtend.Update();
  6632. }
  6633. int gysid = GetPostInt("ResponsibleSupId");
  6634. if (entity.AfterSaleUserId == 0)
  6635. {
  6636. entity.AfterSaleUserId = CurrentUser.UserID;
  6637. }
  6638. entity.ResponsibleUserId = resIdStr;
  6639. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6640. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6641. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6642. {
  6643. CeErpTradeResponsible.DelByTid(eid, -1);
  6644. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6645. int backNum = 0;
  6646. if (number != null)
  6647. {
  6648. backNum = number.BackNum;
  6649. }
  6650. char[] separator = { ',' };
  6651. string[] sArray = resIdStr.Split(separator);
  6652. string[] refundFreeList = { };
  6653. if (refundFees.Length > 0)
  6654. {
  6655. refundFreeList = refundFees.Split(separator);
  6656. }
  6657. int index = -1;
  6658. foreach (string i in sArray)
  6659. {
  6660. index++;
  6661. if (i.Length <= 0) continue;
  6662. char[] separator2 = { '_' };
  6663. string idstr = i.Split(separator2)[0];
  6664. string idtype = i.Split(separator2)[1];
  6665. double refudFree = 0;
  6666. if (refundFreeList.Length > 0)
  6667. {
  6668. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6669. }
  6670. if (idtype == "s")
  6671. {
  6672. isDesign = true;
  6673. designFree = refudFree;
  6674. }
  6675. int userId = Convert.ToInt32(idstr);
  6676. int type = 0;
  6677. if (idtype == "g")
  6678. {
  6679. type = 1;
  6680. }
  6681. if (idtype == "w")
  6682. {
  6683. type = 2;
  6684. }
  6685. if (idtype == "t")
  6686. {
  6687. type = 3;
  6688. }
  6689. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6690. if (ceErpTradeResponsible == null)
  6691. {
  6692. ceErpTradeResponsible = new CeErpTradeResponsible();
  6693. ceErpTradeResponsible.tid = eid;
  6694. ceErpTradeResponsible.UserId = userId;
  6695. ceErpTradeResponsible.createdTime = DateTime.Now;
  6696. ceErpTradeResponsible.type = type;
  6697. if (type == 1)
  6698. {
  6699. ceErpTradeResponsible.IsSup = 1;
  6700. }
  6701. if (type == 2)
  6702. {
  6703. ceErpTradeResponsible.IsFlow = 1;
  6704. }
  6705. }
  6706. ceErpTradeResponsible.RefundFee = refudFree;
  6707. ceErpTradeResponsible.VerifyState = 0;
  6708. if (userId == 2125 || idtype == "w")
  6709. {
  6710. ceErpTradeResponsible.VerifyState = 1;
  6711. }
  6712. if (idtype == "w" && userId == 101)
  6713. {
  6714. ceErpTradeResponsible.VerifyState = 0;
  6715. }
  6716. if (ceErpTradeResponsible.ID > 0)
  6717. {
  6718. ceErpTradeResponsible.Update();
  6719. }
  6720. else
  6721. {
  6722. ceErpTradeResponsible.Create();
  6723. }
  6724. if (isDesign)
  6725. {
  6726. responsibleId = ceErpTradeResponsible.ID;
  6727. }
  6728. }
  6729. CeErpTradeResponsible.NumByTid(backNum, eid);
  6730. }
  6731. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6732. if (ceErpTradeCellExtend != null)
  6733. {
  6734. ceErpTradeCellExtend.returnVisit = 0;
  6735. ceErpTradeCellExtend.Update();
  6736. }
  6737. if (entity.HandleTime != null)
  6738. {
  6739. if (entity.AfterSaleState == 1)
  6740. {
  6741. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6742. }
  6743. else
  6744. {
  6745. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6746. }
  6747. }
  6748. else
  6749. {
  6750. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6751. entity.HandleTime = DateTime.Now;
  6752. }
  6753. bool isCompale = false;
  6754. if (entity.AfterSaleState == 5)
  6755. {
  6756. isCompale = true;
  6757. entity.AfterSaleState = 3;
  6758. }
  6759. entity.AfterSaleSupplierState = 0;
  6760. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6761. {
  6762. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6763. }
  6764. string sImgs = GetPostString("img");
  6765. entity.AfterSaleSupplierImg = sImgs;
  6766. entity.supRefundType = GetPostString("supRefundType");
  6767. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6768. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6769. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6770. entity.AfterSaleMemoType = GetPostString("MemoType");
  6771. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6772. {
  6773. //entity.AfterSaleSupplierState = 2;
  6774. }
  6775. string df = GetPostString("DeductFee");
  6776. if (df == "")
  6777. {
  6778. df = "0";
  6779. }
  6780. string rf = GetPostString("RefundFee");
  6781. if (rf == "")
  6782. {
  6783. rf = "0";
  6784. }
  6785. string pm = GetPostString("AfterSalePayment");
  6786. if (pm == "")
  6787. {
  6788. pm = "0";
  6789. }
  6790. entity.AfterSalePayment = Convert.ToDouble(pm);
  6791. entity.DeductFee = Convert.ToDouble(df);
  6792. entity.RefundFee = Convert.ToDouble(rf);
  6793. entity.UpdateTime = DateTime.Now;
  6794. entity.Update();
  6795. string toState = GetPostString("ToState");
  6796. string original = GetPostString("isOriginal");
  6797. ApiVo apiVo = new ApiVo();
  6798. apiVo.orderNumber = entity.ctid;
  6799. apiVo.actionName = "afterDesign";
  6800. apiVo.orderRemarks = entity.AfterSaleMethod;
  6801. apiVo.reasonRemarks = entity.AfterSaleReason;
  6802. apiVo.isDesign = isDesign;
  6803. apiVo.designFree = designFree;
  6804. apiVo.responsibleId = responsibleId;
  6805. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6806. if (toState == "设计师")
  6807. {
  6808. apiVo.isOriginal = Convert.ToBoolean(original);
  6809. }
  6810. designHelper.API_WorkCore(apiVo);//afterDesign
  6811. CeErpMethod methodSql = new CeErpMethod();
  6812. methodSql.con = entity.AfterSaleMethod;
  6813. methodSql.addTime = DateTime.Now;
  6814. methodSql.Create();
  6815. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6816. CeErpMethod.ExecuteNonQuery(delsql);
  6817. if (isCompale)
  6818. {
  6819. aftersale_data_change(entity.ctid);
  6820. }
  6821. returnSuccessMsg("操作成功!");
  6822. return;
  6823. }
  6824. returnErrorMsg("找不到订单记录");
  6825. }
  6826. }
  6827. public void ins_erp_toresponsible()
  6828. {
  6829. if (UrlPostParmsCheck("ctid"))
  6830. {
  6831. string eid = GetPostString("ctid");
  6832. CeErpTradeCell entity = null;
  6833. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6834. if (entity != null)
  6835. {
  6836. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6837. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6838. {
  6839. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6840. return;
  6841. }
  6842. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6843. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6844. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6845. if (entity.AfterSalePreTime == null)
  6846. {
  6847. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6848. {
  6849. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6850. }
  6851. }
  6852. entity.AfterSalePreTime = DateTime.Now;
  6853. //预完成给售后主管审核客户问题直接完成
  6854. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6855. {
  6856. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6857. {
  6858. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6859. }
  6860. }
  6861. ceErpTradeAfterSaleExtend.Update();
  6862. entity.AfterSaleState = 2;
  6863. entity.UpdateTime = DateTime.Now;
  6864. entity.Update();
  6865. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6866. aftersale_data_change(entity.ctid);
  6867. returnSuccessMsg("操作成功!");
  6868. return;
  6869. }
  6870. returnErrorMsg("找不到订单记录");
  6871. }
  6872. }
  6873. public void cancel_erp_aftersaleanddelnew()
  6874. {
  6875. if (UrlPostParmsCheck("ctid"))
  6876. {
  6877. string eid = GetPostString("ctid");
  6878. CeErpTradeCell entity = null;
  6879. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6880. if (entity != null)
  6881. {
  6882. entity.AfterSaleState = 0;
  6883. entity.AfterSaleReason = "";
  6884. entity.AfterSaleMethod = "";
  6885. entity.AfterSaleMemo = "";
  6886. entity.AfterSaleResponsible = "";
  6887. entity.ResponsibleUserId = "";
  6888. entity.DeductFee = 0;
  6889. entity.RefundFee = 0;
  6890. entity.IsArbitrate = 0;
  6891. CeErpTradeResponsible.DelByTid(eid, -1);
  6892. entity.Update();
  6893. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6894. if (after != null)
  6895. {
  6896. if (after.OrderState < 5)
  6897. CeErpTradeCell.DelByCtid("S_" + eid);
  6898. }
  6899. returnSuccessMsg("操作成功!");
  6900. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6901. return;
  6902. }
  6903. returnErrorMsg("找不到订单记录");
  6904. }
  6905. }
  6906. public void get_erp_aftersale_pregather()
  6907. {
  6908. List<string> lw = new List<string>();
  6909. int st = GetInt("st");
  6910. string tid = GetPostString("ctid");
  6911. if (tid.Length > 0)
  6912. {
  6913. string select_tid = getTidByCtid(tid);
  6914. lw.Add(string.Format("tid='{0}'", select_tid));
  6915. }
  6916. string shopname = GetPostString("shopname");
  6917. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6918. string buyernick = GetPostString("buyer_nick");
  6919. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6920. string sellermemo = GetPostString("seller_memo");
  6921. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6922. string orderState = GetPostString("orderState");
  6923. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6924. string reason = GetPostString("reason");
  6925. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6926. string method = GetPostString("method");
  6927. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6928. string handler = GetPostString("handler");
  6929. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6930. string handledate1 = GetPostString("handledate1");
  6931. string handledate2 = GetPostString("handledate2");
  6932. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6933. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6934. string supplier = GetPostString("supplier");
  6935. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6936. string responsible = GetPostString("responsibleman");
  6937. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6938. string customer = GetPostString("customer");
  6939. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6940. string design = GetPostString("design");
  6941. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6942. string afterMemoType = GetPostString("aftermemotype");
  6943. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6944. string afterSaleMemo = GetPostString("afterSaleMemo");
  6945. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6946. string afterresult = GetPostString("afterresult");
  6947. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6948. string poscode = CurrentUser.UserPost.Post.Code;
  6949. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6950. {
  6951. string shopid = CurrentUser.User.pemShop;
  6952. lw.Add(string.Format("shopId in ({0})", shopid));
  6953. }
  6954. var mainwhere = string.Join(" and ", lw.ToArray());
  6955. string ro_json = "";
  6956. string type = GetPostString("gather_type");
  6957. int number = 0;
  6958. if (poscode == "AfterSale")
  6959. {
  6960. //处理中
  6961. if (type == "Handling")
  6962. {
  6963. 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) : ""));
  6964. DataTable dt = null;
  6965. try
  6966. {
  6967. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6968. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6969. }
  6970. catch (Exception e)
  6971. {
  6972. dt = new DataTable();
  6973. }
  6974. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6975. return;
  6976. }
  6977. if (type == "Wait")
  6978. {
  6979. //待处理
  6980. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6981. DataTable dt1 = null;
  6982. try
  6983. {
  6984. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6985. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6986. }
  6987. catch (Exception e)
  6988. {
  6989. dt1 = new DataTable();
  6990. }
  6991. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6992. return;
  6993. }
  6994. if (type == "back")
  6995. {
  6996. //打回
  6997. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6998. DataTable dt2 = null;
  6999. try
  7000. {
  7001. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7002. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7003. }
  7004. catch (Exception e)
  7005. {
  7006. dt2 = new DataTable();
  7007. }
  7008. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7009. return;
  7010. }
  7011. if (type == "preCompletion")
  7012. {
  7013. //预完成
  7014. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7015. DataTable dt3 = null;
  7016. try
  7017. {
  7018. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7019. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7020. }
  7021. catch (Exception e)
  7022. {
  7023. dt3 = new DataTable();
  7024. }
  7025. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7026. return;
  7027. }
  7028. if (type == "documentary")
  7029. {
  7030. //跟单中
  7031. 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) : ""));
  7032. DataTable dt4 = null;
  7033. try
  7034. {
  7035. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7036. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7037. }
  7038. catch (Exception e)
  7039. {
  7040. dt4 = new DataTable();
  7041. }
  7042. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7043. return;
  7044. }
  7045. if (type == "reBack")
  7046. {
  7047. //被打回
  7048. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7049. DataTable dt1 = null;
  7050. try
  7051. {
  7052. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7053. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7054. }
  7055. catch (Exception e)
  7056. {
  7057. dt1 = new DataTable();
  7058. }
  7059. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7060. return;
  7061. }
  7062. }
  7063. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7064. {
  7065. if (type == "puBack")
  7066. {
  7067. //退回
  7068. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7069. DataTable dt = null;
  7070. try
  7071. {
  7072. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7073. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7074. }
  7075. catch (Exception e)
  7076. {
  7077. dt = new DataTable();
  7078. }
  7079. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7080. return;
  7081. }
  7082. if (type == "reBack")
  7083. {
  7084. //打回
  7085. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7086. DataTable dt1 = null;
  7087. try
  7088. {
  7089. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7090. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7091. }
  7092. catch (Exception e)
  7093. {
  7094. dt1 = new DataTable();
  7095. }
  7096. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7097. return;
  7098. }
  7099. if (type == "examEd")
  7100. {
  7101. //已审核
  7102. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7103. DataTable dt2 = null;
  7104. try
  7105. {
  7106. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7107. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7108. }
  7109. catch (Exception e)
  7110. {
  7111. dt2 = new DataTable();
  7112. }
  7113. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7114. return;
  7115. }
  7116. if (type == "waitExam")
  7117. {
  7118. //待审核
  7119. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7120. DataTable dt3 = null;
  7121. try
  7122. {
  7123. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7124. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7125. }
  7126. catch (Exception e)
  7127. {
  7128. dt3 = new DataTable();
  7129. }
  7130. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7131. return;
  7132. }
  7133. if (type == "Handling")
  7134. {
  7135. //处理中
  7136. 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) : ""));
  7137. DataTable dt4 = null;
  7138. try
  7139. {
  7140. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7141. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7142. }
  7143. catch (Exception e)
  7144. {
  7145. dt4 = new DataTable();
  7146. }
  7147. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7148. return;
  7149. }
  7150. if (type == "Wait")
  7151. {
  7152. //待处理
  7153. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7154. DataTable dt5 = null;
  7155. try
  7156. {
  7157. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7158. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7159. }
  7160. catch (Exception e)
  7161. {
  7162. dt5 = new DataTable();
  7163. }
  7164. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7165. return;
  7166. }
  7167. if (type == "documentary")
  7168. {
  7169. //跟单中
  7170. 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) : ""));
  7171. DataTable dt6 = null;
  7172. try
  7173. {
  7174. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7175. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7176. }
  7177. catch (Exception e)
  7178. {
  7179. dt6 = new DataTable();
  7180. }
  7181. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7182. return;
  7183. }
  7184. }
  7185. returnSuccess(ro_json);
  7186. }
  7187. public void end_erp_aftersale()
  7188. {
  7189. if (UrlPostParmsCheck("ctid"))
  7190. {
  7191. string eid = GetPostString("ctid");
  7192. CeErpTradeCell entity = null;
  7193. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7194. if (entity != null)
  7195. {
  7196. string stype = GetPostString("stype");
  7197. string typeStr = stype;
  7198. entity.AfterSaleState = 4;
  7199. entity.FinishAfterSaleTime = DateTime.Now;
  7200. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7201. entity.Update();
  7202. ApiVo apiVo = new ApiVo();
  7203. apiVo.orderNumber = entity.ctid;
  7204. apiVo.actionName = "afterOver";
  7205. designHelper.API_WorkCore(apiVo); //afterOver
  7206. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7207. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7208. CeErpSukuraData.createInfo(entity.ctid, 8);
  7209. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7210. returnSuccessMsg("操作成功!");
  7211. return;
  7212. }
  7213. returnErrorMsg("找不到订单记录");
  7214. }
  7215. }
  7216. public void ins_erp_finishaftersale()
  7217. {
  7218. if (UrlPostParmsCheck("id"))
  7219. {
  7220. string eid = GetPostString("id");
  7221. CeErpTradeResponsible entity = null;
  7222. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7223. if (entity != null)
  7224. {
  7225. entity.VerifyState = 1;
  7226. entity.VerifyTime = DateTime.Now;
  7227. entity.Update();
  7228. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7229. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7230. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7231. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7232. if (dt.Rows.Count <= 0)
  7233. {
  7234. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7235. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7236. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7237. CeErpSukuraData.createInfo(entity.tid, 8);
  7238. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7239. {
  7240. CeErpDesignerBill.Del(entity.tid);
  7241. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7242. }
  7243. }
  7244. returnSuccessMsg("操作成功!");
  7245. return;
  7246. }
  7247. returnErrorMsg("找不到订单记录");
  7248. }
  7249. }
  7250. public void upd_erp_arbitrateaftersale()
  7251. {
  7252. if (UrlPostParmsCheck("id"))
  7253. {
  7254. string eid = GetPostString("id");
  7255. CeErpTradeResponsible entity = null;
  7256. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7257. if (entity != null)
  7258. {
  7259. entity.IsArbitrate = 1;
  7260. entity.ArbitradeMemo = GetPostString("reason");
  7261. entity.VerifyState = 2;
  7262. entity.Update();
  7263. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7264. if (tradecell != null)
  7265. {
  7266. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7267. tradecell.IsArbitrate = 1;
  7268. tradecell.Update();
  7269. }
  7270. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7271. returnSuccessMsg("操作成功!");
  7272. return;
  7273. }
  7274. returnErrorMsg("找不到订单记录");
  7275. }
  7276. }
  7277. public void upd_erp_backaftersale()
  7278. {
  7279. if (UrlPostParmsCheck("tid"))
  7280. {
  7281. string eid = GetPostString("tid");
  7282. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7283. int backNum = 0;
  7284. if (number != null)
  7285. {
  7286. backNum = number.BackNum;
  7287. }
  7288. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7289. CeErpTradeCell entity = null;
  7290. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7291. if (entity != null)
  7292. {
  7293. entity.AfterSaleBackReason = GetPostString("backreason");
  7294. entity.AfterSaleState = 1;
  7295. entity.AfterSaleSupplierState = 0;
  7296. entity.UpdateTime = DateTime.Now;
  7297. entity.Update();
  7298. returnSuccessMsg("操作成功!");
  7299. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7300. return;
  7301. }
  7302. returnErrorMsg("找不到订单记录");
  7303. }
  7304. }
  7305. public void get_erp_supplieraftersalelist()
  7306. {
  7307. DataStruct dStruct = GetPostStruct();
  7308. List<string> lw = new List<string>();
  7309. string tid = GetPostString("ctid");
  7310. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7311. string shopname = GetPostString("shopname");
  7312. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7313. string buyernick = GetPostString("buyer_nick");
  7314. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7315. string sellermemo = GetPostString("seller_memo");
  7316. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7317. string orderState = GetPostString("orderState");
  7318. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7319. string afterState = GetPostString("afterstate");
  7320. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7321. string date1 = GetPostString("date1");
  7322. string date2 = GetPostString("date2");
  7323. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7324. if (dw.Length > 0) lw.Add(dw);
  7325. string price1 = GetPostString("price1");
  7326. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7327. string price2 = GetPostString("price2");
  7328. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7329. string reason = GetPostString("reason");
  7330. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7331. string method = GetPostString("method");
  7332. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7333. string handledate1 = GetPostString("handledate1");
  7334. string handledate2 = GetPostString("handledate2");
  7335. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7336. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7337. string handler = GetPostString("handler");
  7338. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7339. string afterdate1 = GetPostString("afterdate1");
  7340. string afterdate2 = GetPostString("afterdate2");
  7341. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7342. if (afterDate.Length > 0) lw.Add(afterDate);
  7343. string customer = GetPostString("customer");
  7344. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7345. string design = GetPostString("design");
  7346. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7347. string afterMemoType = GetPostString("aftermemotype");
  7348. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7349. string vstate = GetPostString("vstate");
  7350. if (vstate.Length > 0)
  7351. {
  7352. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7353. }
  7354. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7355. string supplier = GetPostString("supplier");
  7356. int supid = commonHelper.getSupplierIDByName(supplier);
  7357. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7358. string posCode = CurrentUser.UserPost.Post.Code;
  7359. if (posCode == "Supplier")
  7360. {
  7361. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7362. }
  7363. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7364. {
  7365. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7366. }
  7367. else
  7368. {
  7369. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7370. }
  7371. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7372. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7373. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7374. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7375. writeGridDataTableJson(dStruct.TotalCount, dt);
  7376. }
  7377. public void upd_erp_supverifyaftersale()
  7378. {
  7379. if (UrlPostParmsCheck("id"))
  7380. {
  7381. string id = GetPostString("id");
  7382. int st = GetPostInt("afterstate");
  7383. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7384. CeErpTradeCell entity = null;
  7385. if (ceErpTradeResponsible != null)
  7386. {
  7387. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7388. }
  7389. string afmemo = GetPostString("supmemo");
  7390. string image = GetPostString("image");
  7391. if (entity != null)
  7392. {
  7393. entity.AfterSaleSupplierState = st;
  7394. entity.AfterSaleSupplierMemo = afmemo;
  7395. if (st == 1)
  7396. {
  7397. ceErpTradeResponsible.VerifyState = 1;
  7398. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7399. ceErpTradeResponsible.Update();
  7400. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7401. if (isAll)
  7402. {
  7403. entity.AfterSaleState = 4;
  7404. entity.FinishAfterSaleTime = DateTime.Now;
  7405. }
  7406. }
  7407. else
  7408. {
  7409. CeErpTradeResponsible.dateByTid(entity.ctid);
  7410. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7411. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7412. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7413. if (num <= 1)
  7414. {
  7415. entity.AfterSaleState = 1;
  7416. }
  7417. else
  7418. {
  7419. entity.AfterSaleState = 5;
  7420. }
  7421. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7422. if (ceErpTradeAfterSaleExtend != null)
  7423. {
  7424. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7425. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7426. ceErpTradeAfterSaleExtend.Update();
  7427. }
  7428. else
  7429. {
  7430. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7431. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7432. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7433. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7434. ceErpTradeAfterSaleExtend.Create();
  7435. }
  7436. }
  7437. if (entity.AfterSaleState == 4)
  7438. {
  7439. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7440. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7441. {
  7442. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7443. }
  7444. ApiVo apiVo = new ApiVo();
  7445. apiVo.orderNumber = entity.ctid;
  7446. apiVo.actionName = "afterOver";
  7447. designHelper.API_WorkCore(apiVo); //afterOver
  7448. }
  7449. entity.UpdateTime = DateTime.Now;
  7450. entity.Update();
  7451. returnSuccessMsg("操作成功!");
  7452. CeErpSukuraData.createInfo(entity.ctid, 8);
  7453. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7454. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7455. return;
  7456. }
  7457. returnErrorMsg("找不到订单记录");
  7458. }
  7459. }
  7460. public void upd_erp_masteraftersale()
  7461. {
  7462. if (UrlPostParmsCheck("id"))
  7463. {
  7464. string id = GetPostString("id");
  7465. int st = GetPostInt("afterstate");
  7466. string afmemo = GetPostString("supmemo");
  7467. string image = GetPostString("image");
  7468. string textResult = GetPostString("textResult");
  7469. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7470. if (ceErpTradeResponsible != null)
  7471. {
  7472. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7473. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7474. ceErpTradeResponsible.Update();
  7475. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7476. if (entity != null)
  7477. {
  7478. entity.AfterSaleSupplierState = st;
  7479. entity.AfterSaleSupplierMemo = afmemo;
  7480. if (st == 1)
  7481. {
  7482. }
  7483. else
  7484. {
  7485. CeErpTradeResponsible.dateByTid(entity.ctid);
  7486. //退回到售后
  7487. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7488. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7489. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7490. if (num <= 1)
  7491. {
  7492. entity.AfterSaleState = 1;
  7493. }
  7494. else
  7495. {
  7496. entity.AfterSaleState = 5;
  7497. }
  7498. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7499. if (ceErpTradeAfterSaleExtend != null)
  7500. {
  7501. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7502. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7503. ceErpTradeAfterSaleExtend.Update();
  7504. }
  7505. else
  7506. {
  7507. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7508. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7509. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7510. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7511. ceErpTradeAfterSaleExtend.Create();
  7512. }
  7513. }
  7514. entity.UpdateTime = DateTime.Now;
  7515. entity.Update();
  7516. returnSuccessMsg("操作成功!");
  7517. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7518. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7519. return;
  7520. }
  7521. }
  7522. returnErrorMsg("找不到订单记录");
  7523. }
  7524. }
  7525. public void upd_erp_personaftersale()
  7526. {
  7527. if (UrlPostParmsCheck("id"))
  7528. {
  7529. string id = GetPostString("id");
  7530. int st = GetPostInt("afterstate");
  7531. string afmemo = GetPostString("supmemo");
  7532. string image = GetPostString("image");
  7533. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7534. if (ceErpTradeResponsible != null)
  7535. {
  7536. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7537. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7538. ceErpTradeResponsible.Update();
  7539. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7540. if (entity != null)
  7541. {
  7542. entity.AfterSaleSupplierMemo = afmemo;
  7543. entity.AfterSaleSupplierState = st;
  7544. if (st == 1)
  7545. {
  7546. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7547. if (isAll)
  7548. {
  7549. entity.AfterSaleState = 4;
  7550. entity.FinishAfterSaleTime = DateTime.Now;
  7551. }
  7552. }
  7553. else
  7554. {
  7555. CeErpTradeResponsible.dateByTid(entity.ctid);
  7556. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7557. if (ceErpTradeAfterSaleExtend != null)
  7558. {
  7559. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7560. ceErpTradeAfterSaleExtend.Update();
  7561. }
  7562. else
  7563. {
  7564. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7565. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7566. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7567. ceErpTradeAfterSaleExtend.Create();
  7568. }
  7569. //退回到主管
  7570. //entity.AfterSaleState = 2;
  7571. }
  7572. if (entity.AfterSaleState == 4)
  7573. {
  7574. ApiVo apiVo = new ApiVo();
  7575. apiVo.orderNumber = entity.ctid;
  7576. apiVo.actionName = "afterOver";
  7577. designHelper.API_WorkCore(apiVo); //afterOver
  7578. }
  7579. entity.UpdateTime = DateTime.Now;
  7580. entity.Update();
  7581. returnSuccessMsg("操作成功!");
  7582. CeErpSukuraData.createInfo(entity.ctid, 8);
  7583. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7584. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7585. return;
  7586. }
  7587. }
  7588. returnErrorMsg("找不到订单记录");
  7589. }
  7590. }
  7591. public void set_erp_supplierrefundtag()
  7592. {
  7593. if (UrlPostParmsCheck("ctid"))
  7594. {
  7595. string eid = GetPostString("ctid");
  7596. CeErpTradeCell entity = null;
  7597. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7598. if (entity != null)
  7599. {
  7600. entity.IsSupplierRefund = GetPostInt("tag");
  7601. entity.Update();
  7602. returnSuccessMsg("操作成功!");
  7603. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7604. return;
  7605. }
  7606. returnErrorMsg("找不到订单记录");
  7607. }
  7608. }
  7609. public void get_erp_refundlist()
  7610. {
  7611. DataStruct dStruct = GetPostStruct();
  7612. List<string> lw = new List<string>();
  7613. string tid = GetPostString("tid");
  7614. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7615. //string rid = GetPostString("refund_id");
  7616. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7617. string shopname = GetPostString("shopname");
  7618. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7619. string buyernick = GetPostString("buyer_nick");
  7620. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7621. string customer = GetPostString("customer");
  7622. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7623. string design = GetPostString("design");
  7624. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7625. string sellermemo = GetPostString("seller_memo");
  7626. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7627. //string date1 = GetPostString("date1");
  7628. //string date2 = GetPostString("date2");
  7629. //string dateType = GetPostString("dateType");
  7630. //if (dateType.Length > 0)
  7631. //{
  7632. // if (dateType == "1001") dateType = "0";
  7633. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7634. // if (searchDT.Count == 2)
  7635. // {
  7636. // date1 = searchDT[0].ToString();
  7637. // date2 = searchDT[1].ToString();
  7638. // }
  7639. //}
  7640. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7641. //if (dw.Length > 0) lw.Add(dw);
  7642. string redate1 = GetPostString("refunddate1");
  7643. string redate2 = GetPostString("refunddate2");
  7644. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7645. if (dwdate.Length > 0) lw.Add(dwdate);
  7646. string price1 = GetPostString("price1");
  7647. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7648. string price2 = GetPostString("price2");
  7649. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7650. string ispartrefund = GetPostString("ispartrefund");
  7651. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7652. string refundState = GetPostString("refundvstate");
  7653. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7654. int st = GetInt("st");
  7655. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7656. {
  7657. string responsible = GetPostString("responsibleman");
  7658. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7659. lw.Add(string.Format("RefundState>={0}", st));
  7660. string code = CurrentUser.UserPost.Post.Code;
  7661. if (code == "CustomerService")
  7662. {
  7663. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7664. }
  7665. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7666. {
  7667. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7668. }
  7669. else if (code == "Place" || code == "PlaceMr")
  7670. {
  7671. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7672. }
  7673. dStruct.Order = "RefundState asc,created desc";
  7674. }
  7675. else if (st == 10)
  7676. {
  7677. string responsible = GetPostString("responsibleman");
  7678. if (responsible == "空白")
  7679. {
  7680. lw.Add(string.Format("ResponsibleUserName = ''"));
  7681. }
  7682. else if (responsible.Length > 0)
  7683. {
  7684. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7685. }
  7686. lw.Add(string.Format("RefundState>=0"));
  7687. dStruct.Order = "created desc";
  7688. }
  7689. else
  7690. {
  7691. string responsible = GetPostString("responsibleman");
  7692. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7693. lw.Add(string.Format("RefundState={0}", st));
  7694. dStruct.Order = "created desc";
  7695. }
  7696. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7697. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7698. dt.Columns.Add("refund_fees");
  7699. foreach (DataRow dr in dt.Rows)
  7700. {
  7701. String status = dr["status"].ToString();
  7702. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7703. {
  7704. dr["refund_fees"] = dr["refund_fee"];
  7705. }
  7706. else
  7707. {
  7708. dr["refund_fees"] = "0.0";
  7709. }
  7710. }
  7711. writeGridDataTableJson(dStruct.TotalCount, dt);
  7712. }
  7713. public void get_erp_refunddesignlist()
  7714. {
  7715. DataStruct dStruct = GetPostStruct();
  7716. List<string> lw = new List<string>();
  7717. string tid = GetPostString("tid");
  7718. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7719. string shopname = GetPostString("shopname");
  7720. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7721. string buyernick = GetPostString("buyer_nick");
  7722. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7723. string customer = GetPostString("customer");
  7724. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7725. string design = GetPostString("design");
  7726. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7727. string sellermemo = GetPostString("seller_memo");
  7728. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7729. string redate1 = GetPostString("refunddate1");
  7730. string redate2 = GetPostString("refunddate2");
  7731. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7732. if (dwdate.Length > 0) lw.Add(dwdate);
  7733. string price1 = GetPostString("price1");
  7734. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7735. string price2 = GetPostString("price2");
  7736. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7737. string ispartrefund = GetPostString("ispartrefund");
  7738. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7739. string designerorg = GetPostString("designerorg");
  7740. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7741. string refundState = GetPostString("refundState");
  7742. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7743. int myOrgid = CurrentUser.UserPost.OrgID;
  7744. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7745. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7746. {
  7747. if (CurrentUser.User.TeamIds.Length > 0)
  7748. {
  7749. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7750. }
  7751. else
  7752. {
  7753. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7754. }
  7755. }
  7756. else if ("SysAdmin".Equals(myOrgCode))
  7757. {
  7758. }
  7759. else
  7760. {
  7761. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7762. {
  7763. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7764. }
  7765. else
  7766. {
  7767. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7768. }
  7769. }
  7770. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7771. dStruct.Order = "created desc";
  7772. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7773. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7774. dt.Columns.Add("refund_fees");
  7775. foreach (DataRow dr in dt.Rows)
  7776. {
  7777. String status = dr["status"].ToString();
  7778. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7779. {
  7780. dr["refund_fees"] = dr["refund_fee"];
  7781. }
  7782. else
  7783. {
  7784. dr["refund_fees"] = "0.0";
  7785. }
  7786. }
  7787. writeGridDataTableJson(dStruct.TotalCount, dt);
  7788. }
  7789. public void handle_erp_refundtag()
  7790. {
  7791. if (UrlPostParmsCheck("refund_id"))
  7792. {
  7793. string eid = GetPostString("refund_id");
  7794. string respMan = GetPostString("ResponsibleName");
  7795. if (respMan.Length <= 0)
  7796. {
  7797. returnErrorMsg("责任人不能为空");
  7798. return;
  7799. }
  7800. CeErpTradeRefund entity = null;
  7801. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7802. if (entity != null)
  7803. {
  7804. entity.ResponsibleUserName = respMan;
  7805. string userid = GetPostString("ResponsibleUserId");
  7806. if (userid.Length > 0)
  7807. {
  7808. entity.ResponsibleUserId = userid;
  7809. }
  7810. entity.Memo = GetPostString("Memo");
  7811. if (respMan.IndexOf("客服") != -1 ||
  7812. respMan.IndexOf("设计师") != -1 ||
  7813. respMan.IndexOf("下单员") != -1)
  7814. {
  7815. entity.RefundState = 2;
  7816. }
  7817. else
  7818. {
  7819. entity.RefundState = 3;
  7820. }
  7821. entity.modified = DateTime.Now;
  7822. entity.Update();
  7823. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7824. returnSuccessMsg("操作成功!");
  7825. return;
  7826. }
  7827. returnErrorMsg("找不到订单记录");
  7828. }
  7829. }
  7830. public void handle_erp_designrefundtag()
  7831. {
  7832. if (UrlPostParmsCheck("refund_id"))
  7833. {
  7834. string eid = GetPostString("refund_id");
  7835. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7836. if (ceErpTradeCellExtend == null)
  7837. {
  7838. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7839. ceErpTradeCellExtend.ctid = eid;
  7840. }
  7841. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7842. if (ceErpTradeCellExtend.ID > 0)
  7843. {
  7844. ceErpTradeCellExtend.Update();
  7845. }
  7846. else
  7847. {
  7848. ceErpTradeCellExtend.Create();
  7849. }
  7850. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7851. returnSuccessMsg("操作成功!");
  7852. return;
  7853. }
  7854. returnErrorMsg("找不到订单记录");
  7855. }
  7856. public void upd_erp_refundverify()
  7857. {
  7858. if (UrlPostParmsCheck("refund_id"))
  7859. {
  7860. string eid = GetPostString("refund_id");
  7861. CeErpTradeRefund entity = null;
  7862. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7863. if (entity != null)
  7864. {
  7865. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7866. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7867. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7868. {
  7869. entity.RefundState = 2;
  7870. }
  7871. else
  7872. {
  7873. entity.RefundState = 3;
  7874. }
  7875. entity.Update();
  7876. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7877. returnSuccessMsg("操作成功!");
  7878. return;
  7879. }
  7880. returnErrorMsg("找不到订单记录");
  7881. }
  7882. }
  7883. public void upd_erp_refundapprove()
  7884. {
  7885. if (UrlPostParmsCheck("refund_id"))
  7886. {
  7887. string eid = GetPostString("refund_id");
  7888. CeErpTradeRefund entity = null;
  7889. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7890. if (entity != null)
  7891. {
  7892. int apr = GetPostInt("approve");
  7893. if (apr == 0)
  7894. {
  7895. entity.RefundState = 1;
  7896. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7897. }
  7898. else if (apr == 1)
  7899. {
  7900. entity.RefundState = 3;
  7901. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7902. }
  7903. entity.modified = DateTime.Now;
  7904. entity.Update();
  7905. returnSuccessMsg("操作成功!");
  7906. return;
  7907. }
  7908. returnErrorMsg("找不到订单记录");
  7909. }
  7910. }
  7911. public void get_erp_billlist()
  7912. {
  7913. DataStruct dStruct = GetPostStruct();
  7914. List<string> lw = new List<string>();
  7915. string title = GetPostString("title");
  7916. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7917. string tid = GetPostString("tid");
  7918. string tids = GetPostString("tids");
  7919. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7920. if (tids.Length > 0)
  7921. {
  7922. tids = "'" + tids + "'";
  7923. tids = tids.Replace(",", "','");
  7924. lw.Add(string.Format("tid in ({0})", tids));
  7925. }
  7926. string shopname = GetPostString("shopname");
  7927. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7928. string buyernick = GetPostString("buyer_nick");
  7929. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7930. string customer = GetPostString("customer");
  7931. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7932. string date1 = GetPostString("date1");
  7933. string date2 = GetPostString("date2");
  7934. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7935. if (dw.Length > 0) lw.Add(dw);
  7936. string price1 = GetPostString("price1");
  7937. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7938. string price2 = GetPostString("price2");
  7939. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7940. string returndate1 = GetPostString("returndate1");
  7941. string returndate2 = GetPostString("returndate2");
  7942. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7943. if (dw1.Length > 0) lw.Add(dw1);
  7944. string billtype = GetPostString("billtype");
  7945. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7946. string billstate = GetPostString("billstate");
  7947. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7948. string usershop = CurrentUser.User.pemShop;
  7949. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7950. dStruct.Order = "createTime desc";
  7951. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7952. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7953. //foreach (DataRow dr in dt.Rows)
  7954. //{
  7955. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7956. //}
  7957. writeGridDataTableJson(dStruct.TotalCount, dt);
  7958. }
  7959. public void modify_erp_billinfo()
  7960. {
  7961. if (UrlPostParmsCheck("ID"))
  7962. {
  7963. string eid = GetPostString("ID");
  7964. CeErpBill bill_entity = null;
  7965. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7966. if (bill_entity != null)
  7967. {
  7968. bill_entity.tid = GetPostString("tid");
  7969. bill_entity.title = GetPostString("title");
  7970. bill_entity.tax = GetPostString("tax");
  7971. bill_entity.bank = GetPostString("bank");
  7972. bill_entity.bankac = GetPostString("bankac");
  7973. bill_entity.address = GetPostString("address");
  7974. bill_entity.phone = GetPostString("phone");
  7975. bill_entity.price = GetPostString("price");
  7976. bill_entity.productId = GetPostInt("ProductName");
  7977. bill_entity.num = GetPostInt("num");
  7978. bill_entity.unit = GetPostString("unit");
  7979. bill_entity.type = GetPostString("type");
  7980. bill_entity.sendType = GetPostString("SendType");
  7981. bill_entity.email = GetPostString("email");
  7982. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7983. bill_entity.shopName = GetPostString("ShopName");
  7984. bill_entity.applymemo = GetPostString("applymemo");
  7985. bill_entity.modifyTime = DateTime.Now;
  7986. bill_entity.createTime = DateTime.Now;
  7987. bill_entity.state = 0;
  7988. bill_entity.Update();
  7989. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7990. returnSuccessMsg("发票修改成功!");
  7991. return;
  7992. }
  7993. returnErrorMsg("找不到对应记录");
  7994. }
  7995. }
  7996. public void set_erp_invoicing()
  7997. {
  7998. if (UrlPostParmsCheck("id"))
  7999. {
  8000. try
  8001. {
  8002. string eid = GetPostString("id");
  8003. CeErpBill bill_entity = null;
  8004. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8005. if (bill_entity != null)
  8006. {
  8007. int ComId = GetPostInt("ComId");
  8008. //string memo = GetPostString("Memo");
  8009. int allInfo = GetPostInt("allinfo");
  8010. string clert = CurrentUser.User.Name;
  8011. //string detailValue = GetPostString("detailvalue");
  8012. string billId = bill_entity.billOrderId;
  8013. string[] billIdList = billId.Split(',');
  8014. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8015. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8016. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8017. {
  8018. billCount += 1;
  8019. }
  8020. if (billId.Length <= 0 || billIdList.Length != billCount)
  8021. {
  8022. bill_entity.billOrderId = "";
  8023. string prebill = "ltb";
  8024. for (int idx = 1; idx <= billCount; idx++)
  8025. {
  8026. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8027. string billoid = prebill + idx + dtstr;
  8028. bill_entity.billOrderId += billoid;
  8029. if (idx < billCount)
  8030. {
  8031. bill_entity.billOrderId += ",";
  8032. }
  8033. }
  8034. }
  8035. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8036. if (bill_entity.state == 5)
  8037. {
  8038. string errMsg = bill_entity.failerror;
  8039. string[] errlist = errMsg.Split('|');
  8040. string[] errTags = new string[errlist.Length];
  8041. for (int itag = 0; itag < errlist.Length; itag++)
  8042. {
  8043. if (errlist[itag].Length <= 0) continue;
  8044. errTags[itag] = errlist[itag].Split('&')[0];
  8045. }
  8046. for (int iii = 0; iii < errTags.Length; iii++)
  8047. {
  8048. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8049. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8050. if (billOrderList.Length >= erroBillOrderTag)
  8051. {
  8052. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8053. if (needModifyBillId.Length <= 19)
  8054. {
  8055. needModifyBillId = needModifyBillId + "1";
  8056. }
  8057. else
  8058. {
  8059. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8060. last = last + 1;
  8061. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8062. }
  8063. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8064. }
  8065. }
  8066. }
  8067. bool isHaveBillSucces = false;
  8068. string totalRes = "";
  8069. bill_entity.failerror = "";
  8070. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8071. {
  8072. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8073. totalRes += res;
  8074. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8075. {
  8076. isHaveBillSucces = true;
  8077. bill_entity.comId = ComId;
  8078. bill_entity.state = 1;
  8079. bill_entity.executeTime = DateTime.Now;
  8080. bill_entity.executeUser = clert;
  8081. }
  8082. else
  8083. {
  8084. bill_entity.state = 5;
  8085. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8086. }
  8087. }
  8088. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8089. bill_entity.Update();
  8090. if (isHaveBillSucces)
  8091. {
  8092. StringBuilder sql = new StringBuilder();
  8093. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8094. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8095. }
  8096. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8097. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8098. {
  8099. returnErrorMsg("开票失败");
  8100. }
  8101. else
  8102. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8103. return;
  8104. }
  8105. returnErrorMsg("找不到对应记录");
  8106. }
  8107. catch (Exception ex)
  8108. {
  8109. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8110. returnErrorMsg("操作失败");
  8111. }
  8112. }
  8113. }
  8114. public void get_erp_invoicing_back()
  8115. {
  8116. if (UrlPostParmsCheck("id"))
  8117. {
  8118. try
  8119. {
  8120. string id = GetPostString("id");
  8121. CeErpBill entiy = CeErpBill.Get(id);
  8122. if (entiy != null)
  8123. {
  8124. if (entiy.state == 0)
  8125. {
  8126. returnErrorMsg("发票还未开具");
  8127. return;
  8128. }
  8129. string[] billOrderList = entiy.billOrderId.Split(',');
  8130. int iTag = 0;
  8131. entiy.fplsh = "";
  8132. entiy.fpdm = "";
  8133. entiy.fphm = "";
  8134. foreach (string billOrderId in billOrderList)
  8135. {
  8136. iTag++;
  8137. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8138. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8139. {
  8140. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8141. try
  8142. {
  8143. Invoicing_get_response_Obj iObj = null;
  8144. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8145. if (iObj != null)
  8146. {
  8147. entiy.state = 2;
  8148. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8149. entiy.fpdm += iObj.list[0].c_fpdm;
  8150. entiy.fphm += iObj.list[0].c_fphm;
  8151. if (iTag < billOrderList.Length)
  8152. {
  8153. entiy.fplsh += ",";
  8154. entiy.fpdm += ",";
  8155. entiy.fphm += ",";
  8156. }
  8157. entiy.Update();
  8158. }
  8159. StringBuilder sql = new StringBuilder();
  8160. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8161. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8162. returnSuccessMsg("开票成功");
  8163. }
  8164. catch (Exception ex)
  8165. {
  8166. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8167. }
  8168. return;
  8169. }
  8170. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8171. {
  8172. var res_obj = new
  8173. {
  8174. data = "开票中"
  8175. };
  8176. string ro_json = JsonConvert.SerializeObject(res_obj);
  8177. returnSuccess(ro_json);
  8178. return;
  8179. }
  8180. else
  8181. {
  8182. int eidx = res.IndexOf("c_resultmsg");
  8183. int lidx = res.IndexOf("c_status");
  8184. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8185. entiy.state = 5;
  8186. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8187. entiy.Update();
  8188. returnErrorMsg("开票失败");
  8189. return;
  8190. }
  8191. }
  8192. }
  8193. }
  8194. catch (Exception ex)
  8195. {
  8196. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8197. }
  8198. return;
  8199. }
  8200. }
  8201. public void get_erp_invoicing()
  8202. {
  8203. if (UrlPostParmsCheck("id"))
  8204. {
  8205. try
  8206. {
  8207. string id = GetPostString("id");
  8208. CeErpBill entiy = CeErpBill.Get(id);
  8209. if (entiy != null)
  8210. {
  8211. if (entiy.state == 0)
  8212. {
  8213. returnErrorMsg("发票还未开具");
  8214. return;
  8215. }
  8216. if (entiy.sendType == "纸质发票")
  8217. {
  8218. if (entiy.img.Length <= 0)
  8219. {
  8220. returnErrorMsg("查无纸质发票");
  8221. return;
  8222. }
  8223. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8224. returnSuccess(returnres);
  8225. return;
  8226. }
  8227. string[] billOrderList = entiy.billOrderId.Split(',');
  8228. int iTag = 0;
  8229. string fpUrl = "";
  8230. entiy.fplsh = "";
  8231. entiy.fpdm = "";
  8232. entiy.fphm = "";
  8233. foreach (string billOrderId in billOrderList)
  8234. {
  8235. iTag++;
  8236. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8237. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8238. {
  8239. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8240. Invoicing_get_response_Obj iObj = null;
  8241. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8242. if (iObj != null)
  8243. {
  8244. //entiy.state = 2;
  8245. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8246. entiy.fpdm += iObj.list[0].c_fpdm;
  8247. entiy.fphm += iObj.list[0].c_fphm;
  8248. if (iTag < billOrderList.Length)
  8249. {
  8250. entiy.fplsh += ",";
  8251. entiy.fpdm += ",";
  8252. entiy.fphm += ",";
  8253. }
  8254. entiy.Update();
  8255. fpUrl += iObj.list[0].c_url + ",";
  8256. }
  8257. //returnSuccess(res);
  8258. StringBuilder sql = new StringBuilder();
  8259. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8260. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8261. }
  8262. else
  8263. {
  8264. int eidx = res.IndexOf("c_resultmsg");
  8265. //int lidx = res.IndexOf("c_status");
  8266. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8267. //开票失败
  8268. entiy.state = 5;
  8269. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8270. entiy.Update();
  8271. returnErrorMsg("开票失败");
  8272. return;
  8273. }
  8274. }
  8275. var returnObj = new
  8276. {
  8277. data = fpUrl
  8278. };
  8279. string ro_json = JsonConvert.SerializeObject(returnObj);
  8280. returnSuccess(ro_json);
  8281. }
  8282. }
  8283. catch (Exception ex)
  8284. {
  8285. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8286. }
  8287. return;
  8288. }
  8289. }
  8290. public void save_erp_billimg()
  8291. {
  8292. if (UrlPostParmsCheck("id"))
  8293. {
  8294. string eid = GetPostString("id");
  8295. CeErpBill bill_entity = null;
  8296. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8297. if (bill_entity != null)
  8298. {
  8299. bill_entity.img = GetPostString("img");
  8300. bill_entity.executeTime = DateTime.Now;
  8301. bill_entity.state = 2;
  8302. bill_entity.Update();
  8303. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8304. returnSuccessMsg("保存成功");
  8305. }
  8306. return;
  8307. }
  8308. }
  8309. public void upd_erp_billreturnback()
  8310. {
  8311. if (UrlPostParmsCheck("id"))
  8312. {
  8313. int eid = GetPostInt("id");
  8314. CeErpBill bill_entity = null;
  8315. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8316. if (bill_entity != null)
  8317. {
  8318. bill_entity.state = 3;
  8319. bill_entity.returnReason = GetPostString("reason");
  8320. bill_entity.Update();
  8321. returnSuccessMsg("驳回成功!");
  8322. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8323. }
  8324. return;
  8325. }
  8326. }
  8327. public void cancel_erp_bill()
  8328. {
  8329. if (UrlPostParmsCheck("id"))
  8330. {
  8331. int eid = GetPostInt("id");
  8332. int detailValue = GetPostInt("detailvalue");
  8333. CeErpBill bill_entity = null;
  8334. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8335. string cres = "";
  8336. string gres = "";
  8337. if (bill_entity != null)
  8338. {
  8339. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8340. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8341. {
  8342. int iTag = 0;
  8343. bill_entity.fplsh = "";
  8344. bill_entity.fpdm = "";
  8345. bill_entity.fphm = "";
  8346. foreach (string billOrderId in billOrderList)
  8347. {
  8348. iTag++;
  8349. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8350. if (gres.IndexOf("success") != -1)
  8351. {
  8352. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8353. Invoicing_get_response_Obj iObj = null;
  8354. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8355. if (iObj != null)
  8356. {
  8357. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8358. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8359. bill_entity.fphm += iObj.list[0].c_fphm;
  8360. if (iTag < billOrderList.Length)
  8361. {
  8362. bill_entity.fplsh += ",";
  8363. bill_entity.fpdm += ",";
  8364. bill_entity.fphm += ",";
  8365. }
  8366. bill_entity.Update();
  8367. }
  8368. }
  8369. else
  8370. {
  8371. returnErrorMsg(gres);
  8372. return;
  8373. }
  8374. }
  8375. }
  8376. if (bill_entity.sendType == "纸质发票")
  8377. {
  8378. //作废
  8379. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8380. //if (DateTime.Now.Month == extime.Month)
  8381. //{
  8382. //cres = taobaoHelper.cancel_invoicing(eid);
  8383. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8384. //{
  8385. bill_entity.state = 4;//已作废
  8386. bill_entity.Update();
  8387. returnSuccessMsg("发票已作废");
  8388. return;
  8389. //}
  8390. //else
  8391. //{
  8392. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8393. // bill_entity.Update();
  8394. // returnErrorMsg(cres);
  8395. // return;
  8396. //}
  8397. //}
  8398. //else
  8399. //{
  8400. // returnErrorMsg("纸质发票只能作废本月的发票");
  8401. // return;
  8402. //}
  8403. }
  8404. //红冲
  8405. int redTag = 0;
  8406. string[] fpdmList = bill_entity.fpdm.Split(',');
  8407. string[] fphmList = bill_entity.fphm.Split(',');
  8408. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8409. {
  8410. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8411. return;
  8412. }
  8413. foreach (string billOrderId in billOrderList)
  8414. {
  8415. redTag++;
  8416. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8417. cres += onecres;
  8418. cres += ",";
  8419. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8420. {
  8421. bill_entity.state = 4;//已作废
  8422. //bill_entity.Update();
  8423. //returnSuccessMsg("发票已红冲");
  8424. }
  8425. else if (onecres.IndexOf("重复冲红") != -1)
  8426. {
  8427. bill_entity.state = 4;//已作废
  8428. //bill_entity.Update();
  8429. //returnSuccessMsg("发票已红冲");
  8430. }
  8431. else
  8432. {
  8433. string errmsg = commonHelper.KeepChinese(onecres);
  8434. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8435. }
  8436. }
  8437. bill_entity.Update();
  8438. if (cres.IndexOf("失败") != -1)
  8439. returnErrorMsg("红冲失败");
  8440. else
  8441. returnSuccessMsg("发票已红冲");
  8442. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8443. return;
  8444. }
  8445. return;
  8446. }
  8447. }
  8448. public void del_erp_billorder()
  8449. {
  8450. if (UrlPostParmsCheck("id"))
  8451. {
  8452. string eid = GetPostString("id");
  8453. CeErpBill.Del(eid);
  8454. CeErpBill bill = CeErpBill.Get(eid);
  8455. if (bill != null)
  8456. {
  8457. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8458. }
  8459. returnSuccessMsg("删除成功");
  8460. }
  8461. }
  8462. public void finish_erp_bill()
  8463. {
  8464. if (UrlPostParmsCheck("ids"))
  8465. {
  8466. string eids = GetPostString("ids");
  8467. string[] list = eids.Split(',');
  8468. foreach (string eid in list)
  8469. {
  8470. CeErpBill bill = CeErpBill.Get(eid);
  8471. if (bill != null)
  8472. {
  8473. bill.state = 2;
  8474. bill.Update();
  8475. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8476. }
  8477. }
  8478. returnSuccessMsg("操作成功");
  8479. }
  8480. }
  8481. public void get_erp_returncash()
  8482. {
  8483. DataStruct dStruct = GetPostStruct();
  8484. List<string> lw = new List<string>();
  8485. string tid = GetPostString("tid");
  8486. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8487. string shopname = GetPostString("shopname");
  8488. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8489. string buyernick = GetPostString("buyer_nick");
  8490. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8491. string customer = GetPostString("customer");
  8492. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8493. string returndate1 = GetPostString("returndate1");
  8494. string returndate2 = GetPostString("returndate2");
  8495. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8496. if (dw.Length > 0) lw.Add(dw);
  8497. string finishDate1 = GetPostString("finishdate1");
  8498. string finishDate2 = GetPostString("finishdate2");
  8499. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8500. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8501. string returntype = GetPostString("returntype");
  8502. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8503. string returnvstate = GetPostString("returnvstate");
  8504. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8505. dStruct.Order = "created desc";
  8506. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8507. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8508. writeGridDataTableJson(dStruct.TotalCount, dt);
  8509. }
  8510. public void get_erp_staygoods()
  8511. {
  8512. DataStruct dStruct = GetPostStruct();
  8513. List<string> lw = new List<string>();
  8514. string tid = GetPostString("tid");
  8515. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8516. string shopname = GetPostString("shopname");
  8517. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8518. string wangwang = GetPostString("wangwang");
  8519. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8520. string customer = GetPostString("customer");
  8521. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8522. string returndate1 = GetPostString("returndate1");
  8523. string returndate2 = GetPostString("returndate2");
  8524. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8525. if (dw.Length > 0) lw.Add(dw);
  8526. string finishDate1 = GetPostString("finishdate1");
  8527. string finishDate2 = GetPostString("finishdate2");
  8528. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8529. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8530. string returnvstate = GetPostString("returnvstate");
  8531. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8532. string persuadetype = GetPostString("persuadetype");
  8533. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8534. string customerOrg = GetPostString("customerOrg");
  8535. if (customerOrg.Length > 0)
  8536. {
  8537. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8538. }
  8539. dStruct.Order = "creata_time desc";
  8540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8541. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8542. writeGridDataTableJson(dStruct.TotalCount, dt);
  8543. }
  8544. public void upd_erp_staygoods()
  8545. {
  8546. if (UrlPostParmsCheck("id"))
  8547. {
  8548. int eid = GetPostInt("id");
  8549. CeErpStayGoods entity = null;
  8550. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8551. if (entity != null)
  8552. {
  8553. entity.audit_type = 1;
  8554. entity.audit_time = DateTime.Now;
  8555. entity.audit_u_id = CurrentUser.UserID;
  8556. entity.audit_u_name = CurrentUser.UserName;
  8557. entity.Update();
  8558. returnSuccessMsg("审核成功!");
  8559. return;
  8560. }
  8561. returnErrorMsg("找不到订单记录");
  8562. }
  8563. }
  8564. public void upd_erp_stayGoodsback()
  8565. {
  8566. if (UrlPostParmsCheck("id"))
  8567. {
  8568. int eid = GetPostInt("id");
  8569. CeErpStayGoods entity = null;
  8570. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8571. if (entity != null)
  8572. {
  8573. entity.audit_text = GetPostString("reason");
  8574. entity.audit_type = 2;
  8575. entity.audit_time = DateTime.Now;
  8576. entity.audit_u_id = CurrentUser.UserID;
  8577. entity.audit_u_name = CurrentUser.UserName;
  8578. entity.Update();
  8579. returnSuccessMsg("退回成功!");
  8580. return;
  8581. }
  8582. returnErrorMsg("找不到订单记录");
  8583. }
  8584. }
  8585. public void upd_erp_returncashverify()
  8586. {
  8587. if (UrlPostParmsCheck("ID"))
  8588. {
  8589. int eid = GetPostInt("ID");
  8590. CeErpReturnCash entity = null;
  8591. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8592. if (entity != null)
  8593. {
  8594. entity.cashstate = 1;
  8595. entity.verifytime = DateTime.Now;
  8596. entity.verifyuserid = CurrentUser.UserID;
  8597. entity.Update();
  8598. returnSuccessMsg("审核成功!");
  8599. return;
  8600. }
  8601. returnErrorMsg("找不到订单记录");
  8602. }
  8603. }
  8604. public void upd_all_erp_returncashverify()
  8605. {
  8606. if (UrlPostParmsCheck("ID"))
  8607. {
  8608. String[] list = GetPostString("ID").Split(',');
  8609. CeErpReturnCash entity = null;
  8610. for (int i = 0; i < list.Length; i++)
  8611. {
  8612. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8613. if (entity != null)
  8614. {
  8615. if (entity.cashstate == 1)
  8616. {
  8617. returnErrorMsg("已审核过的订单不需要在审核!");
  8618. return;
  8619. }
  8620. entity.cashstate = 1;
  8621. entity.verifytime = DateTime.Now;
  8622. entity.verifyuserid = CurrentUser.UserID;
  8623. entity.Update();
  8624. }
  8625. }
  8626. returnSuccessMsg("审核成功!");
  8627. return;
  8628. }
  8629. }
  8630. public void upd_erp_returncashback()
  8631. {
  8632. if (UrlPostParmsCheck("ID"))
  8633. {
  8634. int eid = GetPostInt("ID");
  8635. CeErpReturnCash entity = null;
  8636. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8637. if (entity != null)
  8638. {
  8639. entity.backreason = GetPostString("reason");
  8640. entity.cashstate = 2;
  8641. entity.verifytime = DateTime.Now;
  8642. entity.verifyuserid = CurrentUser.UserID;
  8643. entity.Update();
  8644. returnSuccessMsg("退回成功!");
  8645. return;
  8646. }
  8647. returnErrorMsg("找不到订单记录");
  8648. }
  8649. }
  8650. public void upd_erp_returnprice()
  8651. {
  8652. if (UrlPostParmsCheck("ID"))
  8653. {
  8654. int eid = GetPostInt("ID");
  8655. CeErpReturnCash entity = null;
  8656. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8657. if (entity != null)
  8658. {
  8659. if (entity.cashstate == 1)
  8660. {
  8661. returnErrorMsg("审核通过了不能改");
  8662. return;
  8663. }
  8664. entity.returnprice = GetPostDouble("returnprice");
  8665. entity.Update();
  8666. returnSuccessMsg("修改成功!");
  8667. return;
  8668. }
  8669. returnErrorMsg("找不到订单记录");
  8670. }
  8671. }
  8672. public void del_erp_returncash()
  8673. {
  8674. if (UrlPostParmsCheck("ID"))
  8675. {
  8676. int eid = GetPostInt("ID");
  8677. CeErpReturnCash.Del(eid);
  8678. returnSuccessMsg("操作成功");
  8679. return;
  8680. }
  8681. }
  8682. public void test_for_do_sql()
  8683. {
  8684. string sql = GetPostString("sqlstr");
  8685. if (sql.Length > 0)
  8686. {
  8687. try
  8688. {
  8689. DbHelper.DbConn.ExecuteNonQuery(sql);
  8690. var res_obj = new
  8691. {
  8692. data = "成功",
  8693. };
  8694. string ro_json = JsonConvert.SerializeObject(res_obj);
  8695. returnSuccess(ro_json);
  8696. }
  8697. catch (Exception ex)
  8698. {
  8699. var res_obj = new
  8700. {
  8701. data = ex.Message,
  8702. };
  8703. string ro_json = JsonConvert.SerializeObject(res_obj);
  8704. returnSuccess(ro_json);
  8705. }
  8706. }
  8707. }
  8708. public void get_user_info()
  8709. {
  8710. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8711. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8712. }
  8713. public void get_total_data()
  8714. {
  8715. int userId = CurrentUser.UserID;
  8716. string sql = "";
  8717. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8718. {
  8719. 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);
  8720. }
  8721. else
  8722. {
  8723. 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 " +
  8724. "(select ID from CE_ErpUser where ID = {0}) d " +
  8725. "left join " +
  8726. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8727. ") a on d.ID = a.id left join " +
  8728. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8729. ") b on a.id = b.id1 left join" +
  8730. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8731. ") c on a.id = c.id2;", userId);
  8732. }
  8733. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8734. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8735. }
  8736. public void get_date_area_total_data2()
  8737. {
  8738. int userId = CurrentUser.UserID;
  8739. string date_type = GetPostString("timetype");
  8740. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8741. string sql = "";
  8742. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8743. {
  8744. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8745. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8746. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8747. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8748. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8749. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8750. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8751. ") a on e.ID = a.id left join " +
  8752. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8753. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8754. ") b on a.id = b.id1 " +
  8755. "left join " +
  8756. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8757. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8758. ") c on a.id = c.id2 " +
  8759. "left join " +
  8760. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8761. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8762. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8763. }
  8764. else
  8765. {
  8766. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8767. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8768. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8769. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8770. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8771. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8772. ") a on e.ID = a.id left join " +
  8773. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8774. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8775. ") c on a.id = c.id2 " +
  8776. "left join " +
  8777. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8778. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8779. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8780. }
  8781. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8782. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8783. }
  8784. public void get_date_area_total_data()
  8785. {
  8786. int userId = CurrentUser.UserID;
  8787. string date_type = GetPostString("timetype");
  8788. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8789. string date1 = searchDT[0].ToString();
  8790. string date2 = searchDT[1].ToString();
  8791. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8792. {
  8793. SqlParameter[] sqlParameter ={
  8794. new SqlParameter("@userId", SqlDbType.Int,4),
  8795. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8796. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8797. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8798. };
  8799. sqlParameter[0].Value = userId;
  8800. sqlParameter[1].Value = date1;
  8801. sqlParameter[2].Value = date2;
  8802. sqlParameter[3].Direction = ParameterDirection.Output;
  8803. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8804. string res = sqlParameter[3].Value.ToString();
  8805. var res_obj = new
  8806. {
  8807. data = res
  8808. };
  8809. string ro_json = JsonConvert.SerializeObject(res_obj);
  8810. returnSuccess(ro_json);
  8811. }
  8812. else
  8813. {
  8814. SqlParameter[] sqlParameter ={
  8815. new SqlParameter("@userId", SqlDbType.Int,4),
  8816. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8817. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8818. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8819. };
  8820. sqlParameter[0].Value = userId;
  8821. sqlParameter[1].Value = date1;
  8822. sqlParameter[2].Value = date2;
  8823. sqlParameter[3].Direction = ParameterDirection.Output;
  8824. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8825. string res = sqlParameter[3].Value.ToString();
  8826. var res_obj = new
  8827. {
  8828. data = res
  8829. };
  8830. string ro_json = JsonConvert.SerializeObject(res_obj);
  8831. returnSuccess(ro_json);
  8832. }
  8833. //writeGridDataViewJson(dt.Rows.Count, dv);
  8834. }
  8835. public void get_order_list()
  8836. {
  8837. string strFields = GetPostString("paraFields");
  8838. string strOrder = GetPostString("paraOrder");
  8839. string strWhere = GetPostString("paraWhere");
  8840. string strPageSize = GetPostString("paraPageSize");
  8841. DataStruct dStruct = GetPostStruct();
  8842. dStruct.PageSize = int.Parse(strPageSize);
  8843. dStruct.Fileds = strFields;
  8844. dStruct.Order = strOrder;
  8845. dStruct.MainWhere = strWhere;
  8846. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8847. writeGridDataTableJson(dStruct.TotalCount, dt);
  8848. }
  8849. ////获取待开始订单列表
  8850. //public void get_wait_design_order_list()
  8851. //{
  8852. // string date_type = GetPostString("date_type");
  8853. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8854. // DataStruct dStruct = GetPostStruct();
  8855. // dStruct.PageSize = 1000;
  8856. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8857. // List<string> lw = new List<string>();
  8858. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8859. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8860. // dStruct.Order = "WaitDesignTime asc";
  8861. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8862. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8863. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8864. //}
  8865. //获取完成单量排名
  8866. public void get_finish_order_count_ranking()
  8867. {
  8868. /* string date_type = GetPostString("date_type");
  8869. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8870. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8871. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8872. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8873. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8874. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8875. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8876. writeGridDataTableJson(0, new DataTable());
  8877. }
  8878. public void get_finish_order_amount_ranking()
  8879. {
  8880. /*string date_type = GetPostString("date_type");
  8881. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8882. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8883. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8884. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8885. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8886. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8887. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8888. writeGridDataTableJson(0, new DataTable());
  8889. }
  8890. public void get_finish_refund_count_ranking()
  8891. {
  8892. string date_type = GetPostString("date_type");
  8893. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8894. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8895. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8896. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8897. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8898. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8899. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8900. writeGridDataTableJson(dt.Rows.Count, dt);
  8901. }
  8902. public void get_finish_refund_amount_ranking()
  8903. {
  8904. string date_type = GetPostString("date_type");
  8905. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8906. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8907. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8908. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8909. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8910. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8911. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8912. writeGridDataTableJson(dt.Rows.Count, dt);
  8913. }
  8914. public void set_erp_finishorder_director()
  8915. {
  8916. if (UrlPostParmsCheck("ctid"))
  8917. {
  8918. string eid = GetPostString("ctid");
  8919. CeErpTradeCell entity = null;
  8920. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8921. if (entity != null)
  8922. {
  8923. entity.OrderState = 8;
  8924. entity.Update();
  8925. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8926. returnSuccessMsg("操作成功!");
  8927. return;
  8928. }
  8929. returnErrorMsg("找不到记录");
  8930. }
  8931. }
  8932. public void get_erp_placeregistlist()
  8933. {
  8934. DataStruct dStruct = GetPostStruct();
  8935. List<string> lw = new List<string>();
  8936. string outsid = GetPostString("outsid");
  8937. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8938. string memo = GetPostString("memo");
  8939. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8940. string filename = GetPostString("filename");
  8941. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8942. string islate = GetPostString("islate");
  8943. if (islate.Length > 0)
  8944. {
  8945. if (islate == "1")
  8946. lw.Add(string.Format("OutLate>0"));
  8947. else
  8948. lw.Add(string.Format("OutLate=0"));
  8949. }
  8950. string placedate1 = GetPostString("placedate1");
  8951. string placedate2 = GetPostString("placedate2");
  8952. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8953. if (dw.Length > 0) lw.Add(dw);
  8954. string deliveryDate1 = GetPostString("deliverydate1");
  8955. string deliveryDate2 = GetPostString("deliverydate2");
  8956. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8957. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8958. dStruct.Order = "ID desc";
  8959. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8960. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8961. writeGridDataTableJson(dStruct.TotalCount, dt);
  8962. }
  8963. public void ins_erp_placeregist()
  8964. {
  8965. if (UrlPostParmsCheck("id"))
  8966. {
  8967. string eid = GetPostString("id");
  8968. CeErpPlaceRegister entity = null;
  8969. if (eid == "0")//新增
  8970. {
  8971. entity = new CeErpPlaceRegister();
  8972. string xdTime = GetPostString("placeTime");
  8973. if (xdTime.Length > 0)
  8974. {
  8975. entity.PlactTime = Convert.ToDateTime(xdTime);
  8976. }
  8977. string fhTime = GetPostString("deliveryTime");
  8978. if (fhTime.Length > 0)
  8979. {
  8980. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8981. }
  8982. string preTime = GetPostString("preOutTime");
  8983. if (preTime.Length > 0)
  8984. {
  8985. entity.PreOutTime = Convert.ToDateTime(preTime);
  8986. }
  8987. entity.DeliveryCount = GetPostInt("deliveryCount");
  8988. entity.ReceiveCount = GetPostInt("receiveCount");
  8989. entity.OutSid = GetPostString("outSid");
  8990. entity.FileName = GetPostString("fileName");
  8991. entity.Memo = GetPostString("memo");
  8992. entity.AddUserId = CurrentUser.UserID;
  8993. entity.CreateTime = DateTime.Now;
  8994. entity.Img = GetPostString("img");
  8995. entity.Supplier = GetPostInt("supplier");
  8996. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8997. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8998. {
  8999. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9000. DateTime dt2 = (DateTime)entity.PreOutTime;
  9001. TimeSpan span = dt1.Subtract(dt2);
  9002. if (span.Days > 0)
  9003. {
  9004. entity.OutLate = span.Days;
  9005. }
  9006. }
  9007. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9008. entity.Create();
  9009. returnSuccessMsg("添加成功!");
  9010. return;
  9011. }
  9012. else //修改
  9013. {
  9014. entity = CeErpPlaceRegister.Get(eid);
  9015. if (entity != null)
  9016. {
  9017. string xdTime = GetPostString("placeTime");
  9018. if (xdTime.Length > 0)
  9019. {
  9020. entity.PlactTime = Convert.ToDateTime(xdTime);
  9021. }
  9022. string fhTime = GetPostString("deliveryTime");
  9023. if (fhTime.Length > 0)
  9024. {
  9025. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9026. }
  9027. string preTime = GetPostString("preOutTime");
  9028. if (preTime.Length > 0)
  9029. {
  9030. entity.PreOutTime = Convert.ToDateTime(preTime);
  9031. }
  9032. entity.DeliveryCount = GetPostInt("deliveryCount");
  9033. entity.ReceiveCount = GetPostInt("receiveCount");
  9034. if (entity.DeliveryCount == entity.ReceiveCount)
  9035. {
  9036. entity.CurState = "已完成";
  9037. }
  9038. else
  9039. {
  9040. entity.CurState = "未完成";
  9041. }
  9042. entity.OutSid = GetPostString("outSid");
  9043. entity.FileName = GetPostString("fileName");
  9044. entity.Memo = GetPostString("memo");
  9045. entity.Img = GetPostString("img");
  9046. entity.Supplier = GetPostInt("supplier");
  9047. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9048. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9049. {
  9050. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9051. DateTime dt2 = (DateTime)entity.PreOutTime;
  9052. TimeSpan span = dt1.Subtract(dt2);
  9053. if (span.Days > 0)
  9054. {
  9055. entity.OutLate = span.Days;
  9056. }
  9057. }
  9058. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9059. entity.Update();
  9060. returnSuccessMsg("修改成功");
  9061. return;
  9062. }
  9063. returnErrorMsg("找不到对应的记录");
  9064. return;
  9065. }
  9066. }
  9067. returnErrorMsg("缺少必要参数");
  9068. }
  9069. public void del_erp_placeregist()
  9070. {
  9071. string eid = GetPostString("id");
  9072. CeErpPlaceRegister.Del(eid);
  9073. returnSuccessMsg("删除成功!");
  9074. return;
  9075. }
  9076. public void ins_erp_placeregistbyorder()
  9077. {
  9078. string ctid = GetPostString("ctid");
  9079. if (ctid.Length > 0)
  9080. {
  9081. StringBuilder sql = new StringBuilder();
  9082. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9083. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9084. if (dt.Rows.Count > 0)
  9085. {
  9086. foreach (DataRow dr in dt.Rows)
  9087. {
  9088. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9089. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9090. entity.AddUserId = CurrentUser.UserID;
  9091. entity.tid = dr["tid"].ToString();
  9092. entity.Did = Convert.ToString(dr["ctid"]);
  9093. entity.splitTag = dr["SplitTag"].ToString();
  9094. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9095. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9096. if (pre_ctid.Length > 0)
  9097. {
  9098. sellmemo = sellmemo.Replace(pre_ctid, "");
  9099. }
  9100. sellmemo = sellmemo.Replace("[", "");
  9101. sellmemo = sellmemo.Replace("]", "");
  9102. entity.FileName = sellmemo;
  9103. string count = dr["ProductCount"].ToString();
  9104. int usecount = commonHelper.getIntCountFromString(count);
  9105. entity.DeliveryCount = usecount;
  9106. entity.CurState = "未完成";
  9107. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9108. {
  9109. entity.Supplier = 24;//dl手提袋定制
  9110. }
  9111. else
  9112. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9113. entity.CreateTime = DateTime.Now;
  9114. entity.Create();
  9115. }
  9116. returnSuccessMsg("操作成功");
  9117. return;
  9118. }
  9119. returnErrorMsg("没有找到对应订单");
  9120. return;
  9121. }
  9122. returnErrorMsg("缺少订单编号");
  9123. return;
  9124. }
  9125. public void get_erp_persuadelist()
  9126. {
  9127. DataStruct dStruct = GetPostStruct();
  9128. List<string> lw = new List<string>();
  9129. string ctid = GetPostString("ctid");
  9130. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9131. string shopname = GetPostString("shopname");
  9132. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9133. string buyernick = GetPostString("buyer_nick");
  9134. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9135. string customer = GetPostString("customer");
  9136. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9137. string returndate1 = GetPostString("returndate1");
  9138. string returndate2 = GetPostString("returndate2");
  9139. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9140. if (dw.Length > 0) lw.Add(dw);
  9141. string finishDate1 = GetPostString("finishdate1");
  9142. string finishDate2 = GetPostString("finishdate2");
  9143. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9144. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9145. string persuadetype = GetPostString("persuadetype");
  9146. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9147. string returnvstate = GetPostString("returnvstate");
  9148. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9149. dStruct.Order = "created desc";
  9150. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9151. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9152. writeGridDataTableJson(dStruct.TotalCount, dt);
  9153. }
  9154. public void upd_erp_returnpersuadeback()
  9155. {
  9156. if (UrlPostParmsCheck("ID"))
  9157. {
  9158. int eid = GetPostInt("ID");
  9159. CeErpPersuade entity = null;
  9160. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9161. if (entity != null)
  9162. {
  9163. entity.backreason = GetPostString("reason");
  9164. entity.pstate = 2;
  9165. entity.verifytime = DateTime.Now;
  9166. entity.verifyuserid = CurrentUser.UserID;
  9167. entity.Update();
  9168. returnSuccessMsg("退回成功!");
  9169. return;
  9170. }
  9171. returnErrorMsg("找不到订单记录");
  9172. }
  9173. }
  9174. public void upd_erp_returnpersuadeverify()
  9175. {
  9176. if (UrlPostParmsCheck("ID"))
  9177. {
  9178. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9179. {
  9180. returnErrorMsg("暂无权限审核");
  9181. return;
  9182. }
  9183. int eid = GetPostInt("ID");
  9184. CeErpPersuade entity = null;
  9185. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9186. if (entity != null)
  9187. {
  9188. entity.pstate = 1;
  9189. entity.verifytime = DateTime.Now;
  9190. entity.verifyuserid = CurrentUser.UserID;
  9191. entity.Update();
  9192. returnSuccessMsg("审核成功!");
  9193. return;
  9194. }
  9195. returnErrorMsg("找不到订单记录");
  9196. }
  9197. }
  9198. public void del_erp_persuade()
  9199. {
  9200. if (UrlPostParmsCheck("ID"))
  9201. {
  9202. int eid = GetPostInt("ID");
  9203. CeErpPersuade.Del(eid);
  9204. returnSuccessMsg("操作成功");
  9205. return;
  9206. }
  9207. }
  9208. public void get_erp_oldcustoupload()
  9209. {
  9210. DataStruct dStruct = GetPostStruct();
  9211. List<string> lw = new List<string>();
  9212. string buyernick = GetPostString("buyer_nick");
  9213. if (buyernick.Length > 0)
  9214. {
  9215. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9216. }
  9217. else
  9218. return;
  9219. dStruct.Order = "pay_time desc";
  9220. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9221. DataTable dt = null;
  9222. dt = WebCache.GetData("view_erptradecell", dStruct);
  9223. writeGridDataTableJson(dStruct.TotalCount, dt);
  9224. }
  9225. public void get_erp_checkorderlist()
  9226. {
  9227. DataStruct dStruct = GetPostStruct();
  9228. List<string> lw = new List<string>();
  9229. string tid = GetPostString("ctid");
  9230. if (tid.Length > 0)
  9231. {
  9232. string select_tid = getTidByCtid(tid);
  9233. lw.Add(string.Format("tid='{0}'", select_tid));
  9234. }
  9235. string shopname = GetPostString("shopname");
  9236. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9237. string buyernick = GetPostString("buyer_nick");
  9238. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9239. string customer = GetPostString("customer");
  9240. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9241. string design = GetPostString("design");
  9242. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9243. string orderState = GetPostString("orderState");
  9244. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9245. string address = GetPostString("address");
  9246. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9247. string sellermemo = GetPostString("seller_memo");
  9248. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9249. string supplier = GetPostString("supplier");
  9250. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9251. {
  9252. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9253. }
  9254. else
  9255. {
  9256. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9257. }
  9258. string date1 = GetPostString("date1");
  9259. string date2 = GetPostString("date2");
  9260. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9261. if (dw.Length > 0) lw.Add(dw);
  9262. string placedate1 = GetPostString("placedate1");
  9263. string placedate2 = GetPostString("placedate2");
  9264. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9265. if (fdw.Length > 0) lw.Add(fdw);
  9266. string price1 = GetPostString("price1");
  9267. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9268. string price2 = GetPostString("price2");
  9269. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9270. string checkst = GetPostString("checkstate");
  9271. if (checkst.Length > 0 && "10".Equals(checkst))
  9272. {
  9273. lw.Add(string.Format("CheckOut>0"));
  9274. }
  9275. else
  9276. {
  9277. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9278. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9279. }
  9280. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9281. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9282. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9283. writeGridDataTableJson(dStruct.TotalCount, dt);
  9284. }
  9285. public void ins_erp_startCheck()
  9286. {
  9287. if (UrlPostParmsCheck("ctid"))
  9288. {
  9289. string eid = GetPostString("ctid");
  9290. CeErpTradeCell entity = null;
  9291. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9292. if (entity != null)
  9293. {
  9294. entity.MemoOpt = 4;
  9295. entity.UpdateTime = DateTime.Now;
  9296. entity.Update();
  9297. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9298. CeErpSukuraData.createInfo(entity.ctid, 6);
  9299. returnSuccessMsg("操作成功!");
  9300. return;
  9301. }
  9302. returnErrorMsg("找不到记录");
  9303. }
  9304. }
  9305. public void upd_erp_sendXlw()
  9306. {
  9307. if (UrlPostParmsCheck("ctid"))
  9308. {
  9309. string eid = GetPostString("ctid");
  9310. CeErpTradeCell entity = null;
  9311. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9312. if (entity != null)
  9313. {
  9314. if (entity.IsSendGift == 1)
  9315. {
  9316. returnErrorMsg("请勿重复标记");
  9317. return;
  9318. }
  9319. entity.IsSendGift = 1;
  9320. entity.Update();
  9321. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9322. returnSuccessMsg("操作成功!");
  9323. return;
  9324. }
  9325. returnErrorMsg("找不到记录");
  9326. }
  9327. }
  9328. public void cancel_sendXlw()
  9329. {
  9330. if (UrlPostParmsCheck("ctid"))
  9331. {
  9332. string eid = GetPostString("ctid");
  9333. CeErpTradeCell entity = null;
  9334. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9335. if (entity != null)
  9336. {
  9337. if (entity.IsSendGift == 0)
  9338. {
  9339. returnErrorMsg("未标记小礼物");
  9340. return;
  9341. }
  9342. entity.IsSendGift = 0;
  9343. entity.Update();
  9344. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9345. returnSuccessMsg("操作成功!");
  9346. return;
  9347. }
  9348. returnErrorMsg("找不到记录");
  9349. }
  9350. }
  9351. public void get_erp_designbill()
  9352. {
  9353. DataStruct dStruct = GetPostStruct();
  9354. List<string> lw = new List<string>();
  9355. int isMy = GetInt("my");
  9356. if (isMy == 1)
  9357. {
  9358. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9359. }
  9360. string tid = GetPostString("tid");
  9361. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9362. string userName = GetPostString("design");
  9363. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9364. string price1 = GetPostString("price1");
  9365. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9366. string price2 = GetPostString("price2");
  9367. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9368. string rePrice1 = GetPostString("rePrice1");
  9369. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9370. string rePrice2 = GetPostString("rePrice2");
  9371. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9372. string designerType = GetPostString("designerType");
  9373. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9374. string orderState = GetPostString("orderState");
  9375. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9376. string endTime1 = GetPostString("endTime1");
  9377. string endTime2 = GetPostString("endTime2");
  9378. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9379. if (dw.Length > 0) lw.Add(dw);
  9380. string isDk = GetPostString("isDk");
  9381. if (isDk == "1")
  9382. {
  9383. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9384. }
  9385. else if (isDk == "0")
  9386. {
  9387. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9388. }
  9389. dStruct.Order = "oid, create_time desc";
  9390. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9391. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9392. writeGridDataTableJson(dStruct.TotalCount, dt);
  9393. }
  9394. public void upd_erp_designerbill()
  9395. {
  9396. if (UrlPostParmsCheck("ID"))
  9397. {
  9398. string eid = GetPostString("ID");
  9399. CeErpDesignerBill entity = null;
  9400. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9401. if (entity != null)
  9402. {
  9403. if (GetPostDouble("designerpirce") > 0)
  9404. {
  9405. entity.realPrice = GetPostDouble("designerpirce");
  9406. entity.update_time = DateTime.Now;
  9407. entity.update_u_id = CurrentUser.UserID;
  9408. entity.update_u_name = CurrentUser.UserName;
  9409. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9410. entity.Update();
  9411. returnSuccessMsg("操作成功!");
  9412. return;
  9413. }
  9414. else
  9415. {
  9416. entity.price = GetPostDouble("price");
  9417. entity.update_time = DateTime.Now;
  9418. entity.update_u_id = CurrentUser.UserID;
  9419. entity.update_u_name = CurrentUser.UserName;
  9420. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9421. entity.Update();
  9422. returnSuccessMsg("操作成功!");
  9423. return;
  9424. }
  9425. }
  9426. returnErrorMsg("找不到记录");
  9427. }
  9428. }
  9429. public void audit_erp_designerbill()
  9430. {
  9431. if (UrlPostParmsCheck("ID"))
  9432. {
  9433. string eid = GetPostString("ID");
  9434. CeErpDesignerBill entity = null;
  9435. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9436. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9437. if (entity != null)
  9438. {
  9439. entity.realPrice = GetPostDouble("designerpirce");
  9440. entity.update_time = DateTime.Now;
  9441. entity.update_u_id = CurrentUser.UserID;
  9442. entity.update_u_name = CurrentUser.UserName;
  9443. entity.isAudit = 1;
  9444. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9445. entity.Update();
  9446. if (orderEntity != null)
  9447. {
  9448. orderEntity.IsReadTag = 3;
  9449. orderEntity.Update();
  9450. }
  9451. returnSuccessMsg("操作成功!");
  9452. return;
  9453. }
  9454. returnErrorMsg("找不到记录");
  9455. }
  9456. }
  9457. public void all_audit_erp_designerbill()
  9458. {
  9459. if (UrlPostParmsCheck("idList"))
  9460. {
  9461. string[] list = GetPostString("idList").Split(',');
  9462. CeErpDesignerBill entity = null;
  9463. for (int i = 0; i < list.Length; i++)
  9464. {
  9465. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9466. if (entity == null) return;
  9467. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9468. if (orderEntity == null) return;
  9469. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9470. entity.update_time = DateTime.Now;
  9471. entity.update_u_id = CurrentUser.UserID;
  9472. entity.update_u_name = CurrentUser.UserName;
  9473. entity.isAudit = 1;
  9474. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9475. entity.Update();
  9476. orderEntity.IsReadTag = 3;
  9477. orderEntity.Update();
  9478. }
  9479. returnSuccessMsg("操作成功!");
  9480. return;
  9481. }
  9482. }
  9483. public void get_erp_sameorders()
  9484. {
  9485. if (UrlPostParmsCheck("ctid"))
  9486. {
  9487. string eid = GetPostString("ctid");
  9488. CeErpTradeCell entity = null;
  9489. entity = CeErpTradeCell.GetByCtid(eid);
  9490. if (entity != null)
  9491. {
  9492. StringBuilder sql = new StringBuilder();
  9493. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9494. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9495. var res = new
  9496. {
  9497. data = dt.Rows.Count
  9498. };
  9499. string ro_jsond = JsonConvert.SerializeObject(res);
  9500. returnSuccess(ro_jsond);
  9501. return;
  9502. }
  9503. returnErrorMsg("未找到订单");
  9504. return;
  9505. }
  9506. returnErrorMsg("缺少必要的参数");
  9507. }
  9508. public void get_erp_islasthavesameorder()
  9509. {
  9510. if (UrlPostParmsCheck("ctid"))
  9511. {
  9512. string eid = GetPostString("ctid");
  9513. string[] ctidList = eid.Split(',');
  9514. StringBuilder sql = new StringBuilder();
  9515. string tisCtid = "";
  9516. foreach (string ctid in ctidList)
  9517. {
  9518. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9519. if (entity != null)
  9520. {
  9521. sql = new StringBuilder();
  9522. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9523. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9524. if (dth.Rows.Count > 0)
  9525. {
  9526. tisCtid += entity.ctid;
  9527. tisCtid += ",";
  9528. }
  9529. }
  9530. }
  9531. if (tisCtid.Length > 0)
  9532. {
  9533. var res = new
  9534. {
  9535. data = tisCtid
  9536. };
  9537. string ro_jsond = JsonConvert.SerializeObject(res);
  9538. returnSuccess(ro_jsond);
  9539. }
  9540. else
  9541. {
  9542. var res = new
  9543. {
  9544. data = ""
  9545. };
  9546. string ro_jsond = JsonConvert.SerializeObject(res);
  9547. returnSuccess(ro_jsond);
  9548. }
  9549. return;
  9550. }
  9551. returnErrorMsg("缺少必要的参数");
  9552. }
  9553. public void file_client_down_url()
  9554. {
  9555. if (!UrlPostParmsCheck("userId"))
  9556. {
  9557. returnErrorMsg("缺少必要的参数");
  9558. }
  9559. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9560. }
  9561. public void checkout_form_data()
  9562. {
  9563. if (!UrlPostParmsCheck("tid"))
  9564. {
  9565. returnErrorMsg("缺少必要的参数");
  9566. }
  9567. string tid = GetPostString("tid");
  9568. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9569. if (ceErpOrderFormData != null)
  9570. {
  9571. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9572. returnSuccess(ro_jsond);
  9573. return;
  9574. }
  9575. returnErrorMsg("尚未有文件!");
  9576. }
  9577. public void back_supplier_audit()
  9578. {
  9579. int userId = CurrentUser.UserID;
  9580. StringBuilder sql = new StringBuilder();
  9581. 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);
  9582. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9583. if (dt.Rows.Count > 0)
  9584. {
  9585. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9586. }
  9587. else
  9588. {
  9589. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9590. }
  9591. }
  9592. public void back_supplier_query()
  9593. {
  9594. string eid = GetPostString("ctid");
  9595. if (eid != "")
  9596. {
  9597. StringBuilder sql = new StringBuilder();
  9598. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9599. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9600. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9601. }
  9602. else
  9603. {
  9604. returnErrorMsg("找不到订单记录");
  9605. return;
  9606. }
  9607. }
  9608. public void verified_to_order()
  9609. {
  9610. int userId = CurrentUser.UserID;
  9611. StringBuilder sql = new StringBuilder();
  9612. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9613. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9614. if (dt.Rows.Count > 0)
  9615. {
  9616. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9617. }
  9618. else
  9619. {
  9620. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9621. }
  9622. }
  9623. public void upd_supplier_audit()
  9624. {
  9625. if (UrlPostParmsCheck("ctid"))
  9626. {
  9627. string eid = GetPostString("ctid");
  9628. string reason = GetPostString("returnreason");
  9629. CeErpTradeCell entity = null;
  9630. CeWithdraw withdraw = null;
  9631. withdraw = CeWithdraw.GetByTid(eid);
  9632. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9633. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9634. {
  9635. if (withdraw != null)
  9636. {
  9637. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9638. {
  9639. returnSuccessMsg("您没有权限操作!");
  9640. return;
  9641. }
  9642. else
  9643. {
  9644. if (reason.Equals("1"))
  9645. {
  9646. if (entity.OrderState == -1)
  9647. {
  9648. if (entity.FinishPlaceTime == null)
  9649. {
  9650. entity.OrderState = 2;
  9651. }
  9652. else
  9653. {
  9654. entity.OrderState = 6;
  9655. }
  9656. }
  9657. entity.Update();
  9658. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9659. if (withdraw != null)
  9660. {
  9661. withdraw.status = int.Parse(reason);
  9662. withdraw.Update();
  9663. }
  9664. returnSuccessMsg("操作成功!");
  9665. return;
  9666. }
  9667. else
  9668. {
  9669. withdraw.status = int.Parse(reason);
  9670. withdraw.acknowledgingtime = DateTime.Now;
  9671. withdraw.Update();
  9672. returnSuccessMsg("查看详细请点击线下订单查询");
  9673. return;
  9674. }
  9675. }
  9676. }
  9677. // 第一个字符是 'N'
  9678. }
  9679. if (eid[0] != 'N')
  9680. {
  9681. }
  9682. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9683. {
  9684. entity.IsVerifyToSupplier = false;
  9685. entity.IsReturn = 1;
  9686. entity.ReturnTime = DateTime.Now;
  9687. entity.ReturnReason = reason;
  9688. if (entity.OrderState == 6)
  9689. {
  9690. entity.OrderState = 5;
  9691. }
  9692. entity.Update();
  9693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9694. if (withdraw != null)
  9695. {
  9696. withdraw.status = int.Parse(reason);
  9697. withdraw.Update();
  9698. }
  9699. returnSuccessMsg("操作成功!");
  9700. return;
  9701. }
  9702. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9703. {
  9704. ;
  9705. if (withdraw != null)
  9706. {
  9707. withdraw.status = int.Parse(reason);
  9708. withdraw.acknowledgingtime = DateTime.Now;
  9709. withdraw.Update();
  9710. returnSuccessMsg("供应商取消撤回!");
  9711. return;
  9712. }
  9713. }
  9714. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9715. {
  9716. if (entity.OrderState == -1)
  9717. {
  9718. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9719. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id))
  9720. {
  9721. returnErrorMsg("订单spu没有确认无法通过审核!");
  9722. return;
  9723. }
  9724. if (entity.FinishPlaceTime == null)
  9725. {
  9726. entity.OrderState = 2;
  9727. }
  9728. else
  9729. {
  9730. entity.OrderState = 3;
  9731. }
  9732. commonHelper.getCytPrice(entity);
  9733. }
  9734. entity.Update();
  9735. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9736. if (withdraw != null)
  9737. {
  9738. withdraw.status = int.Parse(reason);
  9739. withdraw.Update();
  9740. }
  9741. returnSuccessMsg("操作成功!");
  9742. return;
  9743. }
  9744. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9745. {
  9746. if (withdraw == null)
  9747. {
  9748. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9749. return;
  9750. }
  9751. }
  9752. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9753. {
  9754. if (withdraw != null)
  9755. {
  9756. withdraw.status = int.Parse(reason);
  9757. withdraw.acknowledgingtime = DateTime.Now;
  9758. withdraw.Update();
  9759. returnSuccessMsg("查看详细请点击线下订单查询");
  9760. return;
  9761. }
  9762. }
  9763. return;
  9764. }
  9765. }
  9766. //校验报价
  9767. public void refund_order_tip()
  9768. {
  9769. int userid = CurrentUser.UserID;
  9770. int sectionId = CurrentUser.UserPost.OrgID;
  9771. StringBuilder sql = new StringBuilder();
  9772. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9773. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9774. List<string> ids = new List<string>();
  9775. if (dth.Rows.Count > 0)
  9776. {
  9777. foreach (DataRow dr in dth.Rows)
  9778. {
  9779. ids.Add(dr["ID"].ToString());
  9780. }
  9781. try
  9782. {
  9783. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9784. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9785. }
  9786. catch (Exception ex)
  9787. {
  9788. }
  9789. }
  9790. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9791. }
  9792. public void refund_order_Design()
  9793. {
  9794. int userid = CurrentUser.UserID;
  9795. int sectionId = CurrentUser.UserPost.OrgID;
  9796. StringBuilder sql = new StringBuilder();
  9797. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9798. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9799. List<string> ids = new List<string>();
  9800. if (dth.Rows.Count > 0)
  9801. {
  9802. foreach (DataRow dr in dth.Rows)
  9803. {
  9804. ids.Add(dr["ID"].ToString());
  9805. }
  9806. try
  9807. {
  9808. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9809. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9810. }
  9811. catch (Exception ex)
  9812. {
  9813. }
  9814. }
  9815. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9816. }
  9817. public void change_order_info()
  9818. {
  9819. int userid = CurrentUser.UserID;
  9820. StringBuilder sql = new StringBuilder();
  9821. 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);
  9822. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9823. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9824. }
  9825. public void change_win_mome()
  9826. {
  9827. if (UrlPostParmsCheck("id,ctid"))
  9828. {
  9829. string id = GetPostString("id");
  9830. string ctid = GetPostString("ctid");
  9831. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9832. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9833. if (ce == null || ceErpMessageTip == null)
  9834. {
  9835. returnSuccessMsg("未找到对应的订单!");
  9836. return;
  9837. }
  9838. if (ce.OrderState >= 5)
  9839. {
  9840. returnSuccessMsg("已上传文件无法修改!");
  9841. return;
  9842. }
  9843. int type = GetPostInt("type");
  9844. string content = GetPostString("content");
  9845. if (type == 0)
  9846. {
  9847. content = content.Replace("(", "(");
  9848. content = content.Replace(")", ")");
  9849. string check = MidStrEx(content, "(", ")").Trim();
  9850. if (string.IsNullOrEmpty(check))
  9851. {
  9852. returnSuccessMsg("文件名格式不正确");
  9853. return;
  9854. }
  9855. }
  9856. ce.seller_memo = content;
  9857. ce.Update();
  9858. ceErpMessageTip.isVisit = true;
  9859. ceErpMessageTip.Update();
  9860. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9861. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9862. ApiVo apiVo = new ApiVo();
  9863. apiVo.orderNumber = ce.ctid;
  9864. apiVo.actionName = "demandDesign";
  9865. apiVo.orderRemarks = content;
  9866. apiVo.demandExamine = type + 1;
  9867. designHelper.API_WorkCore(apiVo);//demandDesign
  9868. returnSuccessMsg("修改成功!");
  9869. }
  9870. }
  9871. public static string MidStrEx(string sourse, string startstr, string endstr)
  9872. {
  9873. string result = string.Empty;
  9874. int startindex, endindex;
  9875. try
  9876. {
  9877. startindex = sourse.IndexOf(startstr);
  9878. if (startindex == -1)
  9879. return result;
  9880. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9881. endindex = tmpstr.IndexOf(endstr);
  9882. if (endindex == -1)
  9883. return result;
  9884. result = tmpstr.Remove(endindex);
  9885. }
  9886. catch (Exception ex)
  9887. {
  9888. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9889. }
  9890. return result;
  9891. }
  9892. public void refund_order_list()
  9893. {
  9894. int userid = CurrentUser.UserID;
  9895. int sectionId = CurrentUser.UserPost.OrgID;
  9896. StringBuilder sql = new StringBuilder();
  9897. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9898. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9899. DataStruct dStruct = GetPostStruct();
  9900. DataTable dt = null;
  9901. List<string> ids = new List<string>();
  9902. List<string> tids = new List<string>();
  9903. if (dth.Rows.Count > 0)
  9904. {
  9905. foreach (DataRow dr in dth.Rows)
  9906. {
  9907. tids.Add("'" + dr["tid"].ToString() + "'");
  9908. ids.Add(dr["id"].ToString());
  9909. }
  9910. try
  9911. {
  9912. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9913. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9914. List<string> lw = new List<string>();
  9915. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9916. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9917. dt = WebCache.GetData("view_orderlist", dStruct);
  9918. }
  9919. catch (Exception ex)
  9920. {
  9921. }
  9922. }
  9923. writeGridDataTableJson(dStruct.TotalCount, dt);
  9924. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9925. }
  9926. //新增
  9927. public void order_batch_downloads()
  9928. {
  9929. string ceid = GetPostString("tid");
  9930. String[] tid = ceid.Split(',');
  9931. order_batch_caiyingtong(tid);
  9932. /* (string success, string errors) = UploadFiles(tid);
  9933. returnSuccessMsg(success + errors);*/
  9934. return;
  9935. }
  9936. //报价接口
  9937. public void Get_To_Quote()
  9938. {
  9939. string ceid = GetPostString("ctid");
  9940. if (ceid != null)
  9941. {
  9942. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9943. if (entity != null)
  9944. {
  9945. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9946. {
  9947. return;
  9948. }
  9949. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9950. double price = 0;
  9951. if (cp == null)
  9952. {
  9953. JObject jsonObject12 = new JObject
  9954. {
  9955. { "UserId", "77886" },
  9956. { "Pwd", "lt666888" },
  9957. { "Filename", entity.seller_memo }
  9958. };
  9959. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9960. JObject jsonObjects1 = JObject.Parse(response1);
  9961. string ms1g = (string)jsonObjects1["msg"];
  9962. if (ms1g == "报价成功")
  9963. {
  9964. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9965. string data = (string)jsonObject1["price"];
  9966. 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 + "');";
  9967. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9968. returnSuccessMsg("获取报价成功:" + data);
  9969. price = Convert.ToDouble(data);
  9970. }
  9971. else
  9972. {
  9973. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9974. return;
  9975. }
  9976. }
  9977. String[] beizhu = entity.seller_memo.Split('-');
  9978. String chanp = "";
  9979. if (beizhu.Length > 0)
  9980. {
  9981. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9982. }
  9983. else
  9984. {
  9985. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9986. }
  9987. JObject jsonObject = new JObject
  9988. {
  9989. { "UserId", "77886" },
  9990. { "Pwd", "lt666888" },
  9991. { "Filename", chanp }
  9992. };
  9993. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9994. JObject jsonObjects = JObject.Parse(response);
  9995. string msg = (string)jsonObjects["msg"];
  9996. if (msg == "报价成功")
  9997. {
  9998. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9999. string data = (string)jsonObject1["price"];
  10000. 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 + "');";
  10001. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10002. returnSuccessMsg("获取报价成功:" + data);
  10003. price = Convert.ToDouble(data);
  10004. }
  10005. else
  10006. {
  10007. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10008. return;
  10009. }
  10010. if (price > 0)
  10011. {
  10012. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10013. if (ceErpTradeCellExtend == null)
  10014. {
  10015. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10016. ceErpTradeCellExtend.ctid = entity.ctid;
  10017. ceErpTradeCellExtend.payment_cyt = price;
  10018. ceErpTradeCellExtend.Create();
  10019. }
  10020. else
  10021. {
  10022. ceErpTradeCellExtend.payment_cyt = price;
  10023. ceErpTradeCellExtend.Update();
  10024. }
  10025. }
  10026. return;
  10027. }
  10028. }
  10029. else
  10030. {
  10031. returnErrorMsg("请至少选择一条数据");
  10032. return;
  10033. }
  10034. }
  10035. //新增
  10036. public void order_To_Supplier()
  10037. {
  10038. string ceid = GetPostString("tid");
  10039. String[] tid = ceid.Split(',');
  10040. if (tid.Length > 0)
  10041. {
  10042. try
  10043. {
  10044. for (int i = 0; i < tid.Length; i++)
  10045. {
  10046. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10047. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10048. entity.SupplierId = suid;
  10049. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10050. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10051. entity.Update();
  10052. }
  10053. }
  10054. catch (Exception ex)
  10055. {
  10056. returnErrorMsg("自动匹配供应商失败");
  10057. return;
  10058. }
  10059. }
  10060. else
  10061. {
  10062. returnErrorMsg("请至少选择一条数据");
  10063. return;
  10064. }
  10065. returnSuccessMsg("自动匹配供应商成功");
  10066. return;
  10067. }
  10068. public (string, string) UploadFiles(string[] urls)
  10069. {
  10070. string success = "";
  10071. string errors = "";
  10072. int userid = CurrentUser.UserID;
  10073. foreach (string url in urls)
  10074. {
  10075. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10076. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10077. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10078. {
  10079. JObject jsonObject = new JObject
  10080. {
  10081. { "Userid", "77886" },
  10082. { "pwd", "cyt86435015" },
  10083. { "content", base64FileContent },
  10084. { "ext", Path.GetExtension(fileName) }
  10085. };
  10086. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10087. JObject jsonObjects = JObject.Parse(response);
  10088. string msg = (string)jsonObjects["msg"];
  10089. if (msg.Equals("上传成功"))
  10090. {
  10091. success += url + " 上传成功";
  10092. }
  10093. else
  10094. {
  10095. errors += url + " 上传失败";
  10096. }
  10097. }
  10098. else
  10099. {
  10100. errors += url + " 格式出现问题";
  10101. }
  10102. }
  10103. if (urls.Length == 0)
  10104. {
  10105. return (success, errors);
  10106. }
  10107. return (success, errors);
  10108. }
  10109. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10110. {
  10111. return true; //总是接受
  10112. }
  10113. public static string HttpPost(string url, string param = null)
  10114. {
  10115. HttpWebRequest request;
  10116. //如果是发送HTTPS请求
  10117. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10118. {
  10119. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10120. request = WebRequest.Create(url) as HttpWebRequest;
  10121. request.ProtocolVersion = HttpVersion.Version10;
  10122. }
  10123. else
  10124. {
  10125. request = WebRequest.Create(url) as HttpWebRequest;
  10126. }
  10127. request.Method = "POST";
  10128. request.ContentType = "application/json";
  10129. request.Accept = "*/*";
  10130. request.Timeout = 120000;
  10131. request.AllowAutoRedirect = false;
  10132. StreamWriter requestStream = null;
  10133. WebResponse response = null;
  10134. string responseStr = null;
  10135. try
  10136. {
  10137. requestStream = new StreamWriter(request.GetRequestStream());
  10138. requestStream.Write(param);
  10139. requestStream.Close();
  10140. response = request.GetResponse();
  10141. if (response != null)
  10142. {
  10143. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10144. responseStr = reader.ReadToEnd();
  10145. reader.Close();
  10146. }
  10147. }
  10148. catch (Exception ex)
  10149. {
  10150. return ex.Message;
  10151. }
  10152. finally
  10153. {
  10154. request = null;
  10155. requestStream = null;
  10156. response = null;
  10157. }
  10158. return responseStr;
  10159. }
  10160. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10161. {
  10162. string base64FileContent;
  10163. string fileName;
  10164. using (WebClient webClient = new WebClient())
  10165. {
  10166. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10167. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10168. {
  10169. using (Stream stream = response.GetResponseStream())
  10170. {
  10171. using (MemoryStream memoryStream = new MemoryStream())
  10172. {
  10173. stream.CopyTo(memoryStream);
  10174. byte[] fileBytes = memoryStream.ToArray();
  10175. base64FileContent = Convert.ToBase64String(fileBytes);
  10176. fileName = response.Headers["Content-Disposition"];
  10177. if (!string.IsNullOrEmpty(fileName))
  10178. {
  10179. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10180. if (index >= 0)
  10181. {
  10182. fileName = fileName.Substring(index + 9).Trim('\"');
  10183. }
  10184. }
  10185. else
  10186. {
  10187. fileName = Path.GetFileName(downloadUrl);
  10188. }
  10189. }
  10190. }
  10191. }
  10192. }
  10193. return (fileName, base64FileContent);
  10194. }
  10195. //新增
  10196. public void order_batch_caiyingtong(string[] downloadUrls)
  10197. {
  10198. try
  10199. {
  10200. //遍历文件
  10201. DataStruct dStruct = GetPostStruct();
  10202. DataTable dt = null;
  10203. int userid = CurrentUser.UserID;
  10204. List<string> ids = new List<string>();//失败组
  10205. List<string> tids = new List<string>();
  10206. using (WebClient webClient = new WebClient())
  10207. {
  10208. foreach (var url in downloadUrls)
  10209. {
  10210. try
  10211. {
  10212. tids.Add("'" + url + "'");
  10213. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10214. if (entity != null)
  10215. {
  10216. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10217. if (cp == null)
  10218. {
  10219. JObject jsonObject = new JObject
  10220. {
  10221. { "Userid", "77886" },
  10222. { "pwd", "lt666888" },
  10223. { "Filename",entity.seller_memo }
  10224. };
  10225. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10226. JObject jsonObjects = JObject.Parse(response);
  10227. string msg = (string)jsonObjects["msg"];
  10228. if (msg == "报价成功")
  10229. {
  10230. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10231. DownloadAndConvertToBase64(url1);
  10232. }
  10233. else
  10234. {
  10235. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10236. }
  10237. }
  10238. else
  10239. {
  10240. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10241. JObject jsonObject = new JObject
  10242. {
  10243. { "Userid", "77886" },
  10244. { "pwd", "lt666888" },
  10245. { "Filename",chanp }
  10246. };
  10247. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10248. JObject jsonObjects = JObject.Parse(response);
  10249. string msg = (string)jsonObjects["msg"];
  10250. if (msg == "报价成功")
  10251. {
  10252. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10253. DownloadAndConvertToBase64(url1);
  10254. }
  10255. else
  10256. {
  10257. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10258. }
  10259. }
  10260. }
  10261. // 上传文件到FTP
  10262. }
  10263. catch (Exception ex)
  10264. {
  10265. Console.WriteLine($"An error occurred: {ex.Message}");
  10266. }
  10267. }
  10268. List<string> lw = new List<string>();
  10269. lw.Add(string.Format("( OrderState < 6 )"));
  10270. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10271. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10272. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10273. if (dt.Rows.Count > 0)
  10274. {
  10275. foreach (DataRow dr in dt.Rows)
  10276. {
  10277. ids.Add(dr["ctid"].ToString());
  10278. }
  10279. }
  10280. String ErrorMsgs = "";
  10281. foreach (String id in ids)
  10282. {
  10283. ErrorMsgs += id + ",";
  10284. }
  10285. if (ErrorMsgs.Length > 1)
  10286. {
  10287. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10288. }
  10289. if (ErrorMsgs.Length < 1)
  10290. {
  10291. ErrorMsgs = "上传成功";
  10292. returnSuccessMsg(ErrorMsgs);
  10293. }
  10294. else
  10295. {
  10296. returnErrorMsg("以下订单" + ErrorMsgs);
  10297. }
  10298. }
  10299. // 删除文件夹及其内容
  10300. /* Directory.Delete(localDirectory, true);*/
  10301. }
  10302. catch { }
  10303. }
  10304. public void get_center_data()
  10305. {
  10306. int userId = CurrentUser.UserID;
  10307. string postCode = CurrentUser.UserPost.Post.Code;
  10308. List<string> lw = new List<string>();
  10309. List<string> ww = new List<string>();
  10310. DateTime currentTime = DateTime.Now;
  10311. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10312. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10313. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10314. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10315. string sql = " SELECT ";
  10316. string startTime = "2023-10-01 11:22:31";
  10317. //设计
  10318. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10319. {
  10320. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10321. 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));
  10322. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10323. 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));
  10324. }
  10325. //客服
  10326. else if (postCode == "CustomerService" || postCode == "Director")
  10327. {
  10328. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10329. 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));
  10330. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10331. 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));
  10332. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10333. 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));
  10334. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10335. 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));
  10336. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10337. 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));
  10338. }
  10339. //售后
  10340. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10341. {
  10342. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10343. 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));
  10344. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10345. 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));
  10346. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10347. 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));
  10348. }
  10349. //下单部
  10350. else if (postCode == "Place" || postCode == "PlaceMr")
  10351. {
  10352. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10353. 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));
  10354. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10355. 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));
  10356. }
  10357. //车间
  10358. else if (postCode == "Supplier")
  10359. {
  10360. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10361. 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));
  10362. }
  10363. DataTable dt = new DataTable();
  10364. if (lw.Count > 0)
  10365. {
  10366. sql += string.Join(" , ", lw);
  10367. sql += " FROM ";
  10368. sql += string.Join(" , ", ww);
  10369. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10370. }
  10371. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10372. }
  10373. public void get_center_data_list()
  10374. {
  10375. int userId = CurrentUser.UserID;
  10376. string postCode = CurrentUser.UserPost.Post.Code;
  10377. string shopIds = CurrentUser.User.pemShop;
  10378. DataStruct dStruct = GetPostStruct();
  10379. List<string> lw = new List<string>();
  10380. DateTime currentTime = DateTime.Now;
  10381. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10382. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10383. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10384. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10385. string startTime = "2023-10-01 11:22:31";
  10386. int order_type = GetPostInt("order_type");
  10387. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10388. {
  10389. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10390. if (order_type == 0)
  10391. {
  10392. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10393. }
  10394. else if (order_type == 3)
  10395. {
  10396. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10397. }
  10398. else
  10399. {
  10400. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10401. }
  10402. }
  10403. //客服
  10404. if (postCode == "CustomerService" || postCode == "Director")
  10405. {
  10406. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10407. if (order_type == 0)
  10408. {
  10409. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10410. }
  10411. else if (order_type == 1)
  10412. {
  10413. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10414. }
  10415. else if (order_type == 2)
  10416. {
  10417. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10418. }
  10419. else if (order_type == 3)
  10420. {
  10421. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10422. }
  10423. else if (order_type == 4)
  10424. {
  10425. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10426. }
  10427. else
  10428. {
  10429. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10430. }
  10431. }
  10432. //售后
  10433. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10434. {
  10435. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10436. if (shopIds != "")
  10437. {
  10438. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10439. }
  10440. if (order_type == 2)
  10441. {
  10442. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10443. }
  10444. else if (order_type == 4)
  10445. {
  10446. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10447. }
  10448. else if (order_type == 5)
  10449. {
  10450. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10451. }
  10452. else
  10453. {
  10454. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10455. }
  10456. }
  10457. //下单部
  10458. if (postCode == "Place" || postCode == "PlaceMr")
  10459. {
  10460. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10461. if (shopIds != "")
  10462. {
  10463. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10464. }
  10465. else if (order_type == 1)
  10466. {
  10467. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10468. }
  10469. else if (order_type == 2)
  10470. {
  10471. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10472. }
  10473. else
  10474. {
  10475. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10476. }
  10477. }
  10478. //车间
  10479. if (postCode == "Supplier")
  10480. {
  10481. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10482. if (order_type == 5)
  10483. {
  10484. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10485. }
  10486. else
  10487. {
  10488. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10489. }
  10490. }
  10491. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10492. dStruct.Fileds = "tid,ctid";
  10493. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10494. writeGridDataTableJson(dStruct.TotalCount, dt);
  10495. }
  10496. public void aftersale_audit_master()
  10497. {
  10498. if (UrlPostParmsCheck("ctid"))
  10499. {
  10500. string ctid = GetPostString("ctid");
  10501. if (ctid.Length > 0)
  10502. {
  10503. bool result = aftersale_data_change(ctid);
  10504. if (result)
  10505. {
  10506. returnSuccessMsg("修改成功!");
  10507. return;
  10508. }
  10509. }
  10510. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10511. }
  10512. }
  10513. public void aftersale_batch_audit_master()
  10514. {
  10515. if (UrlPostParmsCheck("ctids"))
  10516. {
  10517. string ctids = GetPostString("ctids");
  10518. if (ctids.Length > 0)
  10519. {
  10520. List<string> list = new List<string>();
  10521. string[] ctid_list = ctids.Split(',');
  10522. foreach (var item in ctid_list)
  10523. {
  10524. bool result = aftersale_data_change(item);
  10525. if (!result)
  10526. {
  10527. list.Add(item);
  10528. }
  10529. }
  10530. if (list.Count > 0)
  10531. {
  10532. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10533. return;
  10534. }
  10535. returnSuccessMsg("修改成功!");
  10536. return;
  10537. }
  10538. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10539. }
  10540. }
  10541. public bool aftersale_data_change(string ctid)
  10542. {
  10543. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10544. if (ceErpTradeCell != null)
  10545. {
  10546. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10547. ceErpTradeCell.AfterSaleSupplierState = 0;
  10548. StringBuilder sql = new StringBuilder();
  10549. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10550. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10551. CeErpTradeResponsible.DelByTid(ctid, 0);
  10552. 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 == "不理赔")
  10553. {
  10554. CeErpTradeResponsible.DelByTid(ctid, 1);
  10555. ceErpTradeCell.AfterSaleSupplierState = 1;
  10556. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10557. ceErpTradeCell.AfterSaleState = 4;
  10558. }
  10559. else
  10560. {
  10561. ceErpTradeCell.AfterSaleState = 3;
  10562. }
  10563. bool needCyt = false;
  10564. if (dt != null)
  10565. {
  10566. if (dt.Rows.Count == 1)
  10567. {
  10568. bool isEnd = false;
  10569. foreach (DataRow dr in dt.Rows)
  10570. {
  10571. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10572. {
  10573. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10574. isEnd = true;
  10575. }
  10576. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10577. {
  10578. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10579. isEnd = true;
  10580. }
  10581. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10582. {
  10583. needCyt = true;
  10584. }
  10585. }
  10586. if (isEnd)
  10587. {
  10588. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10589. ceErpTradeCell.AfterSaleState = 4;
  10590. ceErpTradeCell.AfterSaleSupplierState = 1;
  10591. }
  10592. }
  10593. else
  10594. {
  10595. bool isAll = true;
  10596. foreach (DataRow dr in dt.Rows)
  10597. {
  10598. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10599. {
  10600. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10601. continue;
  10602. }
  10603. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10604. {
  10605. string path = "";
  10606. int OrgID = 0;
  10607. if (!Convert.IsDBNull(dr["OrgPath"]))
  10608. {
  10609. path = dr["OrgPath"].ToString();
  10610. }
  10611. if (!Convert.IsDBNull(dr["OrgID"]))
  10612. {
  10613. OrgID = Convert.ToInt32(dr["OrgID"]);
  10614. }
  10615. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10616. {
  10617. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10618. continue;
  10619. }
  10620. }
  10621. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10622. {
  10623. needCyt = true;
  10624. }
  10625. isAll = false;
  10626. }
  10627. if (isAll)
  10628. {
  10629. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10630. ceErpTradeCell.AfterSaleState = 4;
  10631. ceErpTradeCell.AfterSaleSupplierState = 1;
  10632. }
  10633. }
  10634. }
  10635. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10636. {
  10637. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10638. }
  10639. if (ceErpTradeCell.AfterSaleState == 4)
  10640. {
  10641. ApiVo apiVo = new ApiVo();
  10642. apiVo.orderNumber = ceErpTradeCell.ctid;
  10643. apiVo.actionName = "afterOver";
  10644. designHelper.API_WorkCore(apiVo); //afterOver
  10645. }
  10646. ceErpTradeCell.Update();
  10647. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10648. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10649. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10650. return true;
  10651. }
  10652. return false;
  10653. }
  10654. public void get_erp_wechatorder()
  10655. {
  10656. DataStruct dStruct = GetPostStruct();
  10657. List<string> lw = new List<string>();
  10658. string tid = GetPostString("tid");
  10659. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10660. string shopname = GetPostString("shopname");
  10661. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10662. string buyernick = GetPostString("buyer_nick");
  10663. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10664. string customer = GetPostString("customer");
  10665. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10666. string returndate1 = GetPostString("returndate1");
  10667. string returndate2 = GetPostString("returndate2");
  10668. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10669. if (dw.Length > 0) lw.Add(dw);
  10670. string finishDate1 = GetPostString("finishdate1");
  10671. string finishDate2 = GetPostString("finishdate2");
  10672. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10673. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10674. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10675. dStruct.Order = "created desc";
  10676. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10677. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10678. writeGridDataTableJson(dStruct.TotalCount, dt);
  10679. }
  10680. public void get_erp_wechatlist_sumprice()
  10681. {
  10682. DataStruct dStruct = GetPostStruct();
  10683. List<string> lw = new List<string>();
  10684. string tid = GetPostString("tid");
  10685. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10686. string shopname = GetPostString("shopname");
  10687. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10688. string buyernick = GetPostString("buyer_nick");
  10689. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10690. string customer = GetPostString("customer");
  10691. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10692. string returndate1 = GetPostString("returndate1");
  10693. string returndate2 = GetPostString("returndate2");
  10694. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10695. if (dw.Length > 0) lw.Add(dw);
  10696. string finishDate1 = GetPostString("finishdate1");
  10697. string finishDate2 = GetPostString("finishdate2");
  10698. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10699. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10700. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10701. string mainWhere = string.Join(" and ", lw.ToArray());
  10702. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10703. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10704. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10705. decimal total = 0;
  10706. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10707. {
  10708. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10709. }
  10710. var res = new
  10711. {
  10712. data = total
  10713. };
  10714. string ro_jsond = JsonConvert.SerializeObject(res);
  10715. returnSuccess(ro_jsond);
  10716. return;
  10717. }
  10718. public void get_erp_qr_waitdeliverylist()
  10719. {
  10720. DataStruct dStruct = GetPostStruct();
  10721. List<string> lw = new List<string>();
  10722. string tid = GetPostString("ctid");
  10723. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10724. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10725. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10726. var res_objz = new
  10727. {
  10728. restype = 1,
  10729. data = dt
  10730. };
  10731. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10732. returnSuccess(ro_jsonz);
  10733. }
  10734. public void get_erp_yield_list()
  10735. {
  10736. DataStruct dStruct = GetPostStruct();
  10737. List<string> lw = new List<string>();
  10738. string tid = GetPostString("ctid");
  10739. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10740. string shopname = GetPostString("shopname");
  10741. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10742. string buyernick = GetPostString("buyer_nick");
  10743. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10744. //if (tid.Length == 0 && buyernick.Length == 0)
  10745. //{
  10746. // lw.Add(string.Format("IsRefund<={0}", 1));
  10747. //}
  10748. string customer = GetPostString("customer");
  10749. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10750. string design = GetPostString("design");
  10751. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10752. string orderState = GetPostString("orderState");
  10753. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10754. string address = GetPostString("address");
  10755. 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));
  10756. string sellermemo = GetPostString("seller_memo");
  10757. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10758. string supplier = GetPostString("supplier");
  10759. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10760. string OrderArea = GetPostString("order_area");
  10761. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10762. string placedate1 = GetPostString("placedate1");
  10763. string placedate2 = GetPostString("placedate2");
  10764. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10765. if (fdw.Length > 0) lw.Add(fdw);
  10766. string price1 = GetPostString("price1");
  10767. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10768. string price2 = GetPostString("price2");
  10769. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10770. string unusualCon = GetPostString("unusualcon");
  10771. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10772. string posTag = CurrentUser.UserPost.Post.Code;
  10773. if (posTag == "Supplier")
  10774. {
  10775. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10776. }
  10777. lw.Add(string.Format("OrderState = 6 "));
  10778. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10779. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10780. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10781. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10782. writeGridDataTableJson(dStruct.TotalCount, dt);
  10783. }
  10784. public void change_erp_sup_state()
  10785. {
  10786. if (UrlPostParmsCheck("ctid"))
  10787. {
  10788. string ctid = GetPostString("ctid");
  10789. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10790. if (ceErpTradeCell != null)
  10791. {
  10792. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10793. if (ceErpTradeCellExtend == null)
  10794. {
  10795. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10796. ceErpTradeCellExtend.ctid = ctid;
  10797. ceErpTradeCellExtend.SupState = 1;
  10798. ceErpTradeCellExtend.Create();
  10799. }
  10800. else
  10801. {
  10802. ceErpTradeCellExtend.SupState = 1;
  10803. ceErpTradeCellExtend.Update();
  10804. }
  10805. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10806. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10807. return;
  10808. }
  10809. returnErrorMsg("找不到订单");
  10810. }
  10811. }
  10812. public void supplier_all_downs()
  10813. {
  10814. if (UrlPostParmsCheck("tids"))
  10815. {
  10816. string tids = GetPostString("tids");
  10817. if (tids != null && tids.Length > 0)
  10818. {
  10819. StringBuilder sql = new StringBuilder();
  10820. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10821. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10822. sql = new StringBuilder();
  10823. 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, "下载设计文件");
  10824. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10825. string[] list = tids.Split(',');
  10826. foreach (string ctid in list)
  10827. {
  10828. CeErpSukuraData.createInfo(ctid, 3);
  10829. }
  10830. designHelper.api_approveDesign(tids); //approveDesign
  10831. returnSuccessMsg("下载成功!");
  10832. return;
  10833. }
  10834. returnErrorMsg("下载订单更新失败");
  10835. }
  10836. }
  10837. public void uploaderFileSuccess()
  10838. {
  10839. if (UrlPostParmsCheck("fileName"))
  10840. {
  10841. string fileName = GetPostString("fileName");
  10842. ApiVo apiVo = new ApiVo();
  10843. apiVo.orderNumber = fileName;
  10844. apiVo.actionName = "finishDesign";
  10845. designHelper.API_WorkCore(apiVo);//finishDesign
  10846. returnSuccessMsg("");
  10847. }
  10848. }
  10849. public void get_sample2_order()
  10850. {
  10851. if (UrlPostParmsCheck("ctid"))
  10852. {
  10853. string ctid = GetPostString("ctid");
  10854. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10855. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10856. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10857. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10858. double total = 0.0;
  10859. double order_price = 0.0;
  10860. if (dt_bu.Rows.Count > 0)
  10861. {
  10862. foreach (DataRow dr in dt_bu.Rows)
  10863. {
  10864. total += Convert.ToDouble(dr["payment"]);
  10865. }
  10866. }
  10867. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10868. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10869. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10870. string tid = ctid.Replace("S_", "");
  10871. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10872. double paymant = 0.0;
  10873. if (entity != null)
  10874. {
  10875. paymant = entity.payment;
  10876. }
  10877. string return_reason = "";
  10878. if (dt_after != null && dt_after.Rows.Count > 0)
  10879. {
  10880. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10881. }
  10882. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10883. }
  10884. }
  10885. public void get_erp_design_status()
  10886. {
  10887. string designName = GetPostString("designName");
  10888. DataStruct dStruct = GetPostStruct();
  10889. if (designName.Length > 0)
  10890. {
  10891. 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";
  10892. sql_user += " and Name like '%" + designName + "%'";
  10893. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10894. List<string> ids_list = new List<string>();
  10895. if (user_table.Rows.Count > 0)
  10896. {
  10897. foreach (DataRow item in user_table.Rows)
  10898. {
  10899. ids_list.Add(item["id"].ToString());
  10900. string ids_s = item["TeamIds"].ToString();
  10901. if (ids_s.Length > 0)
  10902. {
  10903. ids_list.AddRange(ids_s.Split(','));
  10904. }
  10905. }
  10906. }
  10907. HashSet<string> set = new HashSet<string>(ids_list);
  10908. ids_list = set.ToList();
  10909. if (ids_list.Count > 0)
  10910. {
  10911. 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));
  10912. dStruct.MainWhere = sql;
  10913. DataTable dt = null;
  10914. dt = WebCache.GetData("view_ErpUser", dStruct);
  10915. writeGridDataTableJson(dStruct.TotalCount, dt);
  10916. }
  10917. }
  10918. }
  10919. public void change_erp_order_price()
  10920. {
  10921. string ctid = GetPostString("ctid");
  10922. double price = GetPostDouble("price");
  10923. if (ctid.Length > 0)
  10924. {
  10925. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10926. if (ceErpTradeCellExtend == null)
  10927. {
  10928. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10929. ceErpTradeCellExtend.ctid = ctid;
  10930. ceErpTradeCellExtend.payment_cyt = price;
  10931. ceErpTradeCellExtend.Create();
  10932. }
  10933. else
  10934. {
  10935. ceErpTradeCellExtend.payment_cyt = price;
  10936. ceErpTradeCellExtend.Update();
  10937. }
  10938. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10939. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10940. {
  10941. ceErpDataSendOrderInfo.isSync = false;
  10942. ceErpDataSendOrderInfo.Update();
  10943. }
  10944. if (ceErpDataSendOrderInfo == null)
  10945. {
  10946. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10947. ceErpDataSendOrderInfo.isSync = false;
  10948. ceErpDataSendOrderInfo.ctid = ctid;
  10949. ceErpDataSendOrderInfo.Create();
  10950. }
  10951. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10952. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10953. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10954. if (dth != null && dth.Rows.Count > 0)
  10955. {
  10956. dataSendOrderBean dataSendOrderBean = null;
  10957. foreach (DataRow item in dth.Rows)
  10958. {
  10959. try
  10960. {
  10961. dataSendOrderBean = new dataSendOrderBean();
  10962. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10963. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10964. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10965. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10966. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10967. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10968. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10969. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10970. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10971. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10972. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10973. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10974. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10975. if (result != null)
  10976. {
  10977. if ("0".Equals(result.errcode))
  10978. {
  10979. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10980. }
  10981. else
  10982. {
  10983. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10984. }
  10985. }
  10986. }
  10987. catch (Exception ex)
  10988. {
  10989. }
  10990. }
  10991. }
  10992. returnSuccessMsg("修改成功!");
  10993. return;
  10994. }
  10995. returnErrorMsg("找不到订单");
  10996. }
  10997. public void find_he_together()
  10998. {
  10999. string ctid = GetPostString("ctid");
  11000. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11001. List<string> list = new List<string>();
  11002. if (ceErpTradeCell != null)
  11003. {
  11004. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11005. {
  11006. 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);
  11007. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11008. if (table != null && table.Rows.Count > 0)
  11009. {
  11010. foreach (TableRow row in table.Rows)
  11011. {
  11012. }
  11013. }
  11014. }
  11015. }
  11016. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11017. }
  11018. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11019. {
  11020. //chy----19
  11021. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11022. //GD-CYT-----64
  11023. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11024. //ZHX----3
  11025. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11026. //JK----97
  11027. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11028. //ZT----70
  11029. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11030. //LHCY-----98
  11031. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11032. //XD-----90
  11033. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11034. //CYCY-----14
  11035. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11036. };
  11037. //其他改名
  11038. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11039. {
  11040. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11041. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11042. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11043. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11044. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11045. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11046. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11047. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11048. };
  11049. //不统计
  11050. List<int> no_suppliers = new List<int>()
  11051. {
  11052. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11053. };
  11054. //配件单
  11055. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11056. {
  11057. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11058. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11059. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11060. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11061. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11062. {"旗杆",new List<string>(){ "班旗" } },
  11063. {"牙签",new List<string>(){ "不干胶" } }
  11064. };
  11065. public void get_place_order_data()
  11066. {
  11067. string date1 = GetPostString("date1");
  11068. string date2 = GetPostString("date2");
  11069. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11070. DateTime start = DateTime.Parse(starttime);
  11071. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11072. DateTime end = DateTime.Parse(endtime);
  11073. if (date1 != null && date1.Length > 0)
  11074. {
  11075. DateTime dateTime = DateTime.Parse(date1);
  11076. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11077. start = DateTime.Parse(starttime);
  11078. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11079. end = DateTime.Parse(endtime);
  11080. }
  11081. if (date2 != null && date2.Length > 0)
  11082. {
  11083. DateTime dateTime = DateTime.Parse(date2);
  11084. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11085. end = DateTime.Parse(endtime);
  11086. }
  11087. 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);
  11088. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11089. //不干胶-----1,卡片-----29
  11090. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11091. foreach (DataRow row in data.Rows)
  11092. {
  11093. int productId = Convert.ToInt32(row["ProductId"]);
  11094. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11095. if (no_suppliers.Contains(supplierId))
  11096. {
  11097. continue;
  11098. }
  11099. string seller_memo = row["seller_memo"].ToString();
  11100. bool ispj = false;//是否配件单
  11101. bool isfirst = true;//第一个配
  11102. maps.Keys.ForEach(key =>
  11103. {
  11104. //备注包含配件
  11105. if (seller_memo.Contains(key) && isfirst)
  11106. {
  11107. List<string> list = maps[key];
  11108. ispj = true;
  11109. isfirst = false;
  11110. for (int i = 0; i < list.Count; i++)
  11111. {
  11112. if (seller_memo.Contains(list[i]))
  11113. {
  11114. ispj = false;
  11115. break;
  11116. }
  11117. }
  11118. }
  11119. });
  11120. if (ispj)
  11121. {
  11122. continue;
  11123. }
  11124. seller_memo = seller_memo.Replace("UV", "uv");
  11125. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11126. //吊牌归到卡片
  11127. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11128. seller_memo = seller_memo.Replace("卡套", "卡片");
  11129. seller_memo = seller_memo.Replace("封套", "卡片");
  11130. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11131. seller_memo = seller_memo.Replace("腰封", "卡片");
  11132. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11133. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11134. seller_memo = seller_memo.Replace("横幅", "条幅");
  11135. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11136. string map_key = "";
  11137. string type = "";
  11138. if (supplierMap.ContainsKey(supplierId))
  11139. {
  11140. foreach (var kvp in supplierMap[supplierId])
  11141. {
  11142. if (seller_memo.Contains(kvp.Key))
  11143. {
  11144. map_key = kvp.Value;
  11145. type = kvp.Value;
  11146. break;
  11147. }
  11148. }
  11149. }
  11150. if (map_key == "")
  11151. {
  11152. type = "其他";
  11153. map_key = "其他";
  11154. }
  11155. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11156. {
  11157. map_key = suppliers[supplierId];
  11158. }
  11159. if (supplierId == 70)
  11160. {
  11161. supplierId = 70;
  11162. }
  11163. map_key += "_" + row["SupplierName"].ToString();
  11164. Dictionary<string, int> map = null;
  11165. if (other_map.ContainsKey(map_key))
  11166. {
  11167. other_map.TryGetValue(map_key, out map);
  11168. }
  11169. else
  11170. {
  11171. map = new Dictionary<string, int>();
  11172. map.Add("dayDev", 0);//当天出货
  11173. map.Add("dayTotal", 0);//下单总数
  11174. map.Add("payTotal", 0);//500以上
  11175. map.Add("today", 0);//当天出货数量
  11176. map.Add("unusua", 0);//异常数
  11177. other_map.Add(map_key, map);
  11178. other_map.TryGetValue(map_key, out map);
  11179. }
  11180. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11181. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11182. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11183. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11184. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11185. {
  11186. map["dayTotal"]++;
  11187. if (supplierId == 97)
  11188. {
  11189. supplierId = 97;
  11190. }
  11191. }
  11192. if (Convert.ToDecimal(row["payment"]) >= 500)
  11193. {
  11194. map["payTotal"]++;
  11195. }
  11196. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11197. {
  11198. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11199. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11200. {
  11201. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11202. {
  11203. map["today"]++;
  11204. }
  11205. }
  11206. else
  11207. {
  11208. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11209. {
  11210. map["today"]++;
  11211. }
  11212. else
  11213. {
  11214. if (supplierId == 119)
  11215. {
  11216. Debug.WriteLine(row["seller_memo"].ToString());
  11217. }
  11218. }
  11219. }
  11220. }
  11221. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11222. {
  11223. map["unusua"]++;
  11224. }
  11225. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11226. //GD-CYT-----64
  11227. DateTime two = palceTimeStart.AddHours(14);
  11228. DateTime three = palceTimeStart.AddHours(15);
  11229. DateTime four = palceTimeStart.AddHours(16);
  11230. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11231. {
  11232. //下午四点前 500-1000
  11233. string count = row["ProductCount"].ToString();
  11234. if (count != null && count.Length > 0)
  11235. {
  11236. int productCount = commonHelper.getPlaceProductCount(count);
  11237. if (productCount >= 500 && productCount <= 1000)
  11238. {
  11239. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11240. {
  11241. map["dayDev"]++;
  11242. }
  11243. }
  11244. }
  11245. }
  11246. //UV
  11247. else if ("uv".Equals(type))
  11248. {
  11249. //ZT----70
  11250. //ZHX----3
  11251. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11252. {
  11253. map["dayDev"]++;
  11254. }
  11255. //JK----97
  11256. //HZX----105
  11257. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11258. {
  11259. map["dayDev"]++;
  11260. if (supplierId == 97)
  11261. {
  11262. supplierId = 97;
  11263. }
  11264. }
  11265. }
  11266. //帆布---52|条幅---27
  11267. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11268. {
  11269. //LHCY-----98
  11270. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11271. {
  11272. map["dayDev"]++;
  11273. }
  11274. }
  11275. //条幅
  11276. else if ("条幅".Equals(type))
  11277. {
  11278. //XD-----90
  11279. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11280. {
  11281. map["dayDev"]++;
  11282. }
  11283. }
  11284. //桌布
  11285. else if ("桌布".Equals(type))
  11286. {
  11287. //XD-----90
  11288. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11289. {
  11290. map["dayDev"]++;
  11291. }
  11292. }
  11293. //DL---10
  11294. //AYTW---119
  11295. //FS-CYT-DY ----80
  11296. //JK----97
  11297. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11298. {
  11299. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11300. {
  11301. map["dayDev"]++;
  11302. }
  11303. }
  11304. }
  11305. DataTable dt = new DataTable();
  11306. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11307. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11308. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11309. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11310. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11311. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11312. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11313. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11314. other_map.Keys.ForEach(key =>
  11315. {
  11316. DataRow dr = dt.NewRow();
  11317. Dictionary<string, int> map = other_map[key];
  11318. string[] key_list = key.Split('_');
  11319. dr[0] = key_list[0];
  11320. dr[1] = key_list[1];
  11321. if (key_list.Length > 2)
  11322. {
  11323. dr[1] += "(" + key_list[2] + ")";
  11324. }
  11325. dr[2] = map["dayTotal"];
  11326. dr[3] = map["payTotal"];
  11327. dr[4] = map["today"];
  11328. dr[5] = map["unusua"];
  11329. dr[6] = map["dayDev"];
  11330. double rate = 0.00;
  11331. if (map["dayDev"] > 0)
  11332. {
  11333. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11334. }
  11335. dr[7] = rate.ToString();
  11336. dt.Rows.Add(dr);
  11337. });
  11338. DataView dv = new DataView(dt);
  11339. dv.Sort = "SupplierName";
  11340. //dv.Sort = "AllOrder desc";
  11341. DataTable dtNew = dv.ToTable();
  11342. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11343. }
  11344. public void check_order_desing_info()
  11345. {
  11346. string ctid = GetPostString("ctid");
  11347. if (!string.IsNullOrEmpty(ctid))
  11348. {
  11349. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11350. if (ceErpTradeCell != null)
  11351. {
  11352. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11353. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11354. return;
  11355. }
  11356. returnErrorMsg("找不到订单");
  11357. return;
  11358. }
  11359. returnErrorMsg("找不到订单");
  11360. }
  11361. public void get_timeout_detail()
  11362. {
  11363. string poscode = CurrentUser.UserPost.Post.Code;
  11364. DataStruct dStruct = GetPostStruct();
  11365. List<string> lw = new List<string>();
  11366. string id = GetPostString("id");
  11367. string pay_date1 = GetPostString("pay_date1");
  11368. string pay_date2 = GetPostString("pay_date2");
  11369. int type = GetPostInt("type");
  11370. if (type == 0)
  11371. {
  11372. if (pay_date1.Length > 0)
  11373. {
  11374. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11375. }
  11376. if (pay_date2.Length > 0)
  11377. {
  11378. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11379. }
  11380. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11381. }
  11382. if (type == 1)
  11383. {
  11384. if (pay_date1.Length > 0)
  11385. {
  11386. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11387. }
  11388. if (pay_date2.Length > 0)
  11389. {
  11390. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11391. }
  11392. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11393. }
  11394. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11395. DataTable dt = null;
  11396. dt = WebCache.GetData("view_orderlist", dStruct);
  11397. writeGridDataTableJson(dStruct.TotalCount, dt);
  11398. }
  11399. public void saveUrgentChargePrice()
  11400. {
  11401. string ctid = GetPostString("ctid");
  11402. if (!string.IsNullOrEmpty(ctid))
  11403. {
  11404. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11405. if (ceErpTradeCell != null)
  11406. {
  11407. double price = GetPostDouble("price");
  11408. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11409. if (ceErpTradeCellExtend == null)
  11410. {
  11411. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11412. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11413. }
  11414. ceErpTradeCellExtend.urgentCharge = price;
  11415. if (ceErpTradeCellExtend.ID > 0)
  11416. {
  11417. ceErpTradeCellExtend.Update();
  11418. }
  11419. else
  11420. {
  11421. ceErpTradeCellExtend.Save();
  11422. }
  11423. returnSuccessMsg("修改成功!");
  11424. return;
  11425. }
  11426. returnErrorMsg("找不到订单");
  11427. return;
  11428. }
  11429. returnErrorMsg("找不到订单");
  11430. }
  11431. public void finish_erp_order()
  11432. {
  11433. string ctid = GetPostString("ctid");
  11434. if (!string.IsNullOrEmpty(ctid))
  11435. {
  11436. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11437. {
  11438. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11439. if (ceErpTradeCell != null)
  11440. {
  11441. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11442. ceErpTradeCell.Update();
  11443. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11444. returnSuccessMsg("修改成功!");
  11445. return;
  11446. }
  11447. }
  11448. }
  11449. returnErrorMsg("找不到订单");
  11450. }
  11451. public void get_trade_order_list()
  11452. {
  11453. string tid = GetPostString("tid");
  11454. if (!string.IsNullOrEmpty(tid))
  11455. {
  11456. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11457. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11458. writeGridDataTableJson(data.Rows.Count, data);
  11459. return;
  11460. }
  11461. returnErrorMsg("找不到订单");
  11462. }
  11463. public void save_cell_spu()
  11464. {
  11465. string ctid = GetPostString("ctid");
  11466. string spu_id = GetPostString("spu_id");
  11467. if (!string.IsNullOrEmpty(ctid))
  11468. {
  11469. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11470. if (ceErpTradeCellExtend == null)
  11471. {
  11472. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11473. ceErpTradeCellExtend.ctid = ctid;
  11474. }
  11475. ceErpTradeCellExtend.spu_id = spu_id;
  11476. if (ceErpTradeCellExtend.ID == 0)
  11477. {
  11478. ceErpTradeCellExtend.Create();
  11479. }
  11480. else
  11481. {
  11482. ceErpTradeCellExtend.Update();
  11483. }
  11484. returnSuccessMsg("修改成功!");
  11485. return;
  11486. }
  11487. returnErrorMsg("找不到订单");
  11488. }
  11489. public void change_express_info()
  11490. {
  11491. string ctid = GetPostString("ctid");
  11492. string transNo = GetPostString("transNo");
  11493. string transCom = GetPostString("transCom");
  11494. if (!string.IsNullOrEmpty(ctid))
  11495. {
  11496. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11497. if (ceErpTradeCellExtend == null)
  11498. {
  11499. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11500. ceErpTradeCellExtend.ctid = ctid;
  11501. }
  11502. ceErpTradeCellExtend.modExpressNo = transNo;
  11503. ceErpTradeCellExtend.modExpressCom = transCom;
  11504. ceErpTradeCellExtend.readMod = 2;
  11505. if (ceErpTradeCellExtend.ID == 0)
  11506. {
  11507. ceErpTradeCellExtend.Create();
  11508. }
  11509. else
  11510. {
  11511. ceErpTradeCellExtend.Update();
  11512. }
  11513. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11514. returnSuccessMsg("修改成功!");
  11515. return;
  11516. }
  11517. returnErrorMsg("找不到订单");
  11518. }
  11519. public void get_change_express_list()
  11520. {
  11521. DataStruct dStruct = GetPostStruct();
  11522. List<string> lw = new List<string>();
  11523. int st = 2;
  11524. string tid = GetPostString("ctid");
  11525. if (tid.Length > 0)
  11526. {
  11527. string select_tid = getTidByCtid(tid);
  11528. lw.Add(string.Format("tid='{0}'", select_tid));
  11529. }
  11530. string shopname = GetPostString("shopname");
  11531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11532. string buyernick = GetPostString("buyer_nick");
  11533. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11534. string sellermemo = GetPostString("seller_memo");
  11535. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11536. string supplier = GetPostString("supplier");
  11537. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11538. string customer = GetPostString("customer");
  11539. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11540. string design = GetPostString("design");
  11541. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11542. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11543. string poscode = CurrentUser.UserPost.Post.Code;
  11544. if (poscode != "SysAdmin")
  11545. {
  11546. string shopid = CurrentUser.User.pemShop;
  11547. lw.Add(string.Format("shopId in ({0})", shopid));
  11548. }
  11549. lw.Add("readMod = 2");
  11550. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11551. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11552. writeGridDataTableJson(dStruct.TotalCount, dt);
  11553. }
  11554. public void deal_express_complete()
  11555. {
  11556. string ctid = GetPostString("ctid");
  11557. if (!string.IsNullOrEmpty(ctid))
  11558. {
  11559. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11560. if (ceErpTradeCellExtend == null)
  11561. {
  11562. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11563. ceErpTradeCellExtend.ctid = ctid;
  11564. }
  11565. ceErpTradeCellExtend.readMod = 1;
  11566. if (ceErpTradeCellExtend.ID == 0)
  11567. {
  11568. ceErpTradeCellExtend.Create();
  11569. }
  11570. else
  11571. {
  11572. ceErpTradeCellExtend.Update();
  11573. }
  11574. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11575. returnSuccessMsg("修改成功!");
  11576. return;
  11577. }
  11578. returnErrorMsg("找不到订单");
  11579. }
  11580. public void aftersale_return_visit()
  11581. {
  11582. string ctid = GetPostString("ctid");
  11583. if (!string.IsNullOrEmpty(ctid))
  11584. {
  11585. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11586. if (ceErpTradeCellExtend == null)
  11587. {
  11588. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11589. ceErpTradeCellExtend.ctid = ctid;
  11590. }
  11591. ceErpTradeCellExtend.returnVisit = 1;
  11592. if (ceErpTradeCellExtend.ID == 0)
  11593. {
  11594. ceErpTradeCellExtend.Create();
  11595. }
  11596. else
  11597. {
  11598. ceErpTradeCellExtend.Update();
  11599. }
  11600. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11601. if (ceErpTradeAfterSaleExtend != null)
  11602. {
  11603. ceErpTradeAfterSaleExtend.TextResult = "";
  11604. ceErpTradeAfterSaleExtend.Update();
  11605. }
  11606. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11607. returnSuccessMsg("修改成功!");
  11608. return;
  11609. }
  11610. returnErrorMsg("找不到订单");
  11611. }
  11612. public void orderPlaceInfo()
  11613. {
  11614. string ctids = GetPostString("ctids");
  11615. string[] list = ctids.Split(',');
  11616. foreach (string ctid in list)
  11617. {
  11618. CeErpSukuraData.createInfo(ctid, 3);
  11619. }
  11620. StringBuilder sql = new StringBuilder();
  11621. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11622. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11623. designHelper.api_approveDesign(ctids); //approveDesign
  11624. returnSuccessMsg("");
  11625. }
  11626. public void get_issue_list()
  11627. {
  11628. DataStruct dStruct = GetPostStruct();
  11629. List<string> lw = new List<string>();
  11630. int st = 2;
  11631. string tid = GetPostString("ctid");
  11632. if (tid.Length > 0)
  11633. {
  11634. string select_tid = getTidByCtid(tid);
  11635. lw.Add(string.Format("tid='{0}'", select_tid));
  11636. }
  11637. string shopname = GetPostString("shopname");
  11638. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11639. string buyernick = GetPostString("buyer_nick");
  11640. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11641. string sellermemo = GetPostString("seller_memo");
  11642. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11643. string supplier = GetPostString("supplier");
  11644. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11645. string customer = GetPostString("customer");
  11646. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11647. string design = GetPostString("design");
  11648. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11649. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11650. string poscode = CurrentUser.UserPost.Post.Code;
  11651. if (poscode != "SysAdmin")
  11652. {
  11653. string shopid = CurrentUser.User.pemShop;
  11654. lw.Add(string.Format("shopId in ({0})", shopid));
  11655. }
  11656. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11657. {
  11658. lw.Add("IssueState = 1");
  11659. }
  11660. lw.Add("IssueState > 0");
  11661. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11662. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11663. writeGridDataTableJson(dStruct.TotalCount, dt);
  11664. }
  11665. public void saveIssueContent()
  11666. {
  11667. string ctid = GetPostString("ctid");
  11668. if (!string.IsNullOrEmpty(ctid))
  11669. {
  11670. string content = GetPostString("content");
  11671. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11672. if (ceErpTradeAfterSaleExtend == null)
  11673. {
  11674. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11675. ceErpTradeAfterSaleExtend.tid = ctid;
  11676. }
  11677. ceErpTradeAfterSaleExtend.IssueContent = content;
  11678. ceErpTradeAfterSaleExtend.IssueState = 1;
  11679. if (ceErpTradeAfterSaleExtend.ID > 0)
  11680. {
  11681. ceErpTradeAfterSaleExtend.Update();
  11682. }
  11683. else
  11684. {
  11685. ceErpTradeAfterSaleExtend.Create();
  11686. }
  11687. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11688. returnSuccessMsg("添加成功!");
  11689. return;
  11690. }
  11691. returnErrorMsg("找不到订单");
  11692. }
  11693. public void dealIssueContent()
  11694. {
  11695. string ctid = GetPostString("ctid");
  11696. if (!string.IsNullOrEmpty(ctid))
  11697. {
  11698. string content = GetPostString("content");
  11699. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11700. if (ceErpTradeAfterSaleExtend != null)
  11701. {
  11702. ceErpTradeAfterSaleExtend.IssueState = 2;
  11703. ceErpTradeAfterSaleExtend.Update();
  11704. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11705. returnSuccessMsg("修改完成!");
  11706. return;
  11707. }
  11708. }
  11709. returnErrorMsg("找不到订单");
  11710. }
  11711. public void set_tid_attachments()
  11712. {
  11713. string tid = GetPostString("tid");
  11714. string atta = GetPostString("atta");
  11715. if (!string.IsNullOrEmpty(tid))
  11716. {
  11717. if (string.IsNullOrEmpty(atta))
  11718. {
  11719. returnErrorMsg("文件地址为空");
  11720. return;
  11721. }
  11722. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11723. if (ceErpTradeCell != null)
  11724. {
  11725. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11726. if (ceErpTrade == null)
  11727. {
  11728. returnErrorMsg("找不到订单");
  11729. return;
  11730. }
  11731. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11732. bool isSend = false;
  11733. if (dt != null && dt.Rows.Count > 0)
  11734. {
  11735. foreach (DataRow row in dt.Rows)
  11736. {
  11737. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11738. {
  11739. isSend = true;
  11740. }
  11741. }
  11742. if (isSend)
  11743. {
  11744. returnErrorMsg("已发货无法修改");
  11745. return;
  11746. }
  11747. ceErpTrade.Attachments = atta;
  11748. ceErpTrade.Update();
  11749. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11750. returnSuccessMsg("上传成功!");
  11751. return;
  11752. }
  11753. }
  11754. }
  11755. returnErrorMsg("找不到订单");
  11756. }
  11757. public void get_tid_attachments()
  11758. {
  11759. string tid = GetPostString("tid");
  11760. if (!string.IsNullOrEmpty(tid))
  11761. {
  11762. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11763. if (ceErpTradeCell != null)
  11764. {
  11765. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11766. if (ceErpTrade == null)
  11767. {
  11768. returnErrorMsg("找不到订单");
  11769. return;
  11770. }
  11771. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11772. return;
  11773. }
  11774. }
  11775. returnErrorMsg("找不到订单");
  11776. }
  11777. public void check_erp_sameorders()
  11778. {
  11779. if (UrlPostParmsCheck("ctid"))
  11780. {
  11781. string eid = GetPostString("ctid");
  11782. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11783. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11784. if (entity != null && ceErpTrade != null)
  11785. {
  11786. if (entity.OrderState > 6)
  11787. {
  11788. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11789. return;
  11790. }
  11791. StringBuilder sql = new StringBuilder();
  11792. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
  11793. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11794. {
  11795. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11796. }
  11797. else
  11798. {
  11799. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11800. }
  11801. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11802. List<string> ids = new List<string>();
  11803. if (dt != null && dt.Rows.Count > 1)
  11804. {
  11805. bool needhe = true;
  11806. foreach (DataRow dr in dt.Rows)
  11807. {
  11808. ids.Add("'" + dr["ctid"] + "'");
  11809. /* //备注有合包
  11810. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11811. {
  11812. needhe = true;
  11813. }
  11814. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11815. {
  11816. needhe = true;
  11817. }
  11818. //顺丰快递
  11819. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11820. {
  11821. needhe = true;
  11822. }*/
  11823. }
  11824. if (!needhe)
  11825. {
  11826. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11827. return;
  11828. }
  11829. sql = new StringBuilder();
  11830. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11831. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11832. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11833. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11834. foreach (DataRow dr in dt.Rows)
  11835. {
  11836. dr["dstate"] = 0;
  11837. dr["dnumber"] = 0;
  11838. foreach (DataRow row in dt1.Rows)
  11839. {
  11840. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11841. {
  11842. dr["dstate"] = 2;
  11843. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11844. }
  11845. }
  11846. if (eid.Equals(dr["ctid"].ToString()))
  11847. {
  11848. dr["dstate"] = 1;
  11849. }
  11850. }
  11851. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11852. return;
  11853. }
  11854. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11855. return;
  11856. }
  11857. returnErrorMsg("未找到订单");
  11858. return;
  11859. }
  11860. returnErrorMsg("缺少必要的参数");
  11861. }
  11862. public void get_mark_number()
  11863. {
  11864. string eid = GetPostString("ctid");
  11865. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11866. if (entity != null)
  11867. {
  11868. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11869. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11870. int current = 1;
  11871. if (ceErpDeliverMark == null)
  11872. {
  11873. StringBuilder sql = new StringBuilder();
  11874. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
  11875. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11876. {
  11877. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11878. }
  11879. else
  11880. {
  11881. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11882. }
  11883. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11884. List<string> ids = new List<string>();
  11885. if (dt != null && dt.Rows.Count > 1)
  11886. {
  11887. foreach (DataRow dr in dt.Rows)
  11888. {
  11889. ids.Add("'" + dr["ctid"] + "'");
  11890. }
  11891. //查询已有的编号
  11892. sql = new StringBuilder();
  11893. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11894. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11895. if (dt1 == null || dt1.Rows.Count == 0)
  11896. {
  11897. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11898. List<int> list_number = new List<int>();
  11899. foreach (DataRow row in numbers.Rows)
  11900. {
  11901. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11902. }
  11903. //查询空余编号
  11904. for (int i = 0; i < list_number.Count + 2; i++)
  11905. {
  11906. if (!list_number.Contains(current))
  11907. {
  11908. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11909. //防止查询过程中有新数据生成
  11910. if (ceErpDeliverMark1 == null)
  11911. {
  11912. break;
  11913. }
  11914. }
  11915. current++;
  11916. }
  11917. }
  11918. else
  11919. {
  11920. foreach (DataRow row in dt1.Rows)
  11921. {
  11922. current = Convert.ToInt32(row["markNumber"]);
  11923. }
  11924. }
  11925. ceErpDeliverMark = new CeErpDeliverMark();
  11926. ceErpDeliverMark.ctid = eid;
  11927. ceErpDeliverMark.createtime = DateTime.Now;
  11928. if (ceErpTrade != null)
  11929. {
  11930. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11931. }
  11932. ceErpDeliverMark.markNumber = current;
  11933. ceErpDeliverMark.Create();
  11934. }
  11935. }
  11936. else
  11937. {
  11938. current = ceErpDeliverMark.markNumber;
  11939. }
  11940. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11941. return;
  11942. }
  11943. }
  11944. }
  11945. }