sync.order.cs 571 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305
  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.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.Api_SyncOrderByTime("598825");
  52. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  53. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  54. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  55. //banniuApiHelper.sendLogisticsInfo(null);
  56. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  57. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  58. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  59. //int sid = commonHelper.autoDistributeToSupplier(entity);
  60. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  61. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1740972223000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1741145016000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2208932202028/O1CN01SQkhPk1QqsBIMPegn_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":10.0,\"refOlId\":\"2484480075794418199\",\"refSkuId\":\"0\",\"refSpuId\":\"787248116865\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"饰品售后卡片定制珠宝项链购后感谢卡硬卡设计金银保养留言卡纸制作电商包裹贺卡高级明信片首饰好平小卡印刷\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1740995566000,\"openBuyerId\":\"AAFoRHraABkUZRPgSx0XdWH-\",\"openBuyerNick\":\"t**\",\"openSellerNick\":\"麦郁旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1740972209000,\"payTime\":1740972216000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"maiyu\",\"posId\":598808,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"湖州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴兴区\",\"receiverId\":\"82b7afe37a7abf32c5a68285642bc6c7$\",\"receiverState\":\"浙江省\",\"receiverTown\":\"织里镇\",\"refOid\":\"2484480075794418199\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-卡片-300克铜版纸-tb90589912-小元-2,寄样-卡片-300克雅柔纸-tb90589912-小元-2,寄样-卡片-300克蛋壳纸-tb90589912-小元-2,寄样-卡片-300克刚古水纹纸-tb90589912-小元-2,寄样-卡片-300克荷兰白卡纸-tb90589912-小元-2\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":10.0,\"totalPrice\":10.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
  62. //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}}");
  63. List<string> lw = new List<string>();
  64. string tid = GetPostString("ctid");
  65. string date1 = GetPostString("date1");
  66. //12-1 修改
  67. string urgent = GetPostString("urgent");
  68. string back = GetPostString("back");
  69. string offlineSearch = GetPostString("offlineSearch");
  70. int paramsCount = 0;
  71. if (!string.IsNullOrWhiteSpace(urgent))
  72. {
  73. if (urgent.Equals("true"))
  74. {
  75. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  76. }
  77. }
  78. if (!string.IsNullOrWhiteSpace(back))
  79. {
  80. if (back.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(offlineSearch))
  86. {
  87. if (offlineSearch.Equals("true"))
  88. {
  89. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  90. }
  91. }
  92. //end
  93. string date2 = GetPostString("date2");
  94. string buyernick = GetPostString("buyer_nick");
  95. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  96. {
  97. if (tid.Length <= 0 && buyernick.Length <= 0)
  98. {
  99. return;
  100. }
  101. }
  102. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  103. {
  104. if (tid.Length > 0)
  105. {
  106. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  107. }
  108. if (buyernick.Length > 0)
  109. {
  110. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  111. }
  112. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  113. if (dw.Length > 0)
  114. {
  115. lw.Add(dw);
  116. }
  117. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  118. {
  119. string usershop = CurrentUser.User.pemShop;
  120. lw.Add(string.Format("ShopId in ({0})", usershop));
  121. }
  122. }
  123. else
  124. {
  125. if (ex_psize == 0)
  126. {
  127. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  128. }
  129. if (PKey != "admin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. paramsCount++;
  134. }
  135. }
  136. string uploaddate1 = GetPostString("uploaddate1");
  137. string uploaddate2 = GetPostString("uploaddate2");
  138. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  139. if (update.Length > 0) lw.Add(update);
  140. string deliverydate1 = GetPostString("deliverydate1");
  141. string deliverydate2 = GetPostString("deliverydate2");
  142. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  143. if (deliverydate.Length > 0)
  144. {
  145. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  146. };
  147. string shopname = GetPostString("shopname");
  148. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  149. string addwechat = GetPostString("addwechat");
  150. if (addwechat.Length > 0)
  151. {
  152. int addWt = Convert.ToInt32(addwechat);
  153. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  154. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  155. }
  156. string customer = GetPostString("customer");
  157. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  158. string design = GetPostString("design");
  159. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  160. string orderState = GetPostString("orderState");
  161. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  162. string address = GetPostString("address");
  163. 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));
  164. string sellermemo = GetPostString("seller_memo");
  165. if (sellermemo.Length > 0)
  166. {
  167. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  168. }
  169. string backReason = GetPostString("backReason");
  170. if (backReason.Length > 0)
  171. {
  172. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  173. }
  174. string apdate1 = GetPostString("apdate1");
  175. string apdate2 = GetPostString("apdate2");
  176. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  177. if (dwap.Length > 0) lw.Add(dwap);
  178. string price1 = GetPostString("price1");
  179. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  180. string price2 = GetPostString("price2");
  181. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  182. string isoldcustomer = GetPostString("isoldcus");
  183. string finishdate1 = GetPostString("finishdate1");
  184. string finishdate2 = GetPostString("finishdate2");
  185. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  186. bool isFinish = false;
  187. if (finishdate.Length > 0)
  188. {
  189. lw.Add(finishdate);
  190. isFinish = true;
  191. paramsCount++;
  192. }
  193. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  194. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  195. if (ex_psize > 0)
  196. {
  197. int UserID = CurrentUser.UserID;
  198. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  199. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  200. {
  201. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  202. }
  203. dStruct.Order = "pay_time desc";
  204. }
  205. string isNew = GetPostString("isNew");
  206. if (isNew == "true")
  207. {
  208. lw.Add(string.Format("IsNew = {0}", 1));
  209. }
  210. string overtime = GetPostString("overtime");
  211. if (overtime == "1")
  212. {
  213. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  214. }
  215. String usePost = CurrentUser.UserPost.Post.Code;
  216. if (usePost.Equals("Operation") == true)
  217. {
  218. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  219. }
  220. else
  221. {
  222. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. //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";
  225. if (dStruct.PageSize == 100000)
  226. {
  227. dStruct.Order = "";
  228. }
  229. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  230. DataTable dt = null;
  231. string tablename = "view_orderlist";
  232. if (isFinish)
  233. {
  234. tablename = "view_orderlist_end";
  235. }
  236. dt = WebCache.GetData(tablename, dStruct);
  237. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  238. if (dt != null && dt.Rows.Count > 0)
  239. {
  240. foreach (DataRow dr in dt.Rows)
  241. {
  242. try
  243. {
  244. if (dr["refund_fees"] != null)
  245. {
  246. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  247. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  248. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  249. if (payment == refund_fees)
  250. {
  251. dr["refund_fees"] = Math.Round(refund_fees, 2);
  252. continue; // 跳过当前迭代
  253. }
  254. else if (refund_fees == total_fee)
  255. {
  256. dr["refund_fees"] = payment;
  257. continue; // 跳过当前迭代
  258. }
  259. else
  260. {
  261. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  262. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  263. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  264. }
  265. }
  266. // 对象操作
  267. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  268. ceErpTradeCell.ctid = dr["ctid"].ToString();
  269. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  270. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  271. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  272. if (dStruct.PageSize != 100000)
  273. {
  274. if (dr["DispatchSort"].ToString() == "2")
  275. {
  276. dr["gongchuang"] = 200;
  277. }
  278. else
  279. {
  280. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  281. dr["gongchuang"] = response.code;
  282. }
  283. }
  284. }
  285. catch (NullReferenceException ex)
  286. {
  287. // 处理空引用异常
  288. dr["refund_fees"] = "0.00";
  289. }
  290. }
  291. }
  292. writeGridDataTableJson(dStruct.TotalCount, dt);
  293. }
  294. public void get_erp_orderlist_sumprice()
  295. {
  296. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  297. return;
  298. List<string> lw = new List<string>();
  299. string tid = GetPostString("ctid");
  300. string date1 = GetPostString("date1");
  301. string date2 = GetPostString("date2");
  302. if (tid.Length > 0 || date1.Length > 0)
  303. {
  304. lw.Add(string.Format("ctid like '%{0}%'", tid));
  305. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  306. if (dw.Length > 0) lw.Add(dw);
  307. }
  308. else
  309. {
  310. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  311. }
  312. string shopname = GetPostString("shopname");
  313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  314. string buyernick = GetPostString("buyer_nick");
  315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  316. string customer = GetPostString("customer");
  317. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  318. string design = GetPostString("design");
  319. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  320. string orderState = GetPostString("orderState");
  321. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  322. string address = GetPostString("address");
  323. 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));
  324. string sellermemo = GetPostString("seller_memo");
  325. if (sellermemo.Length > 0)
  326. {
  327. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  328. }
  329. string apdate1 = GetPostString("apdate1");
  330. string apdate2 = GetPostString("apdate2");
  331. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  332. if (dwap.Length > 0) lw.Add(dwap);
  333. string price1 = GetPostString("price1");
  334. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  335. string price2 = GetPostString("price2");
  336. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  337. string isoldcustomer = GetPostString("isoldcus");
  338. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  339. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  340. if (PKey != "admin")
  341. {
  342. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  343. lw.Add(string.Format("shopId in ({0})", usershop));
  344. }
  345. //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";
  346. string mainWhere = string.Join(" and ", lw.ToArray());
  347. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  348. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  349. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  350. decimal total = 0;
  351. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  352. {
  353. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  354. }
  355. var res = new
  356. {
  357. data = total
  358. };
  359. string ro_jsond = JsonConvert.SerializeObject(res);
  360. returnSuccess(ro_jsond);
  361. return;
  362. }
  363. public void get_erp_CustomerServiceGather()
  364. {
  365. string userWhere = "", orderWhere = "";
  366. List<string> lw = new List<string>();
  367. string customer = GetPostString("customer");
  368. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  369. string shopname = GetPostString("shopname");
  370. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  371. string date1 = GetPostString("date1");
  372. string date2 = GetPostString("date2");
  373. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  374. if (dw.Length > 0) lw.Add(dw);
  375. orderWhere = string.Join(" and ", lw.ToArray());
  376. 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 " +
  377. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  378. "left join " +
  379. "( " +
  380. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  381. ") as b on a.ID = b.CustomerUserId " +
  382. "left join " +
  383. "( " +
  384. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  385. ") as d on a.ID = d.CustomerUserId " +
  386. "left join " +
  387. "( " +
  388. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  389. ") as e on a.ID = e.CustomerUserId " +
  390. "left join " +
  391. "( " +
  392. " select CustomerUserId, RefundCount, RefundSum from " +
  393. " ( " +
  394. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  395. " from CE_ErpTradeRefund a " +
  396. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  397. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  398. " group by CustomerUserId " +
  399. " ) as a " +
  400. ") as f on a.ID = f.CustomerUserId " +
  401. "where a.PostCode = 'CustomerService'",
  402. userWhere, orderWhere);
  403. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  404. writeGridDataTableJson(dt.Rows.Count, dt);
  405. //writeGridDataTableJson(dt.Rows.Count, dt);
  406. }
  407. //设计汇总
  408. public void get_erp_DesignerGather()
  409. {
  410. string userWhere = "", orderWhere = "";
  411. List<string> lw = new List<string>();
  412. string Designer = GetPostString("designer");
  413. int org = GetPostInt("org");
  414. if (Designer.Length > 0)
  415. {
  416. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  417. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  418. }
  419. else if (org > 0)
  420. {
  421. userWhere = string.Format(" where OrgID ={0}", org);
  422. }
  423. string shopname = GetPostString("shopname");
  424. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  425. string state = GetPostString("state");
  426. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  427. string OrderArea = GetPostString("order_area");
  428. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  429. string date1 = GetPostString("date1");
  430. string date2 = GetPostString("date2");
  431. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  432. if (dw.Length > 0) lw.Add(dw);
  433. string UpDate1 = GetPostString("UpDate1");
  434. string UpDate2 = GetPostString("UpDate2");
  435. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  436. if (dw.Length > 0) lw.Add(dw);
  437. orderWhere = string.Join(" and ", lw.ToArray());
  438. 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 (" +
  439. "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 " +
  440. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  441. "left join " +
  442. "( " +
  443. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  444. ") as b on a.ID = b.DesignUserId " +
  445. "left join " +
  446. "( " +
  447. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  448. ") as d on a.ID = d.DesignUserId " +
  449. "left join " +
  450. "( " +
  451. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  452. ") as e on a.ID = e.DesignUserId " +
  453. "left join " +
  454. "( " +
  455. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  456. ") as g on a.ID = g.DesignUserId " +
  457. "left join " +
  458. "( " +
  459. " select CustomerUserId, RefundCount, RefundSum from " +
  460. " ( " +
  461. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  462. " from CE_ErpTradeRefund a " +
  463. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  464. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  465. " group by CustomerUserId " +
  466. " ) as a " +
  467. ") as f on a.ID = f.CustomerUserId " +
  468. "where a.PostCode = 'Designer') as z",
  469. userWhere, orderWhere);
  470. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  471. writeGridDataTableJson(dt.Rows.Count, dt);
  472. }
  473. //删除tradecell的订单
  474. public void del_erp_cellorder()
  475. {
  476. if (UrlPostParmsCheck("ctid"))
  477. {
  478. string eid = GetPostString("ctid");
  479. CeErpTradeCell.DelByCtid(eid);
  480. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  481. returnSuccessMsg("删除成功");
  482. }
  483. }
  484. public void clear_erp_refundstate()
  485. {
  486. if (UrlPostParmsCheck("ids"))
  487. {
  488. string eids = GetPostString("ids");
  489. string[] ctidList = eids.Split(',');
  490. foreach (string ctid in ctidList)
  491. {
  492. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  493. if (entity != null)
  494. {
  495. entity.IsRefund = 0;
  496. entity.Update();
  497. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  498. }
  499. else
  500. continue;
  501. }
  502. returnSuccessMsg("操作成功");
  503. return;
  504. }
  505. returnErrorMsg("缺少必要参数");
  506. }
  507. public void set_erp_urgency()
  508. {
  509. if (UrlPostParmsCheck("ctid"))
  510. {
  511. string eid = GetPostString("ctid");
  512. CeErpTradeCell entity = null;
  513. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  514. if (entity != null)
  515. {
  516. string utime = GetPostString("urgencytime");
  517. if (utime.Length > 0)
  518. {
  519. entity.UrgencyTime = Convert.ToDateTime(utime);
  520. }
  521. else
  522. {
  523. returnErrorMsg("请选择加急时间");
  524. return;
  525. }
  526. if (entity.OrderState <= 4)
  527. {
  528. //entity.seller_memo = entity.seller_memo + "-加急";
  529. string smemo = entity.seller_memo;
  530. int kindex = smemo.IndexOf(")");
  531. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  532. if (lastoneStr != "-")
  533. {
  534. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  535. }
  536. string prememo = smemo.Substring(0, kindex + 2);
  537. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  538. int lastkindex = lastmemo.IndexOf("(");
  539. DateTime urgtime = Convert.ToDateTime(utime);
  540. string newlastmemo = "";
  541. if (lastkindex == 0)
  542. {
  543. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  544. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  545. }
  546. else
  547. {
  548. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  549. }
  550. entity.seller_memo = prememo + newlastmemo;
  551. }
  552. entity.IsUrgency = true;
  553. entity.Update();
  554. ApiVo apiVo = new ApiVo();
  555. apiVo.orderNumber = entity.ctid;
  556. apiVo.actionName = "changeDesign";
  557. apiVo.orderRemarks = entity.seller_memo;
  558. apiVo.remarkSign = 3;
  559. designHelper.API_WorkCore(apiVo); //changeDesign
  560. CeErpSukuraData.createInfo(entity.ctid, 7);
  561. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  562. returnSuccessMsg("设置成功!");
  563. return;
  564. }
  565. returnErrorMsg("找不到记录");
  566. }
  567. }
  568. public void set_erp_reset()
  569. {
  570. if (UrlPostParmsCheck("ctid"))
  571. {
  572. string eid = GetPostString("ctid");
  573. CeErpTradeCell entity = null;
  574. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  575. if (entity != null)
  576. {
  577. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  578. {
  579. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  580. {
  581. returnErrorMsg("财务要求已下单已发货无法重置");
  582. return;
  583. }
  584. }
  585. entity.IsUrgency = false;
  586. entity.seller_memo = "";
  587. entity.OtherMemo = "";
  588. entity.OrderState = 0;
  589. entity.IsReturn = 0;
  590. //entity.IsRefund = 0;
  591. entity.MemoOpt = 0;
  592. entity.AfterSaleState = 0;
  593. entity.AfterSaleResponsible = "";
  594. entity.AfterSaleUserId = 0;
  595. entity.IsNeedBill = 0;
  596. entity.CustomerUserId = 0;
  597. entity.DesignUserId = 0;
  598. entity.SupplierId = 0;
  599. entity.PlaceUserId = 0;
  600. entity.ptid = "";
  601. entity.IsSample = 0;
  602. entity.IsXianHuo = 0;
  603. entity.isDianziOrder = 0;
  604. entity.DispatchSort = 0;
  605. entity.FinishPlaceTime = null;
  606. entity.Update();
  607. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  608. if (trade != null)
  609. {
  610. trade.seller_memo = "";
  611. trade.Update();
  612. }
  613. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  614. returnSuccessMsg("重置成功!");
  615. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  616. if (desginBill != null)
  617. {
  618. desginBill.isDel = 1;
  619. desginBill.Update();
  620. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  621. }
  622. ApiVo apiVo = new ApiVo();
  623. apiVo.orderNumber = entity.ctid;
  624. apiVo.actionName = "resetDesign";
  625. designHelper.API_WorkCore(apiVo);//resetDesign
  626. return;
  627. }
  628. returnErrorMsg("找不到记录");
  629. }
  630. }
  631. public void save_erp_sellermemo()
  632. {
  633. if (UrlPostParmsCheck("ctid"))
  634. {
  635. string ctid = GetPostString("ctid");
  636. CeErpTradeCell entity = null;
  637. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  638. if (entity != null)
  639. {
  640. string memo = GetPostString("seller_memo");
  641. memo = memo.Replace(" ", "");
  642. if (memo.Contains("补差"))
  643. {
  644. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  645. return;
  646. }
  647. if (entity.seller_memo != memo)
  648. {
  649. if (entity.IsSample == 2)
  650. {
  651. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  652. return;
  653. }
  654. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  655. {
  656. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  657. {
  658. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  659. return;
  660. }
  661. }
  662. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  663. }
  664. commonHelper.getCytPrice(entity);
  665. int memoopt = GetPostInt("MemoOpt");
  666. Boolean ismemoopt = false;
  667. if (memoopt > 0)
  668. {
  669. string stropt = "";
  670. if (memoopt == 1)
  671. {
  672. stropt = "“改稿”";
  673. ismemoopt = true;
  674. }
  675. else if (memoopt == 2)
  676. {
  677. stropt = "“定稿”";
  678. }
  679. else if (memoopt == 3)
  680. {
  681. stropt = "“查货”";
  682. CeErpSukuraData.createInfo(entity.ctid, 6);
  683. }
  684. entity.MemoOpt = Convert.ToInt32(memoopt);
  685. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  686. }
  687. if (entity.OrderState < 5)
  688. {
  689. memo = memo.Replace("(", "(");
  690. memo = memo.Replace(")", ")");
  691. }
  692. entity.seller_memo = memo;
  693. entity.Update();
  694. ApiVo apiVo = new ApiVo();
  695. apiVo.orderNumber = entity.ctid;
  696. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  697. apiVo.orderRemarks = memo;
  698. apiVo.remarkSign = memoopt;
  699. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  700. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  701. returnSuccessMsg("保存成功!");
  702. return;
  703. }
  704. returnErrorMsg("找不到记录");
  705. }
  706. }
  707. public void ins_erp_checkorder()
  708. {
  709. if (UrlPostParmsCheck("ctid"))
  710. {
  711. string ctid = GetPostString("ctid");
  712. CeErpTradeCell entity = null;
  713. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  714. if (entity != null)
  715. {
  716. if (entity.OrderState < 6)
  717. {
  718. returnErrorMsg("下单完成后才可查货");
  719. return;
  720. }
  721. /*if (entity.OrderState > 6)
  722. {
  723. returnErrorMsg("订单已发货");
  724. return;
  725. }*/
  726. if (entity.FinishPlaceTime != null)
  727. {
  728. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  729. {
  730. returnErrorMsg("下单时间不足,无法查货");
  731. return;
  732. }
  733. }
  734. entity.MemoOpt = 3;
  735. entity.CheckOrderTime = DateTime.Now;
  736. entity.Update();
  737. CeErpSukuraData.createInfo(entity.ctid, 6);
  738. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  739. returnSuccessMsg("操作成功!");
  740. return;
  741. }
  742. returnErrorMsg("找不到记录");
  743. }
  744. }
  745. public void save_erp_othermemo()
  746. {
  747. if (UrlPostParmsCheck("ctid"))
  748. {
  749. string ctid = GetPostString("ctid");
  750. CeErpTradeCell entity = null;
  751. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  752. if (entity != null)
  753. {
  754. entity.OtherMemo = GetPostString("otherMemo");
  755. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  756. {
  757. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  758. StringBuilder sql = new StringBuilder();
  759. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  760. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  761. if (dt != null && dt.Rows.Count > 0)
  762. {
  763. foreach (DataRow dr in dt.Rows)
  764. {
  765. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  766. {
  767. //品类一直
  768. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  769. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  770. if (ceErpSampleCustomer == null)
  771. {
  772. ceErpSampleCustomer = new CeErpSampleCustomer();
  773. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  774. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  775. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  776. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  777. ceErpSampleCustomer.shopId = entity.ShopId;
  778. }
  779. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  780. ceErpSampleCustomer.lastTid = entity.tid;
  781. if (ceErpSampleCustomer.ID > 0)
  782. {
  783. ceErpSampleCustomer.Update();
  784. }
  785. else
  786. {
  787. ceErpSampleCustomer.Create();
  788. }
  789. }
  790. }
  791. }
  792. }
  793. //if (entity.IsOldCustomer == 1)
  794. //{
  795. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  796. //{
  797. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  798. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  799. //}
  800. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  801. //{
  802. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  803. // {
  804. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  805. // {
  806. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  807. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  808. // }
  809. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  810. // {
  811. // entity.OrderState = 2;
  812. // entity.DesignUserId = 0;
  813. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  814. // }
  815. // else
  816. // {
  817. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  818. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  819. // }
  820. // }
  821. //}
  822. //}
  823. entity.Update();
  824. returnSuccessMsg("保存成功!");
  825. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  826. return;
  827. }
  828. returnErrorMsg("找不到记录");
  829. }
  830. }
  831. public void save_erp_customermemo()
  832. {
  833. if (UrlPostParmsCheck("ctid"))
  834. {
  835. string ctid = GetPostString("ctid");
  836. CeErpTradeCell entity = null;
  837. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  838. if (entity != null)
  839. {
  840. entity.CustomerMemo = GetPostString("CustomerMemo");
  841. entity.Update();
  842. ApiVo apiVo = new ApiVo();
  843. apiVo.orderNumber = entity.ctid;
  844. apiVo.actionName = "followRemarks";
  845. apiVo.orderRemarks = entity.CustomerMemo;
  846. designHelper.API_WorkCore(apiVo);//followRemarks
  847. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  848. returnSuccessMsg("保存成功!");
  849. return;
  850. }
  851. returnErrorMsg("找不到记录");
  852. }
  853. }
  854. public void upd_erp_addmemotag()
  855. {
  856. if (UrlPostParmsCheck("ctid"))
  857. {
  858. ;
  859. string eid = GetPostString("ctid");
  860. string sfTagstr = GetPostString("memotag");
  861. CeErpTradeCell entity = null;
  862. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  863. if (entity != null)
  864. {
  865. if (entity.OrderState == 0)
  866. {
  867. returnErrorMsg("请先领单");
  868. return;
  869. }
  870. //撤销顺丰
  871. if (sfTagstr == "撤销顺丰")
  872. {
  873. entity.IsSF = 0;
  874. string reMsg = "";
  875. string oldmemo = entity.seller_memo;
  876. if (entity.OrderState < 5)
  877. {
  878. oldmemo = oldmemo.Replace("顺丰到付", "");
  879. oldmemo = oldmemo.Replace("顺丰寄付", "");
  880. entity.seller_memo = oldmemo;
  881. }
  882. else
  883. {
  884. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  885. {
  886. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  887. }
  888. }
  889. entity.Update();
  890. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  891. api.orderNumber = entity.ctid;
  892. api.actionName = "followRemarks";
  893. api.orderRemarks = entity.seller_memo;
  894. api.isSf = entity.IsSF.ToString();
  895. designHelper.API_WorkCore(api);//followRemarks
  896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  897. returnSuccessMsg("撤销成功!" + reMsg);
  898. return;
  899. }
  900. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  901. {
  902. //string oldmemo = entity.seller_memo;
  903. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  904. string sfStr = GetPostString("memotag");
  905. string smemo = entity.seller_memo;
  906. int kindex = smemo.IndexOf(")");
  907. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  908. if (lastoneStr != "-")
  909. {
  910. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  911. }
  912. string prememo = smemo.Substring(0, kindex + 2);
  913. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  914. int lastkindex = lastmemo.IndexOf("(");
  915. string newlastmemo = "";
  916. if (lastkindex == 0)
  917. {
  918. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  919. newlastmemo = "(" + sfStr + "." + useLastmemo;
  920. }
  921. else
  922. {
  923. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  924. }
  925. entity.seller_memo = prememo + newlastmemo;
  926. }
  927. string sfTagMSg = "";
  928. if (sfTagstr == "顺丰寄付")
  929. {
  930. entity.IsSF = 1;
  931. sfTagMSg = "顺丰寄付";
  932. }
  933. else if (sfTagstr == "顺丰到付")
  934. {
  935. entity.IsSF = 2;
  936. sfTagMSg = "顺丰到付";
  937. }
  938. entity.Update();
  939. ApiVo apiVo = new ApiVo();
  940. apiVo.orderNumber = entity.ctid;
  941. apiVo.actionName = "orderRemarks";
  942. apiVo.orderRemarks = entity.seller_memo;
  943. apiVo.isSf = entity.IsSF.ToString();
  944. designHelper.API_WorkCore(apiVo);//orderRemarks
  945. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  946. returnSuccessMsg("标记成功!");
  947. return;
  948. }
  949. returnErrorMsg("找不到记录");
  950. }
  951. }
  952. public void upd_erp_ordertag()
  953. {
  954. if (UrlPostParmsCheck("ctid"))
  955. {
  956. string eid = GetPostString("ctid");
  957. CeErpTradeCell entity = null;
  958. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  959. if (entity != null)
  960. {
  961. int tag = GetPostInt("wechattag");
  962. //if(tag==4 && entity.IsSample == 2)
  963. //{
  964. // returnErrorMsg("补差价单不能标记微信单");
  965. // return;
  966. //}
  967. entity.wechatTag = tag;
  968. entity.Update();
  969. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  970. if (tag == 1)
  971. {
  972. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  973. if (cash == null)
  974. {
  975. CeErpTrade main = CeErpTrade.Get(entity.tid);
  976. cash = new CeErpReturnCash();
  977. cash.tid = entity.tid;
  978. cash.seller_nick = main.seller_nick;
  979. cash.payment = trade.payment;
  980. cash.buyer_nick = main.buyer_nick;
  981. cash.cashstate = 0;
  982. cash.rtype = "微信返现";
  983. cash.returnprice = 0;
  984. cash.created = DateTime.Now;
  985. cash.con = "订单标记微信单";
  986. cash.img = "";
  987. cash.applyuserid = CurrentUser.UserID;
  988. cash.Create();
  989. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  990. }
  991. else
  992. {
  993. cash.cashstate = 0;
  994. cash.Update();
  995. }
  996. CeErpSukuraData.createInfo(entity.ctid, 9);
  997. }
  998. else if (tag == 2)
  999. {
  1000. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1001. if (cash == null)
  1002. {
  1003. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1004. cash = new CeErpReturnCash();
  1005. cash.tid = entity.tid;
  1006. cash.seller_nick = main.seller_nick;
  1007. cash.payment = trade.payment;
  1008. cash.buyer_nick = main.buyer_nick;
  1009. cash.cashstate = 0;
  1010. cash.rtype = "推购返现";
  1011. cash.returnprice = 5;
  1012. cash.created = DateTime.Now;
  1013. cash.con = "订单标记推购单";
  1014. cash.img = "";
  1015. cash.applyuserid = CurrentUser.UserID;
  1016. cash.Create();
  1017. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1018. }
  1019. else
  1020. {
  1021. cash.cashstate = 0;
  1022. cash.Update();
  1023. }
  1024. CeErpSukuraData.createInfo(entity.ctid, 9);
  1025. }
  1026. else if (tag == 3)
  1027. {
  1028. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1029. if (pers == null)
  1030. {
  1031. pers = new CeErpPersuade();
  1032. pers.ctid = entity.ctid;
  1033. pers.pstate = 0;
  1034. pers.created = DateTime.Now;
  1035. pers.applyuserid = CurrentUser.UserID;
  1036. pers.Create();
  1037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1038. }
  1039. else
  1040. {
  1041. pers.pstate = 0;
  1042. pers.Update();
  1043. }
  1044. }
  1045. else if (tag == 4 || tag == 5)
  1046. {
  1047. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1048. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1049. if (pers == null)
  1050. {
  1051. pers = new CeErpStayGoods();
  1052. pers.t_id = entity.tid;
  1053. pers.status = "待审核";
  1054. pers.audit_type = 0;
  1055. if (tag == 4)
  1056. {
  1057. pers.stay_type = "微信推购";
  1058. }
  1059. else
  1060. {
  1061. pers.stay_type = "旺旺推购";
  1062. }
  1063. if (entity.IsXianHuo == 0)
  1064. {
  1065. pers.product_id = entity.ProductId;
  1066. }
  1067. pers.wangwang = main.buyer_nick;
  1068. pers.shop_name = main.seller_nick;
  1069. pers.creata_time = DateTime.Now;
  1070. pers.create_u_id = CurrentUser.UserID;
  1071. pers.create_u_name = CurrentUser.UserName;
  1072. pers.Create();
  1073. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1074. }
  1075. else
  1076. {
  1077. pers.audit_type = 0;
  1078. pers.Update();
  1079. }
  1080. CeErpSukuraData.createInfo(entity.ctid, 10);
  1081. }
  1082. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1083. returnSuccessMsg("标记成功!");
  1084. return;
  1085. }
  1086. returnErrorMsg("找不到记录");
  1087. }
  1088. }
  1089. public void upd_erp_ordertag_cancel()
  1090. {
  1091. if (UrlPostParmsCheck("ctid"))
  1092. {
  1093. string eid = GetPostString("ctid");
  1094. CeErpTradeCell entity = null;
  1095. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1096. if (entity != null)
  1097. {
  1098. entity.wechatTag = 0;
  1099. entity.Update();
  1100. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1101. if (pers != null)
  1102. {
  1103. pers.status = "取消推购";
  1104. pers.audit_type = 3;
  1105. pers.Update();
  1106. }
  1107. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1108. returnSuccessMsg("标记成功!");
  1109. return;
  1110. }
  1111. returnErrorMsg("找不到记录");
  1112. }
  1113. }
  1114. public void upd_erp_addweichattag()
  1115. {
  1116. if (UrlPostParmsCheck("ctid"))
  1117. {
  1118. ;
  1119. string eid = GetPostString("ctid");
  1120. CeErpTradeCell entity = null;
  1121. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1122. if (entity != null)
  1123. {
  1124. if (entity.IsAddWechat > 0)
  1125. {
  1126. returnErrorMsg("此单已经标记过了");
  1127. return;
  1128. }
  1129. 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);
  1130. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1131. if (dt.Rows.Count > 0)
  1132. {
  1133. entity.IsAddWechat = 2;
  1134. }
  1135. else
  1136. {
  1137. entity.IsAddWechat = 1;
  1138. }
  1139. entity.Update();
  1140. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1141. returnSuccessMsg("标记成功!");
  1142. return;
  1143. }
  1144. returnErrorMsg("找不到记录");
  1145. }
  1146. }
  1147. public void upd_erp_getmyorder()
  1148. {
  1149. if (UrlPostParmsCheck("ctid"))
  1150. {
  1151. ;
  1152. string eid = GetPostString("ctid");
  1153. CeErpTradeCell entity = null;
  1154. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1155. if (entity != null)
  1156. {
  1157. if (entity.ctid.IndexOf("C") != -1)
  1158. {
  1159. StringBuilder sql = new StringBuilder();
  1160. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1161. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1162. if (dt.Rows.Count > 0)
  1163. {
  1164. decimal total = 0;
  1165. foreach (DataRow dr in dt.Rows)
  1166. {
  1167. total += Convert.ToDecimal(dr["payment"]);
  1168. }
  1169. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1170. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1171. {
  1172. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1173. return;
  1174. }
  1175. }
  1176. }
  1177. entity.CustomerUserId = CurrentUser.UserID;
  1178. if (entity.OrderState < 2)
  1179. {
  1180. entity.OrderState = 2;
  1181. if (entity.ShopId != 0)
  1182. {
  1183. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1184. }
  1185. }
  1186. entity.Update();
  1187. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1188. returnSuccessMsg("领单成功!");
  1189. return;
  1190. }
  1191. returnErrorMsg("找不到记录");
  1192. }
  1193. }
  1194. public void getmyorder_from_init()
  1195. {
  1196. if (UrlPostParmsCheck("ctid"))
  1197. {
  1198. string eid = GetPostString("ctid");
  1199. CeErpTradeCell entity = null;
  1200. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1201. if (entity != null)
  1202. {
  1203. string sellerMemo = GetPostString("sellerMemo");
  1204. if (sellerMemo.Length > 0)
  1205. {
  1206. entity.seller_memo = sellerMemo;
  1207. }
  1208. string oterhMemo = GetPostString("otherMemo");
  1209. if (oterhMemo.Length > 0)
  1210. {
  1211. entity.OtherMemo = oterhMemo;
  1212. }
  1213. int urg = GetPostInt("urgency");
  1214. entity.IsUrgency = (urg == 1 ? true : false);
  1215. int wechat = GetPostInt("wechat");
  1216. int command = GetPostInt("command");
  1217. if (wechat == 1)
  1218. {
  1219. entity.wechatTag = 1;
  1220. }
  1221. if (command == 1)
  1222. {
  1223. entity.wechatTag = 2;
  1224. }
  1225. string pPro = GetPostString("pprofession");
  1226. if (pPro.Length > 0)
  1227. {
  1228. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1229. string spro = GetPostString("profession");
  1230. if (spro.Length > 0)
  1231. {
  1232. entity.ProfessionId = Convert.ToInt32(spro);
  1233. }
  1234. }
  1235. string proId = GetPostString("productId");
  1236. if (proId.Length > 0)
  1237. {
  1238. entity.ProductId = Convert.ToInt32(proId);
  1239. }
  1240. entity.Material = GetPostString("material");
  1241. entity.Craft = GetPostString("craft");
  1242. entity.CustomerUserId = CurrentUser.UserID;
  1243. if (entity.OrderState < 2)
  1244. {
  1245. entity.OrderState = 2;
  1246. if (entity.ShopId != 0)
  1247. {
  1248. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1249. }
  1250. }
  1251. entity.Update();
  1252. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1253. returnSuccessMsg("领单成功!");
  1254. return;
  1255. }
  1256. returnErrorMsg("找不到记录");
  1257. }
  1258. }
  1259. public void upd_erp_setrelationorder()
  1260. {
  1261. if (UrlPostParmsCheck("ctid"))
  1262. {
  1263. ;
  1264. string eid = GetPostString("ctid");
  1265. string ftid = GetPostString("ftid");
  1266. CeErpTradeCell entity = null;
  1267. CeErpTradeCell fentity = null;
  1268. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1269. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1270. if (fentity == null)
  1271. {
  1272. returnErrorMsg("找不到关联的主订单");
  1273. return;
  1274. }
  1275. if (entity != null)
  1276. {
  1277. if (entity.OrderState >= 5)
  1278. {
  1279. returnErrorMsg("本单已经设计完成无法关联");
  1280. return;
  1281. }
  1282. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1283. {
  1284. returnErrorMsg("线下单续审核后才能关联!");
  1285. return;
  1286. }
  1287. entity.ptid = ftid;
  1288. entity.OrderState = fentity.OrderState;
  1289. //entity.status = fentity.status;
  1290. entity.CustomerUserId = fentity.CustomerUserId;
  1291. entity.DesignUserId = fentity.DesignUserId;
  1292. entity.seller_memo = "补差价单:" + ftid;
  1293. entity.IsSample = 2;
  1294. entity.Update();
  1295. ApiVo apiVo = new ApiVo();
  1296. apiVo.orderNumber = ftid;
  1297. apiVo.payment = entity.payment;
  1298. apiVo.actionName = "repairDesign";
  1299. designHelper.API_WorkCore(apiVo);//repairDesign
  1300. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1301. returnSuccessMsg("关联成功!");
  1302. return;
  1303. }
  1304. else
  1305. returnErrorMsg("找不到记录");
  1306. }
  1307. }
  1308. public void download_erp_neworder()
  1309. {
  1310. string seller = GetPostString("seller_nick");
  1311. string tid = GetPostString("tid");
  1312. if (seller.Length <= 0 || tid.Length <= 0)
  1313. {
  1314. returnErrorMsg("数据错误");
  1315. }
  1316. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1317. //{
  1318. // returnErrorMsg("找不到店铺Sessionkey");
  1319. //}
  1320. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1321. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1322. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1323. if (res.IndexOf("refOid") == -1)
  1324. {
  1325. returnErrorMsg("下载订单数据失败");
  1326. return;
  1327. }
  1328. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1329. returnSuccessMsg("下载完成");
  1330. //tmcHelper.createNewOrder(res);
  1331. //CeErpTrade entr = null;
  1332. //entr = CeErpTrade.Get(tid);
  1333. //if (entr != null)
  1334. //{
  1335. // returnSuccess("下载成功");
  1336. // //下载成功之后,Cell表生成对应的订单;
  1337. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1338. //}
  1339. //else
  1340. //{
  1341. // returnErrorMsg("下载失败或者创建订单失败");
  1342. //}
  1343. }
  1344. public void set_erp_atersale()
  1345. {
  1346. if (UrlPostParmsCheck("ctid"))
  1347. {
  1348. string eid = GetPostString("ctid");
  1349. string reason = GetPostString("AfterSaleReason");
  1350. CeErpTradeCell entity = null;
  1351. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1352. if (entity != null)
  1353. {
  1354. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1355. {
  1356. returnErrorMsg("此订单已经在售后");
  1357. return;
  1358. }
  1359. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1360. //entity.AfterSaleReason = reason;
  1361. entity.AfterSaleTime = DateTime.Now;
  1362. entity.Update();
  1363. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1364. returnSuccessMsg("转售后成功!");
  1365. return;
  1366. }
  1367. returnErrorMsg("找不到记录");
  1368. }
  1369. }
  1370. public void set_erp_withdraw()
  1371. {
  1372. if (UrlPostParmsCheck("ctid"))
  1373. {
  1374. try
  1375. {
  1376. string eid = GetPostString("ctid");//商品id
  1377. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1378. CeWithdraw ceWithdrawSelect = null;
  1379. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1380. if (ceWithdrawSelect != null)
  1381. {
  1382. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1383. {
  1384. ceWithdrawSelect.status = -1;
  1385. ceWithdrawSelect.Update();
  1386. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1387. returnSuccessMsg("重新发起审核成功");
  1388. return;
  1389. }
  1390. else
  1391. {
  1392. returnSuccessMsg("请勿重复申请!");
  1393. return;
  1394. }
  1395. }
  1396. else
  1397. {
  1398. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1399. if (string.IsNullOrEmpty(CustomerUserId))
  1400. {
  1401. CustomerUserId = "-1";
  1402. }
  1403. int Userid = CurrentUser.UserID;//用户id
  1404. CeWithdraw ceWithdraw = new CeWithdraw();
  1405. ceWithdraw.tid = eid;
  1406. ceWithdraw.userid = Userid;
  1407. ceWithdraw.providerid = CustomerUserId;
  1408. ceWithdraw.status = 3;
  1409. ceWithdraw.creationtime = DateTime.Now;
  1410. ceWithdraw.Create();
  1411. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1412. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1413. return;
  1414. }
  1415. }
  1416. catch
  1417. {
  1418. returnErrorMsg("申请撤回订单失败");
  1419. return;
  1420. }
  1421. }
  1422. }
  1423. public void ins_erp_billinfo()
  1424. {
  1425. if (UrlPostParmsCheck("ctid"))
  1426. {
  1427. string eid = GetPostString("ctid");
  1428. CeErpTradeCell entity = null;
  1429. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1430. if (entity != null)
  1431. {
  1432. CeErpBill bill = CeErpBill.GetByTid(eid);
  1433. bool isHave = false;
  1434. if (bill != null)
  1435. {
  1436. isHave = true;
  1437. if (bill.state != 4)
  1438. {
  1439. returnErrorMsg("此单已经申请过发票了");
  1440. return;
  1441. }
  1442. }
  1443. if (entity.IsNeedBill == 0)
  1444. {
  1445. entity.IsNeedBill = 1;
  1446. }
  1447. entity.Update();
  1448. string errjson = "";
  1449. try
  1450. {
  1451. CeErpBill bill_entity = new CeErpBill();
  1452. bill_entity.tid = entity.tid;
  1453. bill_entity.title = GetPostString("title");
  1454. string taxstr = GetPostString("tax");
  1455. taxstr = taxstr.Replace(" ", "");
  1456. bill_entity.tax = taxstr;
  1457. bill_entity.bank = GetPostString("bank");
  1458. string bankacstr = GetPostString("bankac");
  1459. bankacstr = bankacstr.Replace(" ", "");
  1460. bill_entity.bankac = bankacstr;
  1461. bill_entity.address = GetPostString("address");
  1462. bill_entity.phone = GetPostString("phone");
  1463. bill_entity.price = GetPostString("price");
  1464. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1465. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1466. {
  1467. billCount += 1;
  1468. }
  1469. string prebill = "ltb";
  1470. for (int idx = 1; idx <= billCount; idx++)
  1471. {
  1472. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1473. string billoid = prebill + idx + dtstr;
  1474. bill_entity.billOrderId += billoid;
  1475. if (idx < billCount)
  1476. {
  1477. bill_entity.billOrderId += ",";
  1478. }
  1479. }
  1480. bill_entity.productId = GetPostInt("ProductName");
  1481. bill_entity.num = GetPostInt("num");
  1482. bill_entity.unit = GetPostString("unit");
  1483. bill_entity.type = GetPostString("type");
  1484. bill_entity.sendType = GetPostString("SendType");
  1485. bill_entity.email = GetPostString("email");
  1486. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1487. bill_entity.shopName = GetPostString("ShopName");
  1488. bill_entity.applymemo = GetPostString("applyMemo");
  1489. bill_entity.createTime = DateTime.Now;
  1490. bill_entity.state = 0;
  1491. bill_entity.userId = CurrentUser.UserID;
  1492. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1493. bill_entity.Create();
  1494. }
  1495. catch (Exception ex)
  1496. {
  1497. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1498. returnErrorMsg("创建发票出错!");
  1499. return;
  1500. }
  1501. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1502. returnSuccessMsg("发票申请成功!");
  1503. return;
  1504. }
  1505. returnErrorMsg("找不到记录");
  1506. }
  1507. }
  1508. public void ins_erp_neworder()
  1509. {
  1510. if (UrlPostParmsCheck("receiver_name"))
  1511. {
  1512. CeErpTrade entity = new CeErpTrade();
  1513. string plat_form = GetPostString("platform");
  1514. string preStr = "N_";
  1515. if (plat_form == "拼多多")
  1516. {
  1517. preStr = "P_";
  1518. }
  1519. else if (plat_form == "阿里巴巴")
  1520. {
  1521. preStr = "A_";
  1522. }
  1523. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1524. entity.seller_nick = GetPostString("seller_nick");
  1525. entity.buyer_nick = GetPostString("buyer_nick");
  1526. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1527. entity.total_fee = entity.payment;
  1528. entity.pay_time = DateTime.Now;
  1529. entity.status = "NOT_SHIPPED";
  1530. entity.receiver_name = GetPostString("receiver_name");
  1531. entity.receiver_mobile = GetPostString("receiver_mobile");
  1532. entity.receiver_state = GetPostString("receiver_state");
  1533. entity.receiver_city = GetPostString("receiver_city");
  1534. entity.receiver_district = GetPostString("receiver_district");
  1535. entity.receiver_address = GetPostString("receiver_address");
  1536. if (entity.receiver_state == "" || entity.receiver_city == "")
  1537. {
  1538. returnErrorMsg("收件地址不能为空");
  1539. return;
  1540. }
  1541. int shopId = 0;
  1542. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1543. if (nShop != null)
  1544. {
  1545. shopId = nShop.ID;
  1546. }
  1547. if (shopId != 34 && entity.payment == 0)
  1548. {
  1549. returnErrorMsg("公司自用的单金额才能为0");
  1550. return;
  1551. }
  1552. entity.Create();
  1553. CeErpTradeCell entitycell = new CeErpTradeCell();
  1554. entitycell.ctid = entity.tid;
  1555. entitycell.tid = entity.tid;
  1556. entitycell.ShopId = shopId;
  1557. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1558. entitycell.OrderState = 0;
  1559. entitycell.pay_time = entity.pay_time;
  1560. entitycell.IsOffLineOrder = 1;
  1561. entitycell.Create();
  1562. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1563. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1564. return;
  1565. }
  1566. }
  1567. public void ins_erp_neworder2()
  1568. {
  1569. if (UrlPostParmsCheck("receiver_name"))
  1570. {
  1571. //string plat_form = GetPostString("platform");
  1572. string preStr = "X_";
  1573. string memo = GetPostString("memo");
  1574. string productId = GetPostString("productId");
  1575. string primg = GetPostString("proofimg");
  1576. string sellerNick = GetPostString("seller_nick");
  1577. string addFrom = GetPostString("addfrom");
  1578. if (addFrom == "1")
  1579. {
  1580. preStr = "N_";
  1581. }
  1582. int shopId = 0;
  1583. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1584. if (nShop != null)
  1585. {
  1586. shopId = nShop.ID;
  1587. }
  1588. else
  1589. {
  1590. returnErrorMsg("找不到对应店铺");
  1591. return;
  1592. }
  1593. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1594. {
  1595. returnErrorMsg("必须上传付款凭证");
  1596. return;
  1597. }
  1598. CeErpTrade entity = new CeErpTrade();
  1599. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1600. entity.seller_nick = sellerNick;
  1601. entity.buyer_nick = GetPostString("buyer_nick");
  1602. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1603. entity.total_fee = entity.payment;
  1604. entity.pay_time = DateTime.Now;
  1605. entity.status = "NOT_SHIPPED";
  1606. entity.receiver_name = GetPostString("receiver_name");
  1607. entity.receiver_mobile = GetPostString("receiver_mobile");
  1608. entity.receiver_state = GetPostString("receiver_state");
  1609. entity.receiver_city = GetPostString("receiver_city");
  1610. entity.receiver_district = GetPostString("receiver_district");
  1611. entity.receiver_address = GetPostString("receiver_address");
  1612. entity.seller_memo = memo;
  1613. entity.orderFrom = 20;
  1614. entity.orderType = 15;
  1615. if (entity.receiver_state == "" || entity.receiver_city == "")
  1616. {
  1617. returnErrorMsg("收件地址不能为空");
  1618. return;
  1619. }
  1620. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1621. {
  1622. returnErrorMsg("公司自用的单金额才能为0");
  1623. return;
  1624. }
  1625. entity.Create();
  1626. string toWhere = GetPostString("towhere");
  1627. CeErpTradeCell entitycell = new CeErpTradeCell();
  1628. entitycell.ctid = entity.tid;
  1629. //唯一标识
  1630. entitycell.OrderSn = entity.tid;
  1631. //string orderSn = dataHelper.getSaleOrderSn();
  1632. //if (orderSn != "")
  1633. // {
  1634. // entitycell.OrderSn = orderSn;
  1635. // }
  1636. entitycell.tid = entity.tid;
  1637. //if (preStr == "X_")
  1638. //{
  1639. entitycell.IsOffLineOrder = 1;
  1640. //}
  1641. entitycell.CustomerUserId = CurrentUser.UserID;
  1642. entitycell.PayProofImg = primg;
  1643. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1644. entitycell.ProductId = Convert.ToInt32(productId);
  1645. entitycell.ShopId = shopId;
  1646. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1647. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1648. {
  1649. entitycell.IsXianHuo = 1;
  1650. }
  1651. entitycell.pay_time = entity.pay_time;
  1652. if (toWhere == "1")
  1653. {
  1654. entitycell.OrderState = 2;
  1655. }
  1656. else
  1657. {
  1658. entitycell.OrderState = 6;
  1659. entitycell.FinishPlaceTime = entitycell.pay_time;
  1660. }
  1661. if (shopId == 94)
  1662. {
  1663. entitycell.OrderState = 4;
  1664. entitycell.WaitDesignTime = entitycell.pay_time;
  1665. entitycell.StartDesignTime = entitycell.pay_time;
  1666. entitycell.DesignUserId = 218;
  1667. }
  1668. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1669. {
  1670. entitycell.OrderState = -1;//修改12-5
  1671. CeWithdraw ceWithdraw = new CeWithdraw();
  1672. ceWithdraw.tid = entity.tid;
  1673. ceWithdraw.providerid = "-1";
  1674. ceWithdraw.status = -1;
  1675. ceWithdraw.creationtime = DateTime.Now;
  1676. ceWithdraw.userid = 1337;
  1677. ceWithdraw.Create();
  1678. }
  1679. entitycell.Create();
  1680. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1681. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1682. {
  1683. addPlaceRegist(entitycell, CurrentUser.UserID);
  1684. }
  1685. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1686. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1687. return;
  1688. }
  1689. }
  1690. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1691. {
  1692. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1693. entity.PlactTime = tradecell.pay_time;
  1694. entity.AddUserId = userid;
  1695. entity.FileName = tradecell.seller_memo;
  1696. entity.Supplier = 24;
  1697. entity.CreateTime = DateTime.Now;
  1698. entity.Did = tradecell.ctid;
  1699. entity.tid = tradecell.tid;
  1700. entity.splitTag = tradecell.SplitTag;
  1701. entity.CurState = "未完成";
  1702. entity.Create();
  1703. }
  1704. public void get_erp_offlinelist()
  1705. {
  1706. DataStruct dStruct = GetPostStruct();
  1707. List<string> lw = new List<string>();
  1708. string tid = GetPostString("ctid");
  1709. string date1 = GetPostString("date1");
  1710. string date2 = GetPostString("date2");
  1711. if (tid.Length > 0 || date1.Length > 0)
  1712. {
  1713. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1714. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1715. if (dw.Length > 0) lw.Add(dw);
  1716. }
  1717. else
  1718. {
  1719. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1720. }
  1721. string shopname = GetPostString("shopname");
  1722. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1723. string buyernick = GetPostString("buyer_nick");
  1724. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1725. string customer = GetPostString("customer");
  1726. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1727. string design = GetPostString("design");
  1728. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1729. string orderState = GetPostString("orderState");
  1730. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1731. string address = GetPostString("address");
  1732. 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));
  1733. string sellermemo = GetPostString("seller_memo");
  1734. if (sellermemo.Length > 0)
  1735. {
  1736. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1737. }
  1738. string price1 = GetPostString("price1");
  1739. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1740. string price2 = GetPostString("price2");
  1741. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1742. //if (PKey != "admin")
  1743. //{
  1744. // string usershop = CurrentUser.User.pemShop;
  1745. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1746. //}
  1747. //if (ex_psize > 0)
  1748. //{
  1749. dStruct.Order = "pay_time desc";
  1750. //}
  1751. //else
  1752. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1753. lw.Add(string.Format("IsOffLineOrder=1"));
  1754. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1755. DataTable dt = null;
  1756. dt = WebCache.GetData("view_erptradecell", dStruct);
  1757. writeGridDataTableJson(dStruct.TotalCount, dt);
  1758. }
  1759. public void get_erp_returncashrecord()
  1760. {
  1761. DataStruct dStruct = GetPostStruct();
  1762. List<string> lw = new List<string>();
  1763. string tid = GetPostString("ctid");
  1764. if (tid.Length > 0)
  1765. {
  1766. lw.Add(string.Format("tid like '%{0}%'", tid));
  1767. dStruct.Order = "id desc";
  1768. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1769. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1770. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1771. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1772. return;
  1773. }
  1774. returnErrorMsg("id数据错误!");
  1775. }
  1776. public void ins_erp_returncashrecord()
  1777. {
  1778. if (UrlPostParmsCheck("tid"))
  1779. {
  1780. string tid = GetPostString("tid");
  1781. string retype = GetPostString("type");
  1782. StringBuilder sql = new StringBuilder();
  1783. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1784. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1785. if (dt.Rows.Count > 0)
  1786. {
  1787. returnErrorMsg("相同返现类型记录已存在");
  1788. return;
  1789. }
  1790. CeErpReturnCash entity = new CeErpReturnCash();
  1791. entity.tid = tid;
  1792. entity.seller_nick = GetPostString("seller_nick");
  1793. string pment = GetPostString("payment");
  1794. if (pment.Length > 0)
  1795. {
  1796. entity.payment = Convert.ToDouble(pment);
  1797. }
  1798. entity.buyer_nick = GetPostString("buyer_nick");
  1799. entity.cashstate = 0;
  1800. entity.rtype = retype;
  1801. string rPrice = GetPostString("returnprice");
  1802. if (rPrice.Length > 0)
  1803. {
  1804. entity.returnprice = Convert.ToDouble(rPrice);
  1805. }
  1806. entity.created = DateTime.Now;
  1807. entity.con = GetPostString("con");
  1808. entity.img = GetPostString("img");
  1809. entity.applyuserid = CurrentUser.UserID;
  1810. entity.Create();
  1811. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1812. returnSuccessMsg("操作成功!");
  1813. return;
  1814. }
  1815. }
  1816. public void set_erp_predelivery()
  1817. {
  1818. if (UrlPostParmsCheck("ctid"))
  1819. {
  1820. string eid = GetPostString("ctid");
  1821. CeErpTradeCell entity = null;
  1822. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1823. if (entity != null)
  1824. {
  1825. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1826. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1827. //{
  1828. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1829. // return;
  1830. //}
  1831. entity.IsPreDelivery = 1;
  1832. entity.Update();
  1833. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1834. returnSuccessMsg("预发货成功!");
  1835. return;
  1836. //string shop = GetPostString("seller_nick");
  1837. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1838. //string comName = GetPostString("comName");
  1839. //string comCode = GetPostString("comCode");
  1840. //string outSid = GetPostString("outSid");//运单号
  1841. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1842. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1843. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1844. //string apires = "";
  1845. //if (deliveryType == "虚拟发货")
  1846. //{
  1847. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1848. //}
  1849. //else
  1850. //{
  1851. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1852. //}
  1853. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1854. ////{
  1855. //if (apires.IndexOf("发货成功") != -1)
  1856. //{
  1857. // if (deliveryType != "虚拟发货")
  1858. // {
  1859. // //还要插入快递信息到 快递信息表
  1860. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1861. // exinfo.tid = eid;
  1862. // exinfo.out_sid = outSid;
  1863. // exinfo.company_code = comCode;
  1864. // exinfo.company_name = comName;
  1865. // exinfo.delivery_memo = deliveryMemo;
  1866. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1867. // exinfo.deliveryType = deliveryType;
  1868. // exinfo.Create();
  1869. // }
  1870. // returnSuccessMsg("发货成功!");
  1871. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1872. //}
  1873. //else
  1874. //{
  1875. // returnErrorMsg("淘宝发货失败!!");
  1876. //}
  1877. //return;
  1878. }
  1879. returnErrorMsg("找不到订单记录");
  1880. }
  1881. }
  1882. public void get_erp_unusuallist()
  1883. {
  1884. DataStruct dStruct = GetPostStruct();
  1885. List<string> lw = new List<string>();
  1886. string tid = GetPostString("ctid");
  1887. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1888. string shopname = GetPostString("shopname");
  1889. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1890. string buyernick = GetPostString("buyer_nick");
  1891. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1892. string ResponsibleMan = GetPostString("responsible");
  1893. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1894. string date1 = GetPostString("date1");
  1895. string date2 = GetPostString("date2");
  1896. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1897. if (dw.Length > 0) lw.Add(dw);
  1898. string price1 = GetPostString("price1");
  1899. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1900. string price2 = GetPostString("price2");
  1901. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1902. string orderState = GetPostString("orderState");
  1903. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1904. string sellermemo = GetPostString("seller_memo");
  1905. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1906. lw.Add(string.Format("UnusualTag > 0"));
  1907. lw.Add(string.Format("IsRefund<={0}", 1));
  1908. dStruct.Order = "pay_time desc";
  1909. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1910. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1911. writeGridDataTableJson(dStruct.TotalCount, dt);
  1912. }
  1913. public void set_erp_unusualtonomal()
  1914. {
  1915. if (UrlPostParmsCheck("ctid"))
  1916. {
  1917. string eid = GetPostString("ctid");
  1918. CeErpTradeCell entity = null;
  1919. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1920. if (entity != null)
  1921. {
  1922. entity.UnusualTag = -1;
  1923. entity.Update();
  1924. returnSuccessMsg("忽略成功!");
  1925. return;
  1926. }
  1927. returnErrorMsg("找不到记录");
  1928. }
  1929. }
  1930. public void ins_erp_unusualreason()
  1931. {
  1932. if (UrlPostParmsCheck("ctid"))
  1933. {
  1934. string eid = GetPostString("ctid");
  1935. CeErpTradeCell entity = null;
  1936. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1937. if (entity != null)
  1938. {
  1939. entity.MemoOpt = 4;
  1940. entity.UnusualCon = GetPostString("con");
  1941. entity.Update();
  1942. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1943. if (trade != null)
  1944. {
  1945. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1946. }
  1947. //查货是否超时
  1948. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1949. if (ceErpTradeCellExtend == null)
  1950. {
  1951. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1952. ceErpTradeCellExtend.ctid = entity.ctid;
  1953. }
  1954. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1955. {
  1956. ceErpTradeCellExtend.CheckOut += 1;
  1957. }
  1958. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1959. if (ceErpTradeCellExtend.ID > 0)
  1960. {
  1961. ceErpTradeCellExtend.Update();
  1962. }
  1963. else
  1964. {
  1965. ceErpTradeCellExtend.Create();
  1966. }
  1967. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1968. returnSuccessMsg("操作成功!");
  1969. return;
  1970. }
  1971. returnErrorMsg("找不到记录");
  1972. }
  1973. }
  1974. public void upd_erp_sampleorder()
  1975. {
  1976. if (UrlPostParmsCheck("ctid"))
  1977. {
  1978. string eid = GetPostString("ctid");
  1979. string[] eArr = eid.Split(',');
  1980. if (eArr.Length > 1)
  1981. {
  1982. List<string> eLst = new List<string>();
  1983. for (int i = 0; i < eArr.Length; i++)
  1984. {
  1985. eLst.Add("'" + eArr[i] + "'");
  1986. }
  1987. eid = string.Join(",", eLst.ToArray());
  1988. }
  1989. else
  1990. {
  1991. eid = "'" + eid + "'";
  1992. }
  1993. StringBuilder sql = new StringBuilder();
  1994. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1995. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1996. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1997. if (dt.Rows.Count > 0)
  1998. {
  1999. string errmsg = "";
  2000. foreach (DataRow dr in dt.Rows)
  2001. {
  2002. StringBuilder sqlsb = new StringBuilder();
  2003. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2004. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2005. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2006. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2007. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2008. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2009. {
  2010. continue;
  2011. }
  2012. else
  2013. {
  2014. string emsg = commonHelper.KeepChinese(apires);
  2015. errmsg += emsg;
  2016. }
  2017. }
  2018. if (errmsg.Length > 0)
  2019. {
  2020. returnErrorMsg(errmsg);
  2021. return;
  2022. }
  2023. returnSuccessMsg("操作成功");
  2024. return;
  2025. }
  2026. returnErrorMsg("找不到记录");
  2027. }
  2028. }
  2029. public void upd_erp_transcustomer()
  2030. {
  2031. if (UrlPostParmsCheck("ctid"))
  2032. {
  2033. string eid = GetPostString("ctid");
  2034. int userid = GetPostInt("CustomerUserId");
  2035. CeErpTradeCell entity = null;
  2036. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2037. if (entity != null)
  2038. {
  2039. //string[] mlist = entity.seller_memo.Split('-');
  2040. //string sql = "select * from view_erpuser where id=" + userid;
  2041. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2042. //if (dt != null && dt.Rows.Count > 0)
  2043. //{
  2044. // string nmemo = "";
  2045. // for(int i = 0; i < mlist.Length - 1; i++)
  2046. // {
  2047. // nmemo += mlist[i];
  2048. // nmemo += "-";
  2049. // }
  2050. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2051. // entity.seller_memo = nmemo;
  2052. //}
  2053. entity.CustomerUserId = userid;
  2054. entity.Update();
  2055. returnSuccessMsg("操作成功!");
  2056. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2057. return;
  2058. }
  2059. returnErrorMsg("找不到记录");
  2060. }
  2061. }
  2062. public void upd_erp_transdesigner()
  2063. {
  2064. if (UrlPostParmsCheck("ctid"))
  2065. {
  2066. string eids = GetPostString("ctid");
  2067. string[] ctidList = eids.Split(',');
  2068. int userid = GetPostInt("DesignUserId");
  2069. foreach (string ctid in ctidList)
  2070. {
  2071. CeErpTradeCell entity = null;
  2072. CeErpDesignerBill entitys = null;
  2073. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2074. entitys = CeErpDesignerBill.GetByTid(ctid);
  2075. if (entity != null)
  2076. {
  2077. if (entity.OrderState > 4)
  2078. {
  2079. continue;
  2080. }
  2081. //存在退款不能流转
  2082. if (entity.IsRefund > 0)
  2083. {
  2084. continue;
  2085. }
  2086. entity.DesignUserId = userid;
  2087. entity.WaitDesignTime = DateTime.Now;
  2088. entity.Update();
  2089. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2090. }
  2091. }
  2092. returnSuccessMsg("操作成功!");
  2093. }
  2094. }
  2095. public void upd_erp_distributedesigner()
  2096. {
  2097. if (UrlPostParmsCheck("ctid"))
  2098. {
  2099. string eid = GetPostString("ctid");
  2100. int userid = GetPostInt("DesignUserId");
  2101. string[] idlist = eid.Split(',');
  2102. if (idlist.Length <= 0)
  2103. {
  2104. returnErrorMsg("订单不能为空");
  2105. return;
  2106. }
  2107. foreach (string ctid in idlist)
  2108. {
  2109. CeErpTradeCell entity = null;
  2110. CeErpDesignerBill entitys = null;
  2111. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2112. else continue;
  2113. if (entity != null)
  2114. {
  2115. if (userid == 2125 || userid == 3542)
  2116. { }
  2117. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2118. {
  2119. returnErrorMsg("金额错误的订单无法指派");
  2120. return;
  2121. }
  2122. if (entity.OrderState >= 5)
  2123. {
  2124. returnErrorMsg("已经设计完成无法指派");
  2125. return;
  2126. }
  2127. if (entity.OrderState == -1)
  2128. {
  2129. returnErrorMsg("审核中的订单无法指派");
  2130. return;
  2131. }
  2132. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2133. {
  2134. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2135. return;
  2136. }
  2137. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2138. {
  2139. returnErrorMsg("指派设计共创无法再次指派!");
  2140. return;
  2141. }
  2142. entity.OrderState = 3;
  2143. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2144. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2145. {
  2146. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2147. entity.SupplierId = suid;
  2148. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2149. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2150. }
  2151. if (userid == 2125 && entity.seller_memo != "")
  2152. {
  2153. apiDesign.API_GetPrintData_CreateOrder(entity);
  2154. }
  2155. if (userid == 3542 && entity.seller_memo != "")
  2156. {
  2157. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2158. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2159. if (response.msg != "设计共创:成功")
  2160. {
  2161. returnErrorMsg(response.msg);
  2162. return;
  2163. }
  2164. entity.DispatchSort = 2;
  2165. entity.OrderState = 3;
  2166. }
  2167. entity.DesignUserId = userid;
  2168. entity.WaitDesignTime = DateTime.Now;
  2169. entity.Update();
  2170. string name = commonHelper.getUserNameById(userid);
  2171. commonHelper.UpdateRelationOrder(entity.ctid);
  2172. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2173. }
  2174. }
  2175. returnSuccessMsg("操作成功!");
  2176. return;
  2177. }
  2178. }
  2179. public void get_erp_myorderlist()
  2180. {
  2181. DataStruct dStruct = GetPostStruct();
  2182. List<string> lw = new List<string>();
  2183. string tid = GetPostString("ctid");
  2184. if (tid.Length > 0)
  2185. {
  2186. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2187. }
  2188. else
  2189. {
  2190. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2191. }
  2192. //12-1 修改
  2193. string urgent = GetPostString("urgent");
  2194. string back = GetPostString("back");
  2195. string offlineSearch = GetPostString("offlineSearch");
  2196. if (!string.IsNullOrWhiteSpace(urgent))
  2197. {
  2198. if (urgent.Equals("true"))
  2199. {
  2200. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2201. }
  2202. }
  2203. if (!string.IsNullOrWhiteSpace(back))
  2204. {
  2205. if (back.Equals("true"))
  2206. {
  2207. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2208. }
  2209. }
  2210. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2211. {
  2212. if (offlineSearch.Equals("true"))
  2213. {
  2214. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2215. }
  2216. }
  2217. //end
  2218. string shopname = GetPostString("shopname");
  2219. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2220. string buyernick = GetPostString("buyer_nick");
  2221. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2222. string design = GetPostString("design");
  2223. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2224. string orderState = GetPostString("orderState");
  2225. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2226. string sellermemo = GetPostString("seller_memo");
  2227. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2228. string date1 = GetPostString("date1");
  2229. string date2 = GetPostString("date2");
  2230. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2231. if (dw.Length > 0) lw.Add(dw);
  2232. string price1 = GetPostString("price1");
  2233. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2234. string price2 = GetPostString("price2");
  2235. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2236. string urgency = GetPostString("urgency");
  2237. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2238. string after = GetPostString("after");
  2239. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2240. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2241. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2242. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2243. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2244. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2245. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2246. if (dt != null && dt.Rows.Count > 0)
  2247. {
  2248. foreach (DataRow dr in dt.Rows)
  2249. {
  2250. try
  2251. {
  2252. // 对象操作
  2253. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2254. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2255. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2256. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2257. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2258. if (dStruct.PageSize != 100000)
  2259. {
  2260. if (dr["DispatchSort"].ToString() == "2")
  2261. {
  2262. dr["gongchuang"] = 200;
  2263. }
  2264. else
  2265. {
  2266. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2267. dr["gongchuang"] = response.code;
  2268. }
  2269. }
  2270. }
  2271. catch (NullReferenceException ex)
  2272. {
  2273. }
  2274. }
  2275. }
  2276. writeGridDataTableJson(dStruct.TotalCount, dt);
  2277. }
  2278. public void get_erp_myreturnorderlist()
  2279. {
  2280. DataStruct dStruct = GetPostStruct();
  2281. List<string> lw = new List<string>();
  2282. string tid = GetPostString("ctid");
  2283. if (tid.Length > 0)
  2284. {
  2285. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2286. }
  2287. else
  2288. {
  2289. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2290. }
  2291. string shopname = GetPostString("shopname");
  2292. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2293. string buyernick = GetPostString("buyer_nick");
  2294. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2295. string design = GetPostString("design");
  2296. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2297. string orderState = GetPostString("orderState");
  2298. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2299. string sellermemo = GetPostString("seller_memo");
  2300. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2301. string date1 = GetPostString("date1");
  2302. string date2 = GetPostString("date2");
  2303. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2304. if (dw.Length > 0) lw.Add(dw);
  2305. string price1 = GetPostString("price1");
  2306. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2307. string price2 = GetPostString("price2");
  2308. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2309. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2310. {
  2311. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2312. }
  2313. else
  2314. {
  2315. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2316. }
  2317. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2318. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2319. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2320. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2321. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2322. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2323. if (dt != null && dt.Rows.Count > 0)
  2324. {
  2325. foreach (DataRow dr in dt.Rows)
  2326. {
  2327. try
  2328. {
  2329. // 对象操作
  2330. if (dStruct.PageSize != 100000)
  2331. {
  2332. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2333. dr["gongchuang"] = response.code;
  2334. }
  2335. }
  2336. catch (NullReferenceException ex)
  2337. {
  2338. // 处理空引用异常
  2339. }
  2340. }
  2341. }
  2342. writeGridDataTableJson(dStruct.TotalCount, dt);
  2343. }
  2344. public void get_erp_myorderlist_pregather()
  2345. {
  2346. string date1 = GetPostString("date1");
  2347. string date2 = GetPostString("date2");
  2348. int userId = CurrentUser.UserID; //客服id
  2349. string orderWhere = "";
  2350. List<string> lw = new List<string>();
  2351. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2352. if (dw.Length > 0) lw.Add(dw);
  2353. lw.Add(string.Format("CustomerUserId={0}", userId));
  2354. lw.Add(string.Format("OrderState<9"));
  2355. orderWhere = string.Join(" and ", lw.ToArray());
  2356. string orderWhere2 = "";
  2357. List<string> lw2 = new List<string>();
  2358. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2359. if (dw2.Length > 0) lw2.Add(dw2);
  2360. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2361. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2362. string sql = string.Format("select *" +
  2363. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2364. "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 " +
  2365. "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 " +
  2366. "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");
  2367. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2368. //writeGridDataTableJson(dt.Rows.Count, dt);
  2369. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2370. }
  2371. public void upd_erp_publishorder()
  2372. {
  2373. if (UrlPostParmsCheck("ctid"))
  2374. {
  2375. string eid = GetPostString("ctid");
  2376. CeErpTradeCell entity = null;
  2377. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2378. if (entity != null)
  2379. {
  2380. entity.OrderState = 0; //发布后,变为待抢单
  2381. entity.Update();
  2382. commonHelper.UpdateRelationOrder(entity.ctid);
  2383. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2384. returnSuccessMsg("发布成功!");
  2385. return;
  2386. }
  2387. returnErrorMsg("找不到记录");
  2388. }
  2389. }
  2390. public void get_erp_my_tiporder()
  2391. {
  2392. StringBuilder sql = new StringBuilder();
  2393. int userId = 0;
  2394. if (CurrentUser != null) userId = CurrentUser.UserID;
  2395. string posCode = CurrentUser.UserPost.Post.Code;
  2396. string isTipedAfterSaleVerify = GetPostString("af");
  2397. DataTable dt = new DataTable();
  2398. if (posCode != "Supplier")
  2399. {
  2400. if (posCode == "CustomerService" || posCode == "Director")
  2401. {
  2402. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2403. }
  2404. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2405. {
  2406. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2407. }
  2408. else
  2409. {
  2410. string teamIds = CurrentUser.User.TeamIds;
  2411. if (teamIds == "")
  2412. {
  2413. teamIds = "0";
  2414. }
  2415. 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);
  2416. }
  2417. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2418. }
  2419. if (dt.Rows.Count <= 0)
  2420. {
  2421. string key = "aftersale_order_" + userId;
  2422. if (RedisHelper.HasKey(key))
  2423. {
  2424. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2425. dt.Columns.Add("ctid", typeof(string));
  2426. dt.Columns.Add("IsReadTag", typeof(int));
  2427. foreach (var i in list)
  2428. {
  2429. DataRow data = dt.NewRow();
  2430. data["ctid"] = i;
  2431. data["IsReadTag"] = 4;
  2432. dt.Rows.Add(data);
  2433. }
  2434. RedisHelper.StringDelete(key);
  2435. }
  2436. }
  2437. if (dt.Rows.Count <= 0)
  2438. {
  2439. sql = new StringBuilder();
  2440. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2441. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2442. }
  2443. if (posCode == "Supplier")
  2444. {
  2445. string ids = CurrentUser.User.pemVend;
  2446. if (ids != null && ids.Length > 0)
  2447. {
  2448. string[] ids_list = ids.Split(',');
  2449. foreach (var item in ids_list)
  2450. {
  2451. string key = "return_order_" + item;
  2452. if (RedisHelper.HasKey(key))
  2453. {
  2454. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2455. dt.Columns.Add("ctid", typeof(string));
  2456. dt.Columns.Add("IsReadTag", typeof(int));
  2457. foreach (var i in list)
  2458. {
  2459. DataRow data = dt.NewRow();
  2460. data["ctid"] = i;
  2461. data["IsReadTag"] = 1;
  2462. dt.Rows.Add(data);
  2463. }
  2464. RedisHelper.StringDelete(key);
  2465. }
  2466. }
  2467. }
  2468. if (dt.Rows.Count <= 0)
  2469. {
  2470. sql = new StringBuilder();
  2471. 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);
  2472. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2473. }
  2474. }
  2475. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2476. }
  2477. public void reset_erp_tiporder()
  2478. {
  2479. string ids = GetPostString("ids");
  2480. string[] ctidList = ids.Split(',');
  2481. foreach (string ctid in ctidList)
  2482. {
  2483. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2484. if (enty != null)
  2485. {
  2486. enty.IsReadTag = 0;
  2487. enty.Update();
  2488. }
  2489. }
  2490. returnSuccessMsg("成功!");
  2491. return;
  2492. }
  2493. public void get_erp_designlist()
  2494. {
  2495. DataStruct dStruct = GetPostStruct();
  2496. List<string> lw = new List<string>();
  2497. string tid = GetPostString("ctid");
  2498. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2499. string shopname = GetPostString("shopname");
  2500. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2501. string buyernick = GetPostString("buyer_nick");
  2502. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2503. string customer = GetPostString("customer");
  2504. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2505. string design = GetPostString("design");
  2506. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2507. string orderState = GetPostString("orderState");
  2508. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2509. lw.Add(string.Format("OrderState<6"));
  2510. string address = GetPostString("address");
  2511. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2512. string sellermemo = GetPostString("seller_memo");
  2513. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2514. string date1 = GetPostString("date1");
  2515. string date2 = GetPostString("date2");
  2516. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2517. if (dw.Length > 0) lw.Add(dw);
  2518. string apdate1 = GetPostString("apdate1");
  2519. string apdate2 = GetPostString("apdate2");
  2520. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2521. if (dwap.Length > 0) lw.Add(dwap);
  2522. string price1 = GetPostString("price1");
  2523. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2524. string price2 = GetPostString("price2");
  2525. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2526. string designTime = GetPostString("designtime");
  2527. if (designTime.Length > 0)
  2528. {
  2529. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2530. }
  2531. string usershop = CurrentUser.User.pemShop;
  2532. if (usershop.Length > 0)
  2533. {
  2534. lw.Add(string.Format("shopId in ({0})", usershop));
  2535. }
  2536. int myOrgid = CurrentUser.UserPost.OrgID;
  2537. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2538. if (myOrgCode.IndexOf("Designer") != -1)
  2539. {
  2540. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2541. {
  2542. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2543. }
  2544. else
  2545. {
  2546. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2547. }
  2548. }
  2549. else
  2550. {
  2551. string orgId = GetPostString("designerhd");
  2552. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2553. }
  2554. if (tid.Length > 0 || buyernick.Length > 0)
  2555. {
  2556. lw.Add(string.Format("OrderState >= 3"));
  2557. }
  2558. else
  2559. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2560. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2561. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2563. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2564. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2565. if (dt != null && dt.Rows.Count > 0)
  2566. {
  2567. foreach (DataRow dr in dt.Rows)
  2568. {
  2569. try
  2570. {
  2571. // 对象操作
  2572. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2573. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2574. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2575. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2576. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2577. if (dStruct.PageSize != 100000)
  2578. {
  2579. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2580. dr["gongchuang"] = response.code;
  2581. }
  2582. }
  2583. catch (NullReferenceException ex)
  2584. {
  2585. }
  2586. }
  2587. }
  2588. writeGridDataTableJson(dStruct.TotalCount, dt);
  2589. }
  2590. public void get_erp_mydesignlist()
  2591. {
  2592. DataStruct dStruct = GetPostStruct();
  2593. List<string> lw = new List<string>();
  2594. string tid = GetPostString("ctid");
  2595. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2596. string shopname = GetPostString("shopname");
  2597. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2598. string buyernick = GetPostString("buyer_nick");
  2599. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2600. string customer = GetPostString("customer");
  2601. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2602. string orderState = GetPostString("orderState");
  2603. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2604. //lw.Add(string.Format("OrderState<6"));
  2605. string date1 = GetPostString("date1");
  2606. string date2 = GetPostString("date2");
  2607. string dw = GetDateWhere("pay_time", date1, date2);
  2608. if (dw.Length > 0) lw.Add(dw);
  2609. string apdate1 = GetPostString("apdate1");
  2610. string apdate2 = GetPostString("apdate2");
  2611. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2612. if (dwap.Length > 0) lw.Add(dwap);
  2613. string price1 = GetPostString("price1");
  2614. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2615. string price2 = GetPostString("price2");
  2616. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2617. string olddownload = GetPostString("olddown");
  2618. if (olddownload == "1")
  2619. {
  2620. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2621. }
  2622. else if (olddownload == "2")
  2623. {
  2624. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2625. }
  2626. string sellermemo = GetPostString("seller_memo");
  2627. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2628. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2629. if (CurrentUser.User.TeamIds.Length > 0)
  2630. {
  2631. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2632. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2633. else
  2634. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2635. }
  2636. else
  2637. {
  2638. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2639. }
  2640. if (tid.Length <= 0)
  2641. {
  2642. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2643. }
  2644. lw.Add(string.Format("IsReturn!=3"));
  2645. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2646. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2647. string teamids = CurrentUser.User.TeamIds.ToString();
  2648. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2649. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2650. if (dt != null && dt.Rows.Count > 0)
  2651. {
  2652. foreach (DataRow dr in dt.Rows)
  2653. {
  2654. try
  2655. {
  2656. // 对象操作
  2657. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2658. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2659. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2660. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2661. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2662. if (dStruct.PageSize != 100000)
  2663. {
  2664. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2665. dr["gongchuang"] = response.code;
  2666. }
  2667. }
  2668. catch (NullReferenceException ex)
  2669. {
  2670. }
  2671. }
  2672. }
  2673. writeGridDataTableJson(dStruct.TotalCount, dt);
  2674. }
  2675. public void set_erp_startdesign()
  2676. {
  2677. if (UrlPostParmsCheck("ctid"))
  2678. {
  2679. string eid = GetPostString("ctid");
  2680. CeErpTradeCell entity = null;
  2681. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2682. if (entity != null)
  2683. {
  2684. if (entity.OrderState != 3)
  2685. {
  2686. returnErrorMsg("请刷新,订单已经设计了");
  2687. return;
  2688. }
  2689. entity.StartDesignTime = DateTime.Now;
  2690. entity.OrderState = 4;
  2691. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2692. {
  2693. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2694. entity.SupplierId = suid;
  2695. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2696. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2697. }
  2698. //entity.MakeSupplier = suname;
  2699. entity.Update();
  2700. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2701. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2702. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2703. commonHelper.getCytPrice(entity);
  2704. returnSuccessMsg("操作成功!");
  2705. return;
  2706. }
  2707. returnErrorMsg("找不到记录");
  2708. }
  2709. }
  2710. public void ins_erp_designselfmemo()
  2711. {
  2712. if (UrlPostParmsCheck("ctid"))
  2713. {
  2714. string eid = GetPostString("ctid");
  2715. string con = GetPostString("con");
  2716. CeErpTradeCell entity = null;
  2717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2718. if (entity != null)
  2719. {
  2720. entity.DesignSelfMemo = con;
  2721. entity.Update();
  2722. returnSuccessMsg("操作成功!");
  2723. return;
  2724. }
  2725. returnErrorMsg("找不到记录");
  2726. }
  2727. }
  2728. public void ins_erp_designprice()
  2729. {
  2730. if (UrlPostParmsCheck("ctid"))
  2731. {
  2732. string eid = GetPostString("ctid");
  2733. int uid = CurrentUser.UserID;
  2734. string userName = CurrentUser.UserName;
  2735. CeErpTradeCell entity = null;
  2736. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2737. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2738. if (entitys == null)
  2739. {
  2740. entitys = new CeErpDesignerBill();
  2741. }
  2742. if (entity != null)
  2743. {
  2744. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2745. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2746. entity.StartDesignTime = DateTime.Now;
  2747. entity.OrderState = 4;
  2748. string suname = "";
  2749. if (entity.SupplierId == 0)
  2750. {
  2751. int sid = commonHelper.autoDistributeToSupplier(entity);
  2752. entity.SupplierId = sid;
  2753. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2754. }
  2755. entity.Update();
  2756. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2757. if (ceErpUserPost != null)
  2758. {
  2759. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2760. if (ceErpPost != null)
  2761. {
  2762. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2763. {
  2764. entitys.tid = entity.ctid;
  2765. entitys.oid = entity.tid;
  2766. entitys.uid = uid;
  2767. entitys.userName = userName;
  2768. entitys.designerType = 1;
  2769. entitys.designerTypeText = "内部设计师";
  2770. entitys.price = Convert.ToDouble(GetPostString("price"));
  2771. entitys.designNum = GetPostInt("designNum");
  2772. entitys.modifyNum = GetPostInt("modifyNum");
  2773. entitys.designSize = GetPostString("designSize");
  2774. entitys.modifySize = GetPostString("modifySize");
  2775. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2776. {
  2777. entitys.create_time = DateTime.Now;
  2778. entitys.create_u_id = uid;
  2779. entitys.create_u_name = userName;
  2780. entitys.Save();
  2781. }
  2782. else
  2783. {
  2784. entitys.update_time = DateTime.Now;
  2785. entitys.update_u_id = uid;
  2786. entitys.update_u_name = userName;
  2787. entitys.Update();
  2788. }
  2789. }
  2790. }
  2791. }
  2792. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2793. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2794. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2795. if (suname != "")
  2796. {
  2797. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2798. }
  2799. commonHelper.getCytPrice(entity);
  2800. returnSuccessMsg("操作成功!");
  2801. return;
  2802. }
  2803. returnErrorMsg("找不到记录");
  2804. }
  2805. }
  2806. public void upload_erp_filecomplete()
  2807. {
  2808. if (UrlPostParmsCheck("ctid"))
  2809. {
  2810. string eid = GetPostString("ctid");
  2811. CeErpTradeCell entity = null;
  2812. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2813. if (entity != null)
  2814. {
  2815. entity.OrderState = 5; //设计完成
  2816. entity.Update();
  2817. returnSuccessMsg(eid + "上传成功,设计完成!");
  2818. return;
  2819. }
  2820. returnErrorMsg("找不到订单记录");
  2821. }
  2822. }
  2823. public void get_erp_designovertimelist()
  2824. {
  2825. DataStruct dStruct = GetPostStruct();
  2826. List<string> lw = new List<string>();
  2827. string tid = GetPostString("ctid");
  2828. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2829. string shopname = GetPostString("shopname");
  2830. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2831. string buyernick = GetPostString("buyer_nick");
  2832. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2833. string ResponsibleMan = GetPostString("responsible");
  2834. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2835. string date1 = GetPostString("date1");
  2836. string date2 = GetPostString("date2");
  2837. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2838. if (dw.Length > 0) lw.Add(dw);
  2839. string price1 = GetPostString("price1");
  2840. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2841. string price2 = GetPostString("price2");
  2842. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2843. string orderState = GetPostString("orderState");
  2844. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2845. string sellermemo = GetPostString("seller_memo");
  2846. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2847. lw.Add(string.Format("UnusualTag=3"));
  2848. lw.Add(string.Format("IsRefund<={0}", 1));
  2849. dStruct.Order = "WaitDesignTime desc";
  2850. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2851. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2852. writeGridDataTableJson(dStruct.TotalCount, dt);
  2853. }
  2854. //设计管理 获取抢单大厅列表
  2855. public void get_erp_grabinglist()
  2856. {
  2857. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2858. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2859. bool oldOrder = false;
  2860. if (org != null)
  2861. {
  2862. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2863. }
  2864. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2865. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2866. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2867. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2868. //先处理订单数据
  2869. if (dt.Rows.Count > 0)
  2870. {
  2871. Dictionary<string, int> design = null;
  2872. int count = 0;
  2873. foreach (DataRow row in dt.Rows)
  2874. {
  2875. if (map.ContainsKey(row["ShopId"].ToString()))
  2876. {
  2877. map.TryGetValue(row["ShopId"].ToString(), out design);
  2878. }
  2879. else
  2880. {
  2881. design = new Dictionary<string, int>();
  2882. }
  2883. if (design.ContainsKey(row["ProductId"].ToString()))
  2884. {
  2885. design.TryGetValue(row["ProductId"].ToString(), out count);
  2886. }
  2887. count++;
  2888. design[row["ProductId"].ToString()] = count;
  2889. map[row["ShopId"].ToString()] = design;
  2890. }
  2891. }
  2892. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2893. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2894. //把店铺排序和技能排序分类
  2895. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2896. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2897. if (design_dt.Rows.Count > 0)
  2898. {
  2899. Dictionary<string, string> design = null;
  2900. List<string> shopIds = null;
  2901. foreach (DataRow row in design_dt.Rows)
  2902. {
  2903. if ("0".Equals(row["designId"].ToString()))
  2904. {
  2905. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2906. {
  2907. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2908. }
  2909. else
  2910. {
  2911. shopIds = new List<string>();
  2912. }
  2913. shopIds.Add(row["shopId"].ToString());
  2914. shop_orders[row["orders"].ToString()] = shopIds;
  2915. }
  2916. else
  2917. {
  2918. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2919. {
  2920. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2921. }
  2922. else
  2923. {
  2924. design = new Dictionary<string, string>();
  2925. }
  2926. design[row["orders"].ToString()] = row["designId"].ToString();
  2927. design_orders[row["shopId"].ToString()] = design;
  2928. }
  2929. }
  2930. //处理成key value后根据key排序
  2931. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2932. foreach (List<string> val in shop_orders.Values)
  2933. {
  2934. if (val != null)
  2935. {
  2936. foreach (string key in val)
  2937. {
  2938. if (design_orders.ContainsKey(key.ToString()))
  2939. {
  2940. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2941. }
  2942. }
  2943. }
  2944. }
  2945. }
  2946. //校验哪个优先级有订单
  2947. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2948. foreach (string key in shop_orders.Keys)
  2949. {
  2950. List<string> ids = null;
  2951. shop_orders.TryGetValue(key, out ids);
  2952. //id为shopid
  2953. foreach (string id in ids)
  2954. {
  2955. Dictionary<string, int> list = null;
  2956. Dictionary<string, string> desing = null;
  2957. map.TryGetValue(id, out list);
  2958. design_orders.TryGetValue(id, out desing);
  2959. if (list != null && desing != null)
  2960. {
  2961. foreach (var item in desing)
  2962. {
  2963. int count = 0;
  2964. if (list.ContainsKey(item.Value))
  2965. {
  2966. list.TryGetValue(item.Value, out count);
  2967. if (count > 0)
  2968. {
  2969. designIds[id] = item.Value;
  2970. break;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. }
  2976. if (designIds.Count > 0)
  2977. {
  2978. break;
  2979. }
  2980. }
  2981. DataTable table = new DataTable();
  2982. table.Columns.Add("tid", typeof(string));
  2983. table.Columns.Add("ctid", typeof(string));
  2984. table.Columns.Add("seller_nick", typeof(string));
  2985. table.Columns.Add("productName", typeof(string));
  2986. table.Columns.Add("pay_time", typeof(string));
  2987. table.Columns.Add("seller_memo", typeof(string));
  2988. if (designIds.Count > 0)
  2989. {
  2990. string shopId = "";
  2991. string productId = "";
  2992. foreach (var designInfo in designIds)
  2993. {
  2994. shopId = designInfo.Key;
  2995. productId = designInfo.Value;
  2996. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2997. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2998. if (dt.Rows.Count > 0)
  2999. {
  3000. foreach (DataRow row in dt.Rows)
  3001. {
  3002. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3003. {
  3004. DataRow data = table.NewRow();
  3005. data["ctid"] = row["ctid"].ToString();
  3006. data["tid"] = row["tid"].ToString();
  3007. data["seller_nick"] = ceErpShop.ShopName;
  3008. data["pay_time"] = row["pay_time"].ToString();
  3009. data["seller_memo"] = row["seller_memo"].ToString();
  3010. data["productName"] = ceErpProduct.PType;
  3011. table.Rows.Add(data);
  3012. }
  3013. }
  3014. }
  3015. }
  3016. }
  3017. writeGridDataTableJson(table.Rows.Count, table);
  3018. }
  3019. private object rushLockObject = new object();
  3020. public void set_erp_grabingorder()
  3021. {
  3022. if (UrlPostParmsCheck("ctid"))
  3023. {
  3024. int total = CurrentUser.User.Person.Total;
  3025. int userId = CurrentUser.User.ID;
  3026. int noFinish = CurrentUser.User.Person.NoFinish;
  3027. int finalization = CurrentUser.User.Person.Finalization;
  3028. string eids = GetPostString("ctid");
  3029. string key = "RushKey_" + userId;
  3030. int count = 0;
  3031. if (erpRedis.RedisHelper.KeyExists(key))
  3032. {
  3033. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3034. if (redisCount != null)
  3035. {
  3036. count = Convert.ToInt32(redisCount);
  3037. }
  3038. }
  3039. if (count >= total)
  3040. {
  3041. returnErrorMsg("半小时内已经抢" + total + "单");
  3042. return;
  3043. }
  3044. string[] ctidlist = eids.Split(',');
  3045. if (count + ctidlist.Length > total)
  3046. {
  3047. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3048. return;
  3049. }
  3050. int itag = 0;
  3051. lock (rushLockObject)
  3052. {
  3053. if (ctidlist.Length > 0)
  3054. {
  3055. string[] dtList = new string[ctidlist.Length];
  3056. for (int i = 0; i < ctidlist.Length; i++)
  3057. {
  3058. dtList[i] = "'" + ctidlist[i] + "'";
  3059. }
  3060. 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"));
  3061. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3062. if (dt_user.Rows.Count > 0)
  3063. {
  3064. int doing = 0;//未定稿
  3065. int finish = 0;//已完成
  3066. foreach (DataRow dr in dt_user.Rows)
  3067. {
  3068. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3069. {
  3070. doing++;
  3071. }
  3072. else
  3073. {
  3074. finish++;
  3075. }
  3076. }
  3077. if (doing >= noFinish)
  3078. {
  3079. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3080. return;
  3081. }
  3082. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3083. {
  3084. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3085. return;
  3086. }
  3087. }
  3088. //校验选择单子状态
  3089. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3090. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3091. if (dt.Rows.Count > 0)
  3092. {
  3093. List<string> list = new List<string>();
  3094. foreach (DataRow dr in dt.Rows)
  3095. {
  3096. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3097. {
  3098. list.Add(dr["ctid"].ToString());
  3099. }
  3100. }
  3101. if (list.Count > 0)
  3102. {
  3103. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3104. return;
  3105. }
  3106. }
  3107. foreach (string ctid in ctidlist)
  3108. {
  3109. CeErpTradeCell entity = null;
  3110. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3111. if (entity != null)
  3112. {
  3113. entity.OrderState = 3;
  3114. entity.DesignUserId = CurrentUser.UserID;
  3115. entity.WaitDesignTime = DateTime.Now;
  3116. entity.StartDesignTime = DateTime.Now;
  3117. entity.Update();
  3118. commonHelper.UpdateRelationOrder(entity.ctid);
  3119. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3121. itag++;
  3122. }
  3123. }
  3124. }
  3125. }
  3126. count += ctidlist.Length;
  3127. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3128. if (itag == 0)
  3129. returnErrorMsg("没有找到相关订单");
  3130. else
  3131. returnSuccessMsg("抢单成功!");
  3132. return;
  3133. }
  3134. }
  3135. public void get_erp_waitorderlist()
  3136. {
  3137. DataStruct dStruct = GetPostStruct();
  3138. List<string> lw = new List<string>();
  3139. string tid = GetPostString("ctid");
  3140. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3141. string shopname = GetPostString("shopname");
  3142. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3143. string buyernick = GetPostString("buyer_nick");
  3144. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3145. string customer = GetPostString("customer");
  3146. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3147. string design = GetPostString("design");
  3148. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3149. string orderState = GetPostString("orderState");
  3150. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3151. string supplier = GetPostString("supplier");
  3152. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3153. string sellermemo = GetPostString("seller_memo");
  3154. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3155. string otherMemo = GetPostString("otherMemo");
  3156. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3157. string address = GetPostString("address");
  3158. 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));
  3159. string date1 = GetPostString("date1");
  3160. string date2 = GetPostString("date2");
  3161. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3162. if (dw.Length > 0) lw.Add(dw);
  3163. string price1 = GetPostString("price1");
  3164. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3165. string price2 = GetPostString("price2");
  3166. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3167. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3168. lw.Add(string.Format("IsSample != 2 "));
  3169. lw.Add(string.Format("OrderState = 5 "));
  3170. lw.Add(string.Format("IsRefund<={0}", 1));
  3171. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3172. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3173. string pagesize = GetPostString("pagesize");
  3174. if (pagesize != null)
  3175. {
  3176. dStruct.PageSize = 200;
  3177. }
  3178. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3179. foreach (DataRow dr in dt.Rows)
  3180. {
  3181. 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();
  3182. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3183. {
  3184. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3185. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3186. entity.SupplierId = suid;
  3187. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3188. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3189. entity.Update();
  3190. }
  3191. }
  3192. writeGridDataTableJson(dStruct.TotalCount, dt);
  3193. }
  3194. public void get_erp_supplierwaitorderlist()
  3195. {
  3196. DataStruct dStruct = GetPostStruct();
  3197. List<string> lw = new List<string>();
  3198. string tid = GetPostString("ctid");
  3199. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3200. string shopname = GetPostString("shopname");
  3201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3202. string sellermemo = GetPostString("seller_memo");
  3203. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3204. string date1 = GetPostString("date1");
  3205. string date2 = GetPostString("date2");
  3206. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3207. if (dw.Length > 0) lw.Add(dw);
  3208. lw.Add(string.Format("OrderState = 5 "));
  3209. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3210. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3211. {
  3212. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3213. }
  3214. string supplier = GetPostString("supplier");
  3215. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3216. {
  3217. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3218. }
  3219. lw.Add(string.Format("IsRefund<={0}", 1));
  3220. dStruct.Order = "FinishDesignTime desc";
  3221. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3222. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3223. if (dt != null)
  3224. {
  3225. foreach (DataRow dr in dt.Rows)
  3226. {
  3227. 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();
  3228. }
  3229. }
  3230. writeGridDataTableJson(dStruct.TotalCount, dt);
  3231. }
  3232. public void upd_erp_verifytosupplier()
  3233. {
  3234. if (UrlPostParmsCheck("ctid"))
  3235. {
  3236. string eids = GetPostString("ctid");
  3237. CeErpTradeCell entity = null;
  3238. string[] eidsList = eids.Split(',');
  3239. if (eidsList.Length <= 0)
  3240. {
  3241. returnErrorMsg("订单号不能空");
  3242. return;
  3243. }
  3244. List<string> tLst = new List<string>();
  3245. foreach (string ctidstr in eidsList)
  3246. {
  3247. tLst.Add("'" + ctidstr + "'");
  3248. CeErpDataSendOrderInfo.createObject(ctidstr);
  3249. }
  3250. string needtids = string.Join(",", tLst.ToArray());
  3251. StringBuilder sql = new StringBuilder();
  3252. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3253. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3254. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3255. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3256. returnSuccessMsg("操作成功!");
  3257. return;
  3258. /**foreach (string ctidstr in eidsList)
  3259. {
  3260. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3261. if (entity != null)
  3262. {
  3263. if (entity.SupplierId == 0)
  3264. {
  3265. continue;
  3266. }
  3267. entity.IsVerifyToSupplier = true;
  3268. if (entity.IsReturn == 1) //1是供应商打回
  3269. {
  3270. entity.IsReturn = 0;
  3271. }
  3272. entity.FinishPlaceTime = DateTime.Now;
  3273. entity.PlaceUserId = CurrentUser.UserID;
  3274. entity.Update();
  3275. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3276. }
  3277. }
  3278. returnSuccessMsg("操作成功!");
  3279. return;**/
  3280. }
  3281. }
  3282. public void upd_erp_supplierback()
  3283. {
  3284. if (UrlPostParmsCheck("ctid"))
  3285. {
  3286. string eid = GetPostString("ctid");
  3287. string reason = GetPostString("returnreason");
  3288. CeErpTradeCell entity = null;
  3289. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3290. if (entity != null)
  3291. {
  3292. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3293. {
  3294. string key = "return_order_" + entity.SupplierId;
  3295. List<string> list = new List<string>();
  3296. if (RedisHelper.HasKey(key))
  3297. {
  3298. object data = RedisHelper.StringGet(key);
  3299. list = Convert.ToString(data).Split(',').ToList();
  3300. }
  3301. list.Add(eid);
  3302. RedisHelper.StringSet(key, string.Join(",", list));
  3303. }
  3304. entity.IsVerifyToSupplier = false;
  3305. entity.IsReturn = 1;
  3306. entity.ReturnTime = DateTime.Now;
  3307. entity.ReturnReason = reason;
  3308. if (entity.OrderState == 6)
  3309. {
  3310. entity.OrderState = 5;
  3311. }
  3312. entity.Update();
  3313. CeErpSukuraData.createInfo(entity.ctid, 5);
  3314. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3315. returnSuccessMsg("操作成功!");
  3316. return;
  3317. }
  3318. returnErrorMsg("找不到订单记录");
  3319. }
  3320. }
  3321. public void upd_erp_toaftersaleorder()
  3322. {
  3323. if (UrlPostParmsCheck("ctid"))
  3324. {
  3325. string eid = GetPostString("ctid");
  3326. string reason = GetPostString("returnreason");
  3327. CeErpTradeCell entity = null;
  3328. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3329. if (entity != null)
  3330. {
  3331. if (entity.isAfterSaleOrder != 1)
  3332. {
  3333. returnErrorMsg("带S的售后单才能打回给售后");
  3334. return;
  3335. }
  3336. if (entity.OrderState >= 5)
  3337. {
  3338. returnErrorMsg("已经设计完成了不能打回给售后");
  3339. return;
  3340. }
  3341. entity.OrderState = 0;
  3342. entity.IsReturn = 3;
  3343. entity.ReturnTime = DateTime.Now;
  3344. entity.ReturnReason = reason;
  3345. entity.Update();
  3346. CeErpSukuraData.createInfo(entity.ctid, 5);
  3347. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3348. returnSuccessMsg("操作成功!");
  3349. return;
  3350. }
  3351. returnErrorMsg("找不到订单记录");
  3352. }
  3353. }
  3354. public void upd_erp_aftersaletodesign()
  3355. {
  3356. if (UrlPostParmsCheck("ctid"))
  3357. {
  3358. string eid = GetPostString("ctid");
  3359. CeErpTradeCell entity = null;
  3360. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3361. if (entity != null)
  3362. {
  3363. entity.OrderState = 3;
  3364. entity.IsReturn = 0;
  3365. entity.Update();
  3366. CeErpSukuraData.createInfo(entity.ctid, 5);
  3367. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3368. returnSuccessMsg("操作成功!");
  3369. return;
  3370. }
  3371. returnErrorMsg("找不到订单记录");
  3372. }
  3373. }
  3374. public void assign_erp_supplier()
  3375. {
  3376. if (UrlPostParmsCheck("ctid"))
  3377. {
  3378. string eids = GetPostString("ctid");
  3379. int sid = GetPostInt("SupplierName");
  3380. string fromTag = GetPostString("tag");
  3381. string[] eidList = eids.Split(',');
  3382. if (eidList.Length <= 0)
  3383. {
  3384. returnErrorMsg("指派不能为空");
  3385. return;
  3386. }
  3387. string errMsg = "";
  3388. string suname = commonHelper.getSupplierNameById(sid);
  3389. foreach (string ctid in eidList)
  3390. {
  3391. CeErpTradeCell entity = null;
  3392. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3393. if (entity != null)
  3394. {
  3395. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3396. {
  3397. errMsg += (ctid + "指派失败!!!");
  3398. continue;
  3399. }
  3400. entity.SupplierId = sid;
  3401. entity.Update();
  3402. commonHelper.UpdateRelationOrder(entity.ctid);
  3403. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3404. if (entity.OrderState >= 6)
  3405. {
  3406. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3407. //{
  3408. // string msl = entity.MakeSupplier;
  3409. // string[] mslist = msl.Split(',');
  3410. // 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);
  3411. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3412. //}
  3413. //else
  3414. //{
  3415. StringBuilder sql = new StringBuilder();
  3416. 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);
  3417. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3418. //}
  3419. }
  3420. }
  3421. else
  3422. {
  3423. continue;
  3424. }
  3425. }
  3426. if (errMsg.Length > 0)
  3427. {
  3428. returnErrorMsg(errMsg);
  3429. return;
  3430. }
  3431. returnSuccessMsg("操作成功!");
  3432. return;
  3433. }
  3434. }
  3435. public void assign_erp_makesupplier()
  3436. {
  3437. if (UrlPostParmsCheck("ctid"))
  3438. {
  3439. string eids = GetPostString("ctid");
  3440. string sname = GetPostString("SupplierName");
  3441. string[] eidList = eids.Split(',');
  3442. if (eidList.Length <= 0)
  3443. {
  3444. returnErrorMsg("指派不能为空");
  3445. return;
  3446. }
  3447. List<string> tLst = new List<string>();
  3448. foreach (string ctid in eidList)
  3449. {
  3450. CeErpTradeCell entity = null;
  3451. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3452. if (entity != null)
  3453. {
  3454. entity.MakeSupplier = sname;
  3455. entity.Update();
  3456. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3457. tLst.Add("'" + ctid + "'");
  3458. }
  3459. else
  3460. {
  3461. continue;
  3462. }
  3463. }
  3464. string ctids = string.Join(",", tLst.ToArray());
  3465. StringBuilder sql2 = new StringBuilder();
  3466. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3467. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3468. returnSuccessMsg("操作成功!");
  3469. return;
  3470. }
  3471. }
  3472. public void ins_erp_returnreason()
  3473. {
  3474. if (UrlPostParmsCheck("ctid"))
  3475. {
  3476. string eid = GetPostString("ctid");
  3477. CeErpTradeCell entity = null;
  3478. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3479. string userpost = CurrentUser.UserPost.Post.Code;
  3480. if (entity != null)
  3481. {
  3482. bool isPlace = false;
  3483. if (entity.OrderState > 6)
  3484. {
  3485. returnErrorMsg("已发货无法打回!");
  3486. return;
  3487. }
  3488. if (entity.OrderState == 6)
  3489. {
  3490. isPlace = true;
  3491. }
  3492. bool isNeedUpdateCell2 = false;
  3493. if (entity.OrderState >= 6)
  3494. {
  3495. isNeedUpdateCell2 = true;
  3496. }
  3497. int returnTag = 2;
  3498. if (userpost == "Supplier")
  3499. {
  3500. returnTag = 1;
  3501. }
  3502. int toType = GetPostInt("totype");
  3503. string fromType = "3";
  3504. if (entity.OrderState < 5)
  3505. {
  3506. fromType = "3";
  3507. }
  3508. else
  3509. {
  3510. fromType = "4";
  3511. }
  3512. if (entity.IsXianHuo == 0)
  3513. {
  3514. if (returnTag == 2)
  3515. {
  3516. if (toType == 1)
  3517. {
  3518. entity.OrderState = 0;
  3519. entity.ReturnUserType = 1;
  3520. string clearman = GetPostString("clearman");
  3521. if (!string.IsNullOrEmpty(clearman))
  3522. {
  3523. entity.DesignUserId = 0;
  3524. }
  3525. }
  3526. else
  3527. {
  3528. entity.OrderState = 3;
  3529. entity.ReturnUserType = 2;
  3530. }
  3531. entity.IsReadTag = 1;
  3532. }
  3533. else if (returnTag == 1)
  3534. {
  3535. entity.OrderState = 5;
  3536. }
  3537. entity.IsVerifyToSupplier = false;
  3538. }
  3539. if (entity.IsXianHuo == 1)
  3540. {
  3541. entity.OrderState = 5;
  3542. }
  3543. entity.UnusualTag = 0;
  3544. entity.UnusualTime = null;
  3545. entity.UnusualCon = "";
  3546. entity.IsReturn = returnTag;
  3547. entity.ReturnTime = DateTime.Now;
  3548. entity.ReturnReason = GetPostString("returnreason");
  3549. entity.Update();
  3550. if (entity.OrderState == 3)
  3551. {
  3552. ApiVo apiVo = new ApiVo();
  3553. apiVo.orderNumber = entity.ctid;
  3554. apiVo.actionName = "rebutDesign";
  3555. apiVo.orderRemarks = entity.ReturnReason;
  3556. designHelper.API_WorkCore(apiVo);//rebutDesign
  3557. }
  3558. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3559. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3560. {
  3561. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3562. }
  3563. CeErpSukuraData.createInfo(entity.ctid, 5);
  3564. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3565. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3566. if (isPlace)
  3567. {
  3568. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3569. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3570. if (dth != null && dth.Rows.Count > 0)
  3571. {
  3572. dataSendOrderBean dataSendOrderBean = null;
  3573. foreach (DataRow item in dth.Rows)
  3574. {
  3575. try
  3576. {
  3577. dataSendOrderBean = new dataSendOrderBean();
  3578. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3579. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3580. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3581. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3582. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3583. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3584. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3585. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3586. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3587. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3588. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3589. dataSendOrderBean.Radio1723534706288 = "打回";
  3590. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3591. if (result != null)
  3592. {
  3593. if ("0".Equals(result.errcode))
  3594. {
  3595. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3596. }
  3597. else
  3598. {
  3599. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3600. }
  3601. }
  3602. }
  3603. catch (Exception ex)
  3604. {
  3605. }
  3606. }
  3607. }
  3608. }
  3609. if (isNeedUpdateCell2)
  3610. {
  3611. if (entity.MakeSupplier.IndexOf(",") != -1)
  3612. {
  3613. StringBuilder sql2 = new StringBuilder();
  3614. 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);
  3615. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3616. }
  3617. else
  3618. {
  3619. StringBuilder sql2 = new StringBuilder();
  3620. 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);
  3621. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3622. }
  3623. }
  3624. returnSuccessMsg("操作成功!");
  3625. return;
  3626. }
  3627. returnErrorMsg("找不到订单记录");
  3628. }
  3629. }
  3630. public void cyt_erp_returnreason()
  3631. {
  3632. if (UrlPostParmsCheck("ctid"))
  3633. {
  3634. string eid = GetPostString("ctid");
  3635. CeErpTradeCell entity = null;
  3636. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3637. string userpost = CurrentUser.UserPost.Post.Code;
  3638. if (entity != null)
  3639. {
  3640. if (entity.OrderState > 6)
  3641. {
  3642. returnErrorMsg("已发货无法打回!");
  3643. return;
  3644. }
  3645. JObject jsonObject = new JObject
  3646. {
  3647. { "Userid", "77886" },
  3648. { "Pwd", "lt666888" },
  3649. { "LTOrderId",eid }
  3650. };
  3651. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3652. JObject jsonObjects = JObject.Parse(response);
  3653. string msg = (string)jsonObjects["msg"];
  3654. if (msg != "取消成功")
  3655. {
  3656. returnErrorMsg(msg);
  3657. return;
  3658. }
  3659. bool isNeedUpdateCell2 = false;
  3660. if (entity.OrderState >= 6)
  3661. {
  3662. isNeedUpdateCell2 = true;
  3663. }
  3664. int returnTag = 2;
  3665. if (userpost == "Supplier")
  3666. {
  3667. returnTag = 1;
  3668. }
  3669. if (entity.IsXianHuo == 0)
  3670. {
  3671. if (returnTag == 2)
  3672. {
  3673. int toType = GetPostInt("totype");
  3674. if (toType == 1)
  3675. {
  3676. entity.OrderState = 0;
  3677. entity.ReturnUserType = 1;
  3678. }
  3679. else
  3680. {
  3681. entity.OrderState = 4;
  3682. entity.ReturnUserType = 2;
  3683. }
  3684. entity.IsReadTag = 1;
  3685. }
  3686. else if (returnTag == 1)
  3687. {
  3688. entity.OrderState = 5;
  3689. }
  3690. entity.IsVerifyToSupplier = false;
  3691. }
  3692. entity.UnusualTag = 0;
  3693. entity.UnusualTime = null;
  3694. entity.UnusualCon = "";
  3695. entity.IsReturn = returnTag;
  3696. entity.ReturnTime = DateTime.Now;
  3697. entity.ReturnReason = GetPostString("returnreason");
  3698. entity.Update();
  3699. if (entity.OrderState == 4)
  3700. {
  3701. ApiVo apiVo = new ApiVo();
  3702. apiVo.orderNumber = entity.ctid;
  3703. apiVo.actionName = "rebutDesign";
  3704. apiVo.orderRemarks = entity.ReturnReason;
  3705. designHelper.API_WorkCore(apiVo);//rebutDesign
  3706. }
  3707. CeErpSukuraData.createInfo(entity.ctid, 5);
  3708. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3709. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3710. if (isNeedUpdateCell2)
  3711. {
  3712. if (entity.MakeSupplier.IndexOf(",") != -1)
  3713. {
  3714. StringBuilder sql2 = new StringBuilder();
  3715. 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);
  3716. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3717. }
  3718. else
  3719. {
  3720. StringBuilder sql2 = new StringBuilder();
  3721. 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);
  3722. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3723. }
  3724. }
  3725. returnSuccessMsg("操作成功!");
  3726. return;
  3727. }
  3728. returnErrorMsg("找不到订单记录");
  3729. }
  3730. }
  3731. public void upd_erp_xianhuoreturntag()
  3732. {
  3733. if (UrlPostParmsCheck("ctid"))
  3734. {
  3735. string eids = GetPostString("ctid");
  3736. string[] ctids = eids.Split(',');
  3737. foreach (string ctid in ctids)
  3738. {
  3739. CeErpTradeCell entity = null;
  3740. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3741. if (entity != null)
  3742. {
  3743. entity.IsReturn = 0;
  3744. entity.Update();
  3745. CeErpSukuraData.createInfo(entity.ctid, 5);
  3746. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3747. }
  3748. }
  3749. returnSuccessMsg("操作成功!");
  3750. return;
  3751. }
  3752. }
  3753. public void get_erp_waitdeliverylist()
  3754. {
  3755. DataStruct dStruct = GetPostStruct();
  3756. List<string> lw = new List<string>();
  3757. string tid = GetPostString("ctid");
  3758. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3759. string shopname = GetPostString("shopname");
  3760. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3761. string buyernick = GetPostString("buyer_nick");
  3762. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3763. //if (tid.Length == 0 && buyernick.Length == 0)
  3764. //{
  3765. // lw.Add(string.Format("IsRefund<={0}", 1));
  3766. //}
  3767. string customer = GetPostString("customer");
  3768. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3769. string design = GetPostString("design");
  3770. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3771. string orderState = GetPostString("orderState");
  3772. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3773. string address = GetPostString("address");
  3774. 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));
  3775. string sellermemo = GetPostString("seller_memo");
  3776. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3777. string supplier = GetPostString("supplier");
  3778. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3779. string OrderArea = GetPostString("order_area");
  3780. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3781. string placedate1 = GetPostString("placedate1");
  3782. string placedate2 = GetPostString("placedate2");
  3783. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3784. if (fdw.Length > 0) lw.Add(fdw);
  3785. string price1 = GetPostString("price1");
  3786. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3787. string price2 = GetPostString("price2");
  3788. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3789. string unusualCon = GetPostString("unusualcon");
  3790. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3791. string otherMemo = GetPostString("otherMemo");
  3792. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3793. string posTag = CurrentUser.UserPost.Post.Code;
  3794. if (posTag == "Supplier")
  3795. {
  3796. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3797. }
  3798. lw.Add(string.Format("OrderState = 6 "));
  3799. lw.Add(string.Format("type != 'PDD' "));
  3800. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3801. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3802. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3803. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3804. writeGridDataTableJson(dStruct.TotalCount, dt);
  3805. }
  3806. public void get_erp_pddderiving()
  3807. {
  3808. DataStruct dStruct = GetPostStruct();
  3809. List<string> lw = new List<string>();
  3810. string tid = GetPostString("ctid");
  3811. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3812. string shopname = GetPostString("shopname");
  3813. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3814. string buyernick = GetPostString("buyer_nick");
  3815. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3816. //if (tid.Length == 0 && buyernick.Length == 0)
  3817. //{
  3818. // lw.Add(string.Format("IsRefund<={0}", 1));
  3819. //}
  3820. string customer = GetPostString("customer");
  3821. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3822. string design = GetPostString("design");
  3823. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3824. string orderState = GetPostString("orderState");
  3825. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3826. string address = GetPostString("address");
  3827. 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));
  3828. string sellermemo = GetPostString("seller_memo");
  3829. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3830. string supplier = GetPostString("supplier");
  3831. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3832. string OrderArea = GetPostString("order_area");
  3833. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3834. string placedate1 = GetPostString("placedate1");
  3835. string placedate2 = GetPostString("placedate2");
  3836. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3837. if (fdw.Length > 0) lw.Add(fdw);
  3838. string price1 = GetPostString("price1");
  3839. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3840. string price2 = GetPostString("price2");
  3841. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3842. string unusualCon = GetPostString("unusualcon");
  3843. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3844. string posTag = CurrentUser.UserPost.Post.Code;
  3845. if (posTag == "Supplier")
  3846. {
  3847. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3848. }
  3849. lw.Add(string.Format("OrderState = 6 "));
  3850. lw.Add(string.Format("type = 'PDD' "));
  3851. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3852. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3853. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3854. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3855. writeGridDataTableJson(dStruct.TotalCount, dt);
  3856. }
  3857. public void get_erp_jdderiving()
  3858. {
  3859. DataStruct dStruct = GetPostStruct();
  3860. List<string> lw = new List<string>();
  3861. string tid = GetPostString("ctid");
  3862. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3863. string shopname = GetPostString("shopname");
  3864. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3865. string buyernick = GetPostString("buyer_nick");
  3866. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3867. //if (tid.Length == 0 && buyernick.Length == 0)
  3868. //{
  3869. // lw.Add(string.Format("IsRefund<={0}", 1));
  3870. //}
  3871. string customer = GetPostString("customer");
  3872. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3873. string design = GetPostString("design");
  3874. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3875. string orderState = GetPostString("orderState");
  3876. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3877. string address = GetPostString("address");
  3878. 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));
  3879. string sellermemo = GetPostString("seller_memo");
  3880. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3881. string supplier = GetPostString("supplier");
  3882. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3883. string OrderArea = GetPostString("order_area");
  3884. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3885. string placedate1 = GetPostString("placedate1");
  3886. string placedate2 = GetPostString("placedate2");
  3887. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3888. if (fdw.Length > 0) lw.Add(fdw);
  3889. string price1 = GetPostString("price1");
  3890. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3891. string price2 = GetPostString("price2");
  3892. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3893. string unusualCon = GetPostString("unusualcon");
  3894. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3895. string posTag = CurrentUser.UserPost.Post.Code;
  3896. if (posTag == "Supplier")
  3897. {
  3898. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3899. }
  3900. lw.Add(string.Format("OrderState = 6 "));
  3901. lw.Add(string.Format("type = 'JD' "));
  3902. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3903. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3904. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3905. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3906. writeGridDataTableJson(dStruct.TotalCount, dt);
  3907. }
  3908. public void get_erp_demoorderlist()
  3909. {
  3910. DataStruct dStruct = GetPostStruct();
  3911. List<string> lw = new List<string>();
  3912. string tid = GetPostString("ctid");
  3913. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3914. string shopname = GetPostString("shopname");
  3915. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3916. string buyernick = GetPostString("buyer_nick");
  3917. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3918. string customer = GetPostString("customer");
  3919. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3920. string design = GetPostString("design");
  3921. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3922. string orderState = GetPostString("orderState");
  3923. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3924. string address = GetPostString("address");
  3925. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3926. string sellermemo = GetPostString("seller_memo");
  3927. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3928. string supplier = GetPostString("supplier");
  3929. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3930. string OrderArea = GetPostString("order_area");
  3931. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3932. string date1 = GetPostString("date1");
  3933. string date2 = GetPostString("date2");
  3934. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3935. if (dw.Length > 0) lw.Add(dw);
  3936. string price1 = GetPostString("price1");
  3937. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3938. string price2 = GetPostString("price2");
  3939. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3940. string posTag = CurrentUser.UserPost.Post.Code;
  3941. if (posTag == "Supplier")
  3942. {
  3943. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3944. }
  3945. //lw.Add(string.Format("OrderState = 6 "));
  3946. lw.Add(string.Format("IsSample={0}", 3));
  3947. lw.Add(string.Format("IsRefund<={0}", 1));
  3948. dStruct.Order = "pay_time desc";
  3949. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3950. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3951. writeGridDataTableJson(dStruct.TotalCount, dt);
  3952. }
  3953. public void save_erp_checkmemo()
  3954. {
  3955. if (UrlPostParmsCheck("ctid"))
  3956. {
  3957. string ctid = GetPostString("ctid");
  3958. CeErpTradeCell entity = null;
  3959. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3960. if (entity != null)
  3961. {
  3962. entity.CheckMemo = GetPostString("CheckMemo");
  3963. entity.Update();
  3964. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3965. if (trade != null)
  3966. {
  3967. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3968. }
  3969. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3970. returnSuccessMsg("保存成功!");
  3971. return;
  3972. }
  3973. returnErrorMsg("找不到记录");
  3974. }
  3975. }
  3976. public void get_erp_returnlist()
  3977. {
  3978. DataStruct dStruct = GetPostStruct();
  3979. List<string> lw = new List<string>();
  3980. string tid = GetPostString("ctid");
  3981. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3982. string shopname = GetPostString("shopname");
  3983. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3984. string buyernick = GetPostString("buyer_nick");
  3985. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3986. string customer = GetPostString("customer");
  3987. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3988. string design = GetPostString("design");
  3989. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3990. string orderState = GetPostString("orderState");
  3991. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3992. string address = GetPostString("address");
  3993. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3994. string sellermemo = GetPostString("seller_memo");
  3995. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3996. string supplier = GetPostString("supplier");
  3997. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3998. string date1 = GetPostString("date1");
  3999. string date2 = GetPostString("date2");
  4000. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4001. if (dw.Length > 0) lw.Add(dw);
  4002. string bdate1 = GetPostString("backdate1");
  4003. string bdate2 = GetPostString("backdate2");
  4004. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4005. if (dw_back.Length > 0) lw.Add(dw_back);
  4006. string price1 = GetPostString("price1");
  4007. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4008. string price2 = GetPostString("price2");
  4009. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4010. lw.Add(string.Format("IsReturn>0"));
  4011. lw.Add(string.Format("IsXianHuo=0"));
  4012. lw.Add(string.Format("IsReturn!=3"));
  4013. string backtype = GetPostString("backtype");
  4014. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4015. dStruct.Order = "FinishDesignTime desc";
  4016. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4017. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4018. writeGridDataTableJson(dStruct.TotalCount, dt);
  4019. }
  4020. public void get_erp_today_sumreturn()
  4021. {
  4022. DataStruct dStruct = GetPostStruct();
  4023. List<string> lw = new List<string>();
  4024. string bdate1 = GetPostString("returnTimeS");
  4025. string bdate2 = GetPostString("returnTimeE");
  4026. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4027. if (dw_back.Length > 0) lw.Add(dw_back);
  4028. lw.Add(string.Format("IsReturn=0"));
  4029. lw.Add(string.Format("IsXianHuo=0"));
  4030. string mainWhere = string.Join(" and ", lw.ToArray());
  4031. string sql = "";
  4032. if (dw_back.Length > 0)
  4033. {
  4034. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4035. }
  4036. else
  4037. {
  4038. 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 + "'";
  4039. }
  4040. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4041. decimal total = 0, today_finish = 0;
  4042. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4043. {
  4044. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4045. }
  4046. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4047. {
  4048. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4049. }
  4050. var res = new
  4051. {
  4052. data = total,
  4053. data1 = today_finish,
  4054. };
  4055. string ro_jsond = JsonConvert.SerializeObject(res);
  4056. returnSuccess(ro_jsond);
  4057. return;
  4058. }
  4059. public void get_erp_allreturnlist()
  4060. {
  4061. DataStruct dStruct = GetPostStruct();
  4062. List<string> lw = new List<string>();
  4063. string tid = GetPostString("ctid");
  4064. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4065. string shopname = GetPostString("shopname");
  4066. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4067. string buyernick = GetPostString("buyer_nick");
  4068. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4069. string customer = GetPostString("customer");
  4070. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4071. string design = GetPostString("design");
  4072. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4073. string orderState = GetPostString("orderState");
  4074. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4075. string address = GetPostString("address");
  4076. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4077. string sellermemo = GetPostString("seller_memo");
  4078. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4079. string supplier = GetPostString("supplier");
  4080. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4081. string date1 = GetPostString("date1");
  4082. string date2 = GetPostString("date2");
  4083. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4084. if (dw.Length > 0) lw.Add(dw);
  4085. string bdate1 = GetPostString("backdate1");
  4086. string bdate2 = GetPostString("backdate2");
  4087. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4088. if (dw_back.Length > 0) lw.Add(dw_back);
  4089. string price1 = GetPostString("price1");
  4090. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4091. string price2 = GetPostString("price2");
  4092. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4093. string backreason = GetPostString("backreason");
  4094. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4095. lw.Add(string.Format("IsXianHuo=0"));
  4096. lw.Add(string.Format("ReturnTime != ''"));
  4097. string backtype = GetPostString("backtype");
  4098. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4099. dStruct.Order = "FinishDesignTime desc";
  4100. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4101. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4102. writeGridDataTableJson(dStruct.TotalCount, dt);
  4103. }
  4104. public void get_erp_aftersalereturnlist()
  4105. {
  4106. DataStruct dStruct = GetPostStruct();
  4107. List<string> lw = new List<string>();
  4108. string tid = GetPostString("ctid");
  4109. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4110. string shopname = GetPostString("shopname");
  4111. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4112. string buyernick = GetPostString("buyer_nick");
  4113. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4114. string customer = GetPostString("customer");
  4115. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4116. string design = GetPostString("design");
  4117. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4118. string orderState = GetPostString("orderState");
  4119. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4120. string address = GetPostString("address");
  4121. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4122. string sellermemo = GetPostString("seller_memo");
  4123. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4124. string supplier = GetPostString("supplier");
  4125. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4126. string date1 = GetPostString("date1");
  4127. string date2 = GetPostString("date2");
  4128. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4129. if (dw.Length > 0) lw.Add(dw);
  4130. string bdate1 = GetPostString("backdate1");
  4131. string bdate2 = GetPostString("backdate2");
  4132. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4133. if (dw_back.Length > 0) lw.Add(dw_back);
  4134. string price1 = GetPostString("price1");
  4135. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4136. string price2 = GetPostString("price2");
  4137. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4138. lw.Add(string.Format("IsReturn=3"));
  4139. string backtype = GetPostString("backtype");
  4140. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4141. string backreason = GetPostString("backreason");
  4142. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4143. dStruct.Order = "ReturnTime desc";
  4144. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4145. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4146. writeGridDataTableJson(dStruct.TotalCount, dt);
  4147. }
  4148. public void get_erp_xianhuoreturnlist()
  4149. {
  4150. DataStruct dStruct = GetPostStruct();
  4151. List<string> lw = new List<string>();
  4152. string tid = GetPostString("ctid");
  4153. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4154. string shopname = GetPostString("shopname");
  4155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4156. string buyernick = GetPostString("buyer_nick");
  4157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4158. string customer = GetPostString("customer");
  4159. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4160. string design = GetPostString("design");
  4161. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4162. string orderState = GetPostString("orderState");
  4163. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4164. string address = GetPostString("address");
  4165. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4166. string sellermemo = GetPostString("seller_memo");
  4167. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4168. string supplier = GetPostString("supplier");
  4169. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4170. string OrderArea = GetPostString("order_area");
  4171. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4172. string date1 = GetPostString("date1");
  4173. string date2 = GetPostString("date2");
  4174. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4175. if (dw.Length > 0) lw.Add(dw);
  4176. string price1 = GetPostString("price1");
  4177. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4178. string price2 = GetPostString("price2");
  4179. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4180. string posTag = CurrentUser.UserPost.Post.Code;
  4181. if (posTag == "Supplier")
  4182. {
  4183. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4184. }
  4185. lw.Add(string.Format("OrderState=6 "));
  4186. lw.Add(string.Format("IsXianHuo=1 "));
  4187. lw.Add(string.Format("IsReturn>0 "));
  4188. lw.Add(string.Format("IsReturn!=3"));
  4189. lw.Add(string.Format("IsRefund<={0}", 1));
  4190. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4191. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4192. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4193. writeGridDataTableJson(dStruct.TotalCount, dt);
  4194. }
  4195. public void set_erp_orderdelivery()
  4196. {
  4197. if (UrlPostParmsCheck("ctid"))
  4198. {
  4199. string eid = GetPostString("ctid");
  4200. CeErpTradeCell entity = null;
  4201. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4202. if (entity != null)
  4203. {
  4204. if (entity.OrderState >= 7)
  4205. {
  4206. returnErrorMsg("此单已发货,无需重复发货");
  4207. return;
  4208. }
  4209. if (entity.OrderState != 6)
  4210. {
  4211. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4212. return;
  4213. }
  4214. string shop = GetPostString("seller_nick");
  4215. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4216. string comName = GetPostString("comName");
  4217. string comCode = GetPostString("comCode");
  4218. string outSid = GetPostString("outSid");
  4219. string deliveryType = GetPostString("deliveryType");
  4220. string deliveryMemo = GetPostString("deliveryMemo");
  4221. outSid = outSid.Trim();
  4222. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4223. if (mainEn == null)
  4224. {
  4225. returnErrorMsg("找不到原始订单记录");
  4226. return;
  4227. }
  4228. bool isInitOrderDeliv = false;
  4229. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4230. {
  4231. isInitOrderDeliv = true;
  4232. }
  4233. string apires = "";
  4234. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4235. 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)
  4236. {
  4237. apires = "发货成功true";
  4238. }
  4239. else
  4240. {
  4241. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4242. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4243. }
  4244. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4245. {
  4246. entity.OrderState = 7;//发货后订单已发货
  4247. entity.OutSid = outSid;
  4248. entity.MemoOpt = 0;
  4249. entity.FinishDeliveryTime = DateTime.Now;
  4250. entity.Update();
  4251. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4252. commonHelper.UpdateRelationOrder(entity.ctid);
  4253. //还要插入快递信息到 快递信息表
  4254. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4255. exinfo.tid = eid;
  4256. exinfo.out_sid = outSid;
  4257. exinfo.company_code = comCode;
  4258. exinfo.company_name = comName;
  4259. exinfo.delivery_memo = deliveryMemo;
  4260. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4261. exinfo.deliveryType = deliveryType;
  4262. exinfo.Create();
  4263. returnSuccessMsg("发货操作成功!");
  4264. commonHelper.UpdateRelationOrder(entity.ctid);
  4265. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4266. CeErpSukuraData.createInfo(entity.ctid, 4);
  4267. if (entity.SupplierId == 64)
  4268. {
  4269. commonHelper.sendCytExpress(exinfo);
  4270. }
  4271. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4272. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4273. }
  4274. else
  4275. {
  4276. string errmsg = commonHelper.KeepChinese(apires);
  4277. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4278. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4279. }
  4280. return;
  4281. }
  4282. returnErrorMsg("找不到订单记录");
  4283. }
  4284. }
  4285. public void set_erp_multidelivery()
  4286. {
  4287. string eids = GetPostString("tids");
  4288. string[] eidList = eids.Split(',');
  4289. if (eidList.Length <= 0)
  4290. {
  4291. returnErrorMsg("发货不能为空");
  4292. return;
  4293. }
  4294. foreach (string ctid in eidList)
  4295. {
  4296. if (ctid.Length <= 0) continue;
  4297. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4298. if (expInfo != null)
  4299. {
  4300. StringBuilder sql = new StringBuilder();
  4301. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4302. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4303. if (dt.Rows.Count > 0)
  4304. {
  4305. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4306. {
  4307. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4308. expInfo.state = "异常";
  4309. expInfo.isMultiDelivery = 1;
  4310. expInfo.Update();
  4311. continue;
  4312. }
  4313. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4314. {
  4315. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4316. expInfo.state = "异常";
  4317. expInfo.Update();
  4318. continue;
  4319. }
  4320. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4321. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4322. bool isInitOrderDeliv = false;
  4323. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4324. {
  4325. isInitOrderDeliv = true;
  4326. expInfo.isMultiDelivery = 1;
  4327. }
  4328. if (ctid.IndexOf("N") != -1)
  4329. {
  4330. StringBuilder sqlbucha = new StringBuilder();
  4331. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4332. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4333. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4334. commonHelper.UpdateRelationOrder(ctid);
  4335. expInfo.delivery_memo = "发货成功";
  4336. expInfo.state = "发货成功";
  4337. expInfo.isMultiDelivery = 1;
  4338. expInfo.Update();
  4339. }
  4340. else
  4341. {
  4342. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4343. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4344. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4345. {
  4346. expInfo.delivery_memo = "发货成功";
  4347. expInfo.state = "发货成功";
  4348. expInfo.isMultiDelivery = 1;
  4349. expInfo.Update();
  4350. commonHelper.UpdateRelationOrder(ctid);
  4351. CeErpSukuraData.createInfo(ctid, 4);
  4352. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4353. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4354. }
  4355. else
  4356. {
  4357. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4358. expInfo.state = "异常";
  4359. expInfo.Update();
  4360. }
  4361. }
  4362. }
  4363. }
  4364. }
  4365. returnSuccessMsg("操作完成");
  4366. }
  4367. public void reset_erp_memoopt()
  4368. {
  4369. if (UrlPostParmsCheck("ctid"))
  4370. {
  4371. string eid = GetPostString("ctid");
  4372. CeErpTradeCell entity = null;
  4373. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4374. if (entity != null)
  4375. {
  4376. string stropt = "";
  4377. if (entity.MemoOpt == 1)
  4378. {
  4379. stropt = "“改稿”";
  4380. }
  4381. else if (entity.MemoOpt == 2)
  4382. {
  4383. stropt = "“定稿”";
  4384. }
  4385. else if (entity.MemoOpt == 3)
  4386. {
  4387. stropt = "“完成查货”";
  4388. CeErpSukuraData.createInfo(entity.ctid, 6);
  4389. }
  4390. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4391. entity.MemoOpt = 0;
  4392. entity.Update();
  4393. returnSuccessMsg("操作成功!");
  4394. return;
  4395. }
  4396. returnErrorMsg("找不到记录");
  4397. }
  4398. }
  4399. public void get_erp_deliveryunusual()
  4400. {
  4401. DataStruct dStruct = GetPostStruct();
  4402. List<string> lw = new List<string>();
  4403. string tid = GetPostString("ctid");
  4404. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4405. string shopname = GetPostString("shopname");
  4406. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4407. string buyernick = GetPostString("buyer_nick");
  4408. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4409. string customer = GetPostString("customer");
  4410. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4411. string design = GetPostString("design");
  4412. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4413. string sellermemo = GetPostString("seller_memo");
  4414. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4415. string supplier = GetPostString("supplier");
  4416. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4417. string date1 = GetPostString("date1");
  4418. string date2 = GetPostString("date2");
  4419. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4420. if (dw.Length > 0) lw.Add(dw);
  4421. string placedate1 = GetPostString("placedate1");
  4422. string placedate2 = GetPostString("placedate2");
  4423. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4424. if (dw_place.Length > 0) lw.Add(dw_place);
  4425. string price1 = GetPostString("price1");
  4426. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4427. string price2 = GetPostString("price2");
  4428. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4429. string unusualCon = GetPostString("unusualcon");
  4430. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4431. string posTag = CurrentUser.UserPost.Post.Code;
  4432. if (posTag == "Supplier")
  4433. {
  4434. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4435. }
  4436. lw.Add(string.Format("OrderState = 6"));
  4437. lw.Add(string.Format("UnusualTag = 5"));
  4438. lw.Add(string.Format("IsRefund<={0}", 1));
  4439. dStruct.Order = "FinishPlaceTime desc";
  4440. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4441. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4442. writeGridDataTableJson(dStruct.TotalCount, dt);
  4443. }
  4444. public void get_erp_deliveryedlist()
  4445. {
  4446. DataStruct dStruct = GetPostStruct();
  4447. List<string> lw = new List<string>();
  4448. string tid = GetPostString("ctid");
  4449. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4450. string shopname = GetPostString("shopname");
  4451. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4452. string buyernick = GetPostString("buyer_nick");
  4453. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4454. string customer = GetPostString("customer");
  4455. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4456. string design = GetPostString("design");
  4457. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4458. string sellermemo = GetPostString("seller_memo");
  4459. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4460. string logistics = GetPostString("logistics");
  4461. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4462. string date1 = GetPostString("date1");
  4463. string date2 = GetPostString("date2");
  4464. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4465. //if (dw.Length > 0) lw.Add(dw);
  4466. string placedate1 = GetPostString("placedate1");
  4467. string placedate2 = GetPostString("placedate2");
  4468. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4469. if (fdw.Length > 0) lw.Add(fdw);
  4470. string devdate1 = GetPostString("deliverydate1");
  4471. string devdate2 = GetPostString("deliverydate2");
  4472. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4473. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4474. string price1 = GetPostString("price1");
  4475. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4476. string price2 = GetPostString("price2");
  4477. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4478. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4479. {
  4480. if (tid.Length > 0)
  4481. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4482. if (buyernick.Length > 0)
  4483. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4484. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4485. if (dw.Length > 0) lw.Add(dw);
  4486. }
  4487. else
  4488. {
  4489. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4490. }
  4491. string posTag = CurrentUser.UserPost.Post.Code;
  4492. if (posTag == "Supplier")
  4493. {
  4494. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4495. }
  4496. else
  4497. {
  4498. string supplier = GetPostString("supplier");
  4499. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4500. }
  4501. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4502. lw.Add(string.Format("IsRefund!={0}", 2));
  4503. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4504. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4505. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4506. if (dt != null)
  4507. {
  4508. foreach (DataRow dr in dt.Rows)
  4509. {
  4510. 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();
  4511. }
  4512. }
  4513. writeGridDataTableJson(dStruct.TotalCount, dt);
  4514. }
  4515. public void get_erp_pdddeliveryed()
  4516. {
  4517. DataStruct dStruct = GetPostStruct();
  4518. List<string> lw = new List<string>();
  4519. string tid = GetPostString("ctid");
  4520. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4521. string shopname = GetPostString("shopname");
  4522. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4523. string buyernick = GetPostString("buyer_nick");
  4524. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4525. string customer = GetPostString("customer");
  4526. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4527. string design = GetPostString("design");
  4528. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4529. string sellermemo = GetPostString("seller_memo");
  4530. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4531. string logistics = GetPostString("logistics");
  4532. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4533. string date1 = GetPostString("date1");
  4534. string date2 = GetPostString("date2");
  4535. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4536. //if (dw.Length > 0) lw.Add(dw);
  4537. string placedate1 = GetPostString("placedate1");
  4538. string placedate2 = GetPostString("placedate2");
  4539. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4540. if (fdw.Length > 0) lw.Add(fdw);
  4541. string devdate1 = GetPostString("deliverydate1");
  4542. string devdate2 = GetPostString("deliverydate2");
  4543. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4544. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4545. string price1 = GetPostString("price1");
  4546. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4547. string price2 = GetPostString("price2");
  4548. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4549. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4550. {
  4551. if (tid.Length > 0)
  4552. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4553. if (buyernick.Length > 0)
  4554. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4555. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4556. if (dw.Length > 0) lw.Add(dw);
  4557. }
  4558. else
  4559. {
  4560. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4561. }
  4562. string posTag = CurrentUser.UserPost.Post.Code;
  4563. if (posTag == "Supplier")
  4564. {
  4565. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4566. }
  4567. else
  4568. {
  4569. string supplier = GetPostString("supplier");
  4570. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4571. }
  4572. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4573. lw.Add(string.Format("type = 'PDD' "));
  4574. lw.Add(string.Format("IsRefund!={0}", 2));
  4575. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4576. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4577. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4578. foreach (DataRow dr in dt.Rows)
  4579. {
  4580. 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();
  4581. }
  4582. writeGridDataTableJson(dStruct.TotalCount, dt);
  4583. }
  4584. public void get_erp_jddeliveryed()
  4585. {
  4586. DataStruct dStruct = GetPostStruct();
  4587. List<string> lw = new List<string>();
  4588. string tid = GetPostString("ctid");
  4589. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4590. string shopname = GetPostString("shopname");
  4591. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4592. string buyernick = GetPostString("buyer_nick");
  4593. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4594. string customer = GetPostString("customer");
  4595. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4596. string design = GetPostString("design");
  4597. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4598. string sellermemo = GetPostString("seller_memo");
  4599. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4600. string date1 = GetPostString("date1");
  4601. string date2 = GetPostString("date2");
  4602. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4603. //if (dw.Length > 0) lw.Add(dw);
  4604. string placedate1 = GetPostString("placedate1");
  4605. string placedate2 = GetPostString("placedate2");
  4606. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4607. if (fdw.Length > 0) lw.Add(fdw);
  4608. string devdate1 = GetPostString("deliverydate1");
  4609. string devdate2 = GetPostString("deliverydate2");
  4610. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4611. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4612. string price1 = GetPostString("price1");
  4613. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4614. string price2 = GetPostString("price2");
  4615. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4616. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4617. {
  4618. if (tid.Length > 0)
  4619. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4620. if (buyernick.Length > 0)
  4621. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4622. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4623. if (dw.Length > 0) lw.Add(dw);
  4624. }
  4625. else
  4626. {
  4627. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4628. }
  4629. string posTag = CurrentUser.UserPost.Post.Code;
  4630. if (posTag == "Supplier")
  4631. {
  4632. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4633. }
  4634. else
  4635. {
  4636. string supplier = GetPostString("supplier");
  4637. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4638. }
  4639. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4640. lw.Add(string.Format("type = 'JD' "));
  4641. lw.Add(string.Format("IsRefund!={0}", 2));
  4642. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4643. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4644. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4645. foreach (DataRow dr in dt.Rows)
  4646. {
  4647. 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();
  4648. }
  4649. writeGridDataTableJson(dStruct.TotalCount, dt);
  4650. }
  4651. public void get_erp_allplacelist()
  4652. {
  4653. DataStruct dStruct = GetPostStruct();
  4654. List<string> lw = new List<string>();
  4655. string tid = GetPostString("ctid");
  4656. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4657. string shopname = GetPostString("shopname");
  4658. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4659. string buyernick = GetPostString("buyer_nick");
  4660. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4661. string customer = GetPostString("customer");
  4662. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4663. string design = GetPostString("design");
  4664. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4665. string sellermemo = GetPostString("seller_memo");
  4666. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4667. string supplier = GetPostString("supplier");
  4668. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4669. string date1 = GetPostString("date1");
  4670. string date2 = GetPostString("date2");
  4671. string pldate1 = GetPostString("placedate1");
  4672. string pldate2 = GetPostString("placedate2");
  4673. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4674. //if (dw.Length > 0) lw.Add(dw);
  4675. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4676. {
  4677. if (tid.Length > 0)
  4678. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4679. if (buyernick.Length > 0)
  4680. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4681. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4682. if (dw.Length > 0) lw.Add(dw);
  4683. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4684. if (dw_place.Length > 0) lw.Add(dw_place);
  4685. }
  4686. else
  4687. {
  4688. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4689. {
  4690. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4691. }
  4692. }
  4693. string price1 = GetPostString("price1");
  4694. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4695. string price2 = GetPostString("price2");
  4696. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4697. string posTag = CurrentUser.UserPost.Post.Code;
  4698. if (posTag == "Supplier")
  4699. {
  4700. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4701. }
  4702. lw.Add(string.Format("OrderState >= 6"));
  4703. lw.Add(string.Format("IsSample != 2 "));
  4704. lw.Add(string.Format("isDianziOrder = 0 "));
  4705. //lw.Add(string.Format("IsRefund<={0}", 1));
  4706. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4707. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4708. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4709. foreach (DataRow dr in dt.Rows)
  4710. {
  4711. 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();
  4712. }
  4713. writeGridDataTableJson(dStruct.TotalCount, dt);
  4714. }
  4715. public void get_erp_financeallplacelist()
  4716. {
  4717. DataStruct dStruct = GetPostStruct();
  4718. List<string> lw = new List<string>();
  4719. string tid = GetPostString("ctid");
  4720. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4721. string shopname = GetPostString("shopname");
  4722. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4723. string buyernick = GetPostString("buyer_nick");
  4724. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4725. string customer = GetPostString("customer");
  4726. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4727. string design = GetPostString("design");
  4728. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4729. string sellermemo = GetPostString("seller_memo");
  4730. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4731. string supplier = GetPostString("supplier");
  4732. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4733. string date1 = GetPostString("date1");
  4734. string date2 = GetPostString("date2");
  4735. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4736. if (dw.Length > 0) lw.Add(dw);
  4737. string pldate1 = GetPostString("placedate1");
  4738. string pldate2 = GetPostString("placedate2");
  4739. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4740. if (dw_place.Length > 0) lw.Add(dw_place);
  4741. string price1 = GetPostString("price1");
  4742. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4743. string price2 = GetPostString("price2");
  4744. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4745. string posTag = CurrentUser.UserPost.Post.Code;
  4746. if (posTag == "Supplier")
  4747. {
  4748. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4749. }
  4750. //lw.Add(string.Format("OrderState >= 6"));
  4751. lw.Add(string.Format("IsSample != 2 "));
  4752. lw.Add(string.Format("isDianziOrder = 0 "));
  4753. //lw.Add(string.Format("IsRefund<={0}", 1));
  4754. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4755. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4756. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4757. foreach (DataRow dr in dt.Rows)
  4758. {
  4759. 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();
  4760. }
  4761. writeGridDataTableJson(dStruct.TotalCount, dt);
  4762. }
  4763. public void get_erp_expresslist()
  4764. {
  4765. int listtype = GetInt("ltype");
  4766. DataStruct dStruct = GetPostStruct();
  4767. List<string> lw = new List<string>();
  4768. string tid = GetPostString("tid");
  4769. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4770. string outsid = GetPostString("out_sid");
  4771. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4772. string importer = GetPostString("ImportUserName");
  4773. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4774. string file = GetPostString("import_file");
  4775. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4776. string printman = GetPostString("printman");
  4777. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4778. string date1 = GetPostString("date1");
  4779. string date2 = GetPostString("date2");
  4780. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4781. if (dw.Length > 0) lw.Add(dw);
  4782. string fdate1 = GetPostString("finishdate1");
  4783. string fdate2 = GetPostString("finishdate2");
  4784. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4785. if (fdw.Length > 0) lw.Add(fdw);
  4786. if (listtype == 1)
  4787. {
  4788. lw.Add(string.Format("importUserId !=0"));
  4789. }
  4790. string posTag = CurrentUser.UserPost.Post.Code;
  4791. if (posTag == "Supplier")
  4792. {
  4793. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4794. }
  4795. if (dStruct.PageSize != 100000)
  4796. {
  4797. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4798. }
  4799. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4800. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4801. writeGridDataTableJson(dStruct.TotalCount, dt);
  4802. }
  4803. public void set_erp_buchaorderdelivery()
  4804. {
  4805. if (UrlPostParmsCheck("ctid"))
  4806. {
  4807. string eid = GetPostString("ctid");
  4808. CeErpTradeCell entity = null;
  4809. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4810. if (entity != null)
  4811. {
  4812. if (entity.IsSample != 2)
  4813. {
  4814. returnErrorMsg("补差价单才能标记为已发货");
  4815. return;
  4816. }
  4817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4818. entity.OrderState = 7;
  4819. entity.Update();
  4820. returnSuccessMsg("操作成功!");
  4821. return;
  4822. }
  4823. returnErrorMsg("找不到记录");
  4824. }
  4825. }
  4826. public void get_stdtemplates()
  4827. {
  4828. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4829. //string res = taobaoHelper.test();
  4830. string res = apiHelper.API_PrintTemplate();
  4831. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4832. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4833. {
  4834. int sidx = res.IndexOf("error_code");
  4835. int eidx = res.IndexOf("success");
  4836. string msg = res.Substring(sidx, eidx - sidx);
  4837. returnErrorMsg(msg);
  4838. return;
  4839. }
  4840. if (res.Length <= 0)
  4841. {
  4842. returnErrorMsg("模板数据为空!");
  4843. return;
  4844. }
  4845. ReturnSuccess(res);
  4846. }
  4847. public void cancel_print_order()
  4848. {
  4849. if (UrlPostParmsCheck("ctid"))
  4850. {
  4851. string ctid = GetPostString("ctid");
  4852. CeErpTradeCell entity = null;
  4853. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4854. if (entity != null)
  4855. {
  4856. string res = "";
  4857. string code = entity.LastBillWaybillCode;
  4858. if (code == "")
  4859. {
  4860. code = entity.OutSid;
  4861. }
  4862. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4863. XLog.SaveLog(0, "取消面单" + res);
  4864. }
  4865. }
  4866. }
  4867. public void set_erp_printwaybill()
  4868. {
  4869. if (UrlPostParmsCheck("ctid"))
  4870. {
  4871. string ctid = GetPostString("ctid");
  4872. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4873. string cpName = GetPostString("cpname");
  4874. string isTogether = GetPostString("together");
  4875. //var res_obj = new
  4876. //{
  4877. // restype = 1,
  4878. // 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\"}"
  4879. //};
  4880. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4881. //ReturnSuccess(ro_json);
  4882. //return;
  4883. bool isUseLastWayBillCode = false;
  4884. CeErpTradeCell entity = null;
  4885. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4886. if (entity != null)
  4887. {
  4888. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4889. {
  4890. isUseLastWayBillCode = true;
  4891. }
  4892. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4893. {
  4894. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4895. return;
  4896. }
  4897. }
  4898. string res = "";
  4899. Api_waybill_code_response_Obj fullObj = null;
  4900. string pData_str = "";
  4901. string curUseWayBillCode = "";
  4902. if (isUseLastWayBillCode == false)
  4903. {
  4904. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4905. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4906. if (res.IndexOf("failure") != -1)
  4907. {
  4908. //int idx = res.IndexOf("sub_message");
  4909. //int idx2 = res.IndexOf("flag");
  4910. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4911. string errMsgNeed = commonHelper.KeepChinese(res);
  4912. var res_objd = new
  4913. {
  4914. restype = 0,
  4915. data = "获取面单失败" + errMsgNeed
  4916. };
  4917. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4918. returnSuccess(ro_jsond);
  4919. if (res.IndexOf("停发") != -1)
  4920. {
  4921. entity.UnusualCon = "物流停发";
  4922. entity.Update();
  4923. }
  4924. //returnErrorMsg("获取面单失败,"+emsg);
  4925. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4926. return;
  4927. }
  4928. else if (res.IndexOf("errorMsg") != -1)
  4929. {
  4930. //int idx = res.IndexOf("errorMsg");
  4931. //int idx2 = res.IndexOf("}]}");
  4932. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4933. string errMsgNeed = commonHelper.KeepChinese(res);
  4934. var res_objf = new
  4935. {
  4936. restype = 0,
  4937. data = "获取面单失败2" + errMsgNeed
  4938. };
  4939. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4940. if (res.IndexOf("停发") != -1)
  4941. {
  4942. entity.UnusualCon = "物流停发";
  4943. entity.Update();
  4944. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4945. if (trade != null)
  4946. {
  4947. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4948. }
  4949. }
  4950. returnSuccess(ro_jsonf);
  4951. //returnErrorMsg("获取面单失败," + emsg);
  4952. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4953. return;
  4954. }
  4955. try
  4956. {
  4957. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4958. //res = res.Replace(" ", "");
  4959. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4960. }
  4961. catch (Exception ex)
  4962. {
  4963. XLog.SaveLog(0, "生成fullObj" + res);
  4964. var res_objf = new
  4965. {
  4966. restype = 0,
  4967. data = "生成fullObj发生错误" + ex.Message
  4968. };
  4969. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4970. returnSuccess(ro_jsonf);
  4971. return;
  4972. }
  4973. if (fullObj.response.data.content.Count > 0)
  4974. {
  4975. ContentItem codeObj = fullObj.response.data.content[0];
  4976. if (cpCode.IndexOf("SFFQ-") != -1)
  4977. {
  4978. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4979. }
  4980. else
  4981. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4982. curUseWayBillCode = codeObj.waybillCode;
  4983. }
  4984. else
  4985. {
  4986. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4987. var res_objf = new
  4988. {
  4989. restype = 0,
  4990. data = "生成fullObj找不到快递单号waybillCode"
  4991. };
  4992. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4993. returnSuccess(ro_jsonf);
  4994. return;
  4995. }
  4996. }
  4997. else
  4998. {
  4999. //使用上次打印的快递单号
  5000. if (cpCode == "SFFQ-LY")
  5001. {
  5002. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5003. }
  5004. else
  5005. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5006. curUseWayBillCode = entity.LastBillWaybillCode;
  5007. }
  5008. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5009. {
  5010. var res_obje = new
  5011. {
  5012. restype = 0,
  5013. data = "获取加密打印数据失败"
  5014. };
  5015. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5016. returnSuccess(ro_jsone);
  5017. entity.LastBillCpCode = cpCode;
  5018. entity.LastBillWaybillCode = curUseWayBillCode;
  5019. entity.Update();
  5020. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5021. //returnErrorMsg("获取加密打印数据失败");
  5022. return;
  5023. }
  5024. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5025. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5026. string btnType = "";
  5027. if (entity != null)
  5028. {
  5029. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5030. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5031. //cpcode是 YTO-CAINIAO
  5032. //string comCode = cpCode.Split('-')[0].ToString();
  5033. string apires = "";
  5034. if (ctid.IndexOf("N") != -1)
  5035. {
  5036. apires = "发货成功";
  5037. }
  5038. else
  5039. {
  5040. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5041. }
  5042. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5043. //打单后发货
  5044. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5045. {
  5046. try
  5047. {
  5048. btnType = "待发货";
  5049. entity.OutSid = curUseWayBillCode;
  5050. entity.OrderState = 7;
  5051. entity.IsUrgency = false;
  5052. entity.LastBillCpCode = "";
  5053. entity.LastBillWaybillCode = "";
  5054. entity.FinishDeliveryTime = DateTime.Now;
  5055. entity.IsReturn = 0;
  5056. entity.MemoOpt = 0;
  5057. entity.Update();
  5058. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5059. //还要插入快递信息到 快递信息表
  5060. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5061. exinfo.tid = entity.ctid;
  5062. exinfo.out_sid = entity.OutSid;
  5063. exinfo.company_code = cpCode;
  5064. exinfo.company_name = cpName;
  5065. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5066. exinfo.deliveryType = "发货成功";
  5067. exinfo.print_time = DateTime.Now;
  5068. exinfo.printUser = CurrentUser.UserName;
  5069. exinfo.Create();
  5070. commonHelper.UpdateRelationOrder(entity.ctid);
  5071. CeErpSukuraData.createInfo(ctid, 4);
  5072. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5073. if (entity.SupplierId == 64)
  5074. {
  5075. commonHelper.sendCytExpress(exinfo);
  5076. }
  5077. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5078. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5079. if (isTogether == "1")
  5080. {
  5081. StringBuilder sqlsb = new StringBuilder();
  5082. 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);
  5083. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5084. }
  5085. }
  5086. catch (Exception ex)
  5087. {
  5088. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5089. }
  5090. }
  5091. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5092. {
  5093. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5094. if (entity.OrderState == 6)
  5095. {
  5096. entity.OrderState = 7;
  5097. }
  5098. entity.FinishDeliveryTime = DateTime.Now;
  5099. btnType = "已发货";
  5100. entity.Update();
  5101. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5102. exinfo.tid = entity.ctid;
  5103. exinfo.out_sid = entity.OutSid;
  5104. exinfo.company_code = cpCode;
  5105. exinfo.company_name = cpName;
  5106. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5107. exinfo.deliveryType = "发货成功";
  5108. exinfo.print_time = DateTime.Now;
  5109. exinfo.printUser = CurrentUser.UserName;
  5110. exinfo.Create();
  5111. commonHelper.UpdateRelationOrder(entity.ctid);
  5112. CeErpSukuraData.createInfo(entity.ctid, 4);
  5113. if (entity.SupplierId == 64)
  5114. {
  5115. commonHelper.sendCytExpress(exinfo);
  5116. }
  5117. if (isTogether == "1")
  5118. {
  5119. StringBuilder sqlsb = new StringBuilder();
  5120. 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);
  5121. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5122. }
  5123. //不处理
  5124. }
  5125. else
  5126. {
  5127. entity.LastBillCpCode = cpCode;
  5128. entity.LastBillWaybillCode = curUseWayBillCode;
  5129. entity.Update();
  5130. string errmsg = commonHelper.KeepChinese(apires);
  5131. var res_objz = new
  5132. {
  5133. restype = 0,
  5134. data = "打单后发货失败"
  5135. };
  5136. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5137. returnSuccess(ro_jsonz);
  5138. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5139. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5140. return;
  5141. }
  5142. }
  5143. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5144. var res_obj = new
  5145. {
  5146. restype = 1,
  5147. data = pData_str
  5148. };
  5149. string ro_json = JsonConvert.SerializeObject(res_obj);
  5150. ReturnSuccess(ro_json);
  5151. return;
  5152. }
  5153. }
  5154. private string GetUTF8String(byte[] vs)
  5155. {
  5156. throw new NotImplementedException();
  5157. }
  5158. public void set_erp_printwaybill_cn()
  5159. {
  5160. if (UrlPostParmsCheck("ctid"))
  5161. {
  5162. string ctid = GetPostString("ctid");
  5163. string cpCode = GetPostString("cpcode");
  5164. string cpName = GetPostString("cpname");
  5165. string tempUrl = GetPostString("tempurl");
  5166. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5167. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5168. //string res = taobaoHelper.test();
  5169. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5170. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5171. {
  5172. int sidx = res.IndexOf("errorMsg");
  5173. int eidx = res.IndexOf("}");
  5174. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5175. var res_objzxx = new
  5176. {
  5177. restype = 0,
  5178. data = msg
  5179. };
  5180. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5181. returnSuccess(ro_jsonzxx);
  5182. //returnErrorMsg(msg);
  5183. return;
  5184. }
  5185. int idx = res.IndexOf("waybillCode");
  5186. int idx2 = res.IndexOf("printData");
  5187. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5188. string eid = GetPostString("ctid");
  5189. CeErpTradeCell entity = null;
  5190. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5191. if (entity != null)
  5192. {
  5193. string osid = entity.OutSid;
  5194. entity.OutSid = osid + "," + outsid;
  5195. entity.FinishDeliveryTime = DateTime.Now;
  5196. entity.OrderState = 7;
  5197. entity.IsReturn = 0;
  5198. entity.Update();
  5199. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5200. exinfo.tid = entity.ctid;
  5201. exinfo.out_sid = outsid;
  5202. exinfo.company_code = cpCode;
  5203. exinfo.company_name = cpName;
  5204. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5205. exinfo.deliveryType = "发货成功";
  5206. exinfo.print_time = DateTime.Now;
  5207. exinfo.printUser = CurrentUser.UserName;
  5208. exinfo.Create();
  5209. if (entity.SupplierId == 64)
  5210. {
  5211. commonHelper.sendCytExpress(exinfo);
  5212. }
  5213. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5214. }
  5215. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5216. var res_objz = new
  5217. {
  5218. restype = 1,
  5219. data = res
  5220. };
  5221. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5222. returnSuccess(ro_jsonz);
  5223. //ReturnSuccess(res);
  5224. }
  5225. }
  5226. ////打单,打印面单 获取面单号
  5227. //public void set_erp_printwaybill()
  5228. //{
  5229. // if (UrlPostParmsCheck("ctid"))
  5230. // {
  5231. // string ctid = GetPostString("ctid");
  5232. // string cpCode = GetPostString("cpcode");
  5233. // string tempUrl = GetPostString("tempurl");
  5234. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5235. // //string res = taobaoHelper.test();
  5236. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5237. // if (res.IndexOf("error_response") != -1)
  5238. // {
  5239. // int sidx = res.IndexOf("sub_msg");
  5240. // int eidx = res.IndexOf("request_id");
  5241. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5242. // returnErrorMsg(msg);
  5243. // return;
  5244. // }
  5245. // int idx = res.IndexOf("waybill_code");
  5246. // int idx2 = res.IndexOf("}]}");
  5247. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5248. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5249. // ReturnSuccess(res);
  5250. // }
  5251. //}
  5252. public void cancel_erp_aftersale()
  5253. {
  5254. if (UrlPostParmsCheck("ctid"))
  5255. {
  5256. string eid = GetPostString("ctid");
  5257. CeErpTradeCell entity = null;
  5258. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5259. if (entity != null)
  5260. {
  5261. //有过处理的售后,取消也不能删除 售 字,保留
  5262. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5263. {
  5264. entity.AfterSaleState = 4;
  5265. }
  5266. else
  5267. entity.AfterSaleState = 0;
  5268. entity.Update();
  5269. returnSuccessMsg("操作成功!");
  5270. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5271. return;
  5272. }
  5273. returnErrorMsg("找不到订单记录");
  5274. }
  5275. }
  5276. public void get_erp_aftersalelist()
  5277. {
  5278. DataStruct dStruct = GetPostStruct();
  5279. List<string> lw = new List<string>();
  5280. int st = GetInt("st");
  5281. string tid = GetPostString("ctid");
  5282. if (st == 3)
  5283. {
  5284. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5285. }
  5286. else
  5287. {
  5288. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5289. }
  5290. string shopname = GetPostString("shopname");
  5291. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5292. string buyernick = GetPostString("buyer_nick");
  5293. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5294. string sellermemo = GetPostString("seller_memo");
  5295. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5296. string orderState = GetPostString("orderState");
  5297. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5298. string afterState = GetPostString("afterstate");
  5299. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5300. string date1 = GetPostString("date1");
  5301. string date2 = GetPostString("date2");
  5302. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5303. if (dw.Length > 0) lw.Add(dw);
  5304. string price1 = GetPostString("price1");
  5305. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5306. string price2 = GetPostString("price2");
  5307. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5308. //lw.Add(string.Format("IsRefund!={0}", 1));
  5309. string reason = GetPostString("reason");
  5310. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5311. string method = GetPostString("method");
  5312. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5313. string handler = GetPostString("handler");
  5314. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5315. string handledate1 = GetPostString("handledate1");
  5316. string handledate2 = GetPostString("handledate2");
  5317. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5318. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5319. string finish1 = GetPostString("finishdate1");
  5320. string finish2 = GetPostString("finishdate2");
  5321. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5322. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5323. string afterdate1 = GetPostString("afterdate1");
  5324. string afterdate2 = GetPostString("afterdate2");
  5325. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5326. if (afterDate.Length > 0) lw.Add(afterDate);
  5327. string supplier = GetPostString("supplier");
  5328. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5329. string responsible = GetPostString("responsibleman");
  5330. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5331. string customer = GetPostString("customer");
  5332. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5333. string design = GetPostString("design");
  5334. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5335. string afterMemoType = GetPostString("aftermemotype");
  5336. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5337. string posCode = CurrentUser.UserPost.Post.Code;
  5338. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5339. //{
  5340. // string vstate = GetPostString("vstate");
  5341. // if (vstate.Length > 0)
  5342. // {
  5343. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5344. // }
  5345. // if (posCode == "Supplier")
  5346. // {
  5347. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5348. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5349. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5350. // }
  5351. // else
  5352. // {
  5353. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5354. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5355. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5356. // {
  5357. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5358. // }
  5359. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5360. // {
  5361. // int orgid = CurrentUser.UserPost.OrgID;
  5362. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5363. // }
  5364. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5365. // {
  5366. // string shopid = CurrentUser.User.pemShop;
  5367. // lw.Add(string.Format("shopId in ({0})", shopid));
  5368. // }
  5369. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5370. // //{
  5371. // // int org_id = CurrentUser.UserPost.OrgID;
  5372. // // lw.Add(string.Format("OrgID={0}", org_id));
  5373. // //}
  5374. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5375. // }
  5376. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5377. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5378. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5379. //}
  5380. if (st == 5)
  5381. {
  5382. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5383. {
  5384. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5385. {
  5386. string shopid = CurrentUser.User.pemShop;
  5387. lw.Add(string.Format("shopId in ({0})", shopid));
  5388. }
  5389. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5390. {
  5391. int mrOrgid = CurrentUser.UserPost.OrgID;
  5392. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5393. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5394. }
  5395. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5396. //{
  5397. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5398. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5399. //}
  5400. else
  5401. {
  5402. string userIdStr = "";
  5403. if (posCode == "CustomerService")
  5404. {
  5405. userIdStr = CurrentUser.UserID + "_k";
  5406. }
  5407. else if (posCode == "Designer" || posCode == "wxDesigner")
  5408. {
  5409. userIdStr = CurrentUser.UserID + "_s";
  5410. }
  5411. else if (posCode == "Place")
  5412. {
  5413. userIdStr = CurrentUser.UserID + "_x";
  5414. }
  5415. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5416. }
  5417. }
  5418. string placedate1 = GetPostString("placedate1");
  5419. string placedate2 = GetPostString("placedate2");
  5420. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5421. if (dwplace.Length > 0) lw.Add(dwplace);
  5422. string supState = GetPostString("supState");
  5423. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5424. string searchType = GetPostString("searchType");
  5425. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5426. {
  5427. lw.Add(string.Format("BackNum>1"));
  5428. }
  5429. lw.Add(string.Format("AfterSaleState>0"));
  5430. if (ex_psize > 0)
  5431. {
  5432. if (CurrentUser.UserPost.Post.Code == "Finance")
  5433. dStruct.Order = "pay_time desc";
  5434. else
  5435. dStruct.Order = "HandleTime desc";
  5436. }
  5437. else
  5438. dStruct.Order = "HandleTime desc";
  5439. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5440. DataTable dt = WebCache.GetData("view_test", dStruct);
  5441. writeGridDataTableJson(dStruct.TotalCount, dt);
  5442. }
  5443. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5444. //{
  5445. // lw.Add(string.Format("AfterSaleState=4"));
  5446. // string code = CurrentUser.UserPost.Post.Code;
  5447. // if (code == "CustomerService")
  5448. // {
  5449. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5450. // }
  5451. // else if (code == "Designer" || code == "DesignerMr")
  5452. // {
  5453. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5454. // }
  5455. // else if (code == "Place" || code == "PlaceMr")
  5456. // {
  5457. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5458. // }
  5459. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5460. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5461. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5462. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5463. //}
  5464. //else //处理中的售后,待处理和处理中合并
  5465. //{
  5466. // if (afterState.Length <= 0)
  5467. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5468. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5469. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5470. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5471. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5472. //}
  5473. }
  5474. public void get_erp_disagreeftersalelist()
  5475. {
  5476. DataStruct dStruct = GetPostStruct();
  5477. List<string> lw = new List<string>();
  5478. int st = 2;
  5479. string tid = GetPostString("ctid");
  5480. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5481. string shopname = GetPostString("shopname");
  5482. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5483. string buyernick = GetPostString("buyer_nick");
  5484. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5485. string sellermemo = GetPostString("seller_memo");
  5486. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5487. string orderState = GetPostString("orderState");
  5488. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5489. string afterState = GetPostString("afterstate");
  5490. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5491. string date1 = GetPostString("date1");
  5492. string date2 = GetPostString("date2");
  5493. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5494. if (dw.Length > 0) lw.Add(dw);
  5495. string price1 = GetPostString("price1");
  5496. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5497. string price2 = GetPostString("price2");
  5498. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5499. //lw.Add(string.Format("IsRefund!={0}", 1));
  5500. string reason = GetPostString("reason");
  5501. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5502. string method = GetPostString("method");
  5503. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5504. string handler = GetPostString("handler");
  5505. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5506. string handledate1 = GetPostString("handledate1");
  5507. string handledate2 = GetPostString("handledate2");
  5508. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5509. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5510. string afterdate1 = GetPostString("afterdate1");
  5511. string afterdate2 = GetPostString("afterdate2");
  5512. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5513. if (afterDate.Length > 0) lw.Add(afterDate);
  5514. string backdate1 = GetPostString("backdate1");
  5515. string backdate2 = GetPostString("backdate2");
  5516. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5517. if (backDate.Length > 0) lw.Add(backDate);
  5518. string supplier = GetPostString("supplier");
  5519. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5520. string responsible = GetPostString("responsibleman");
  5521. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5522. string customer = GetPostString("customer");
  5523. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5524. string design = GetPostString("design");
  5525. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5526. string afterSaleMemo = GetPostString("afterSaleMemo");
  5527. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5528. string afterMemoType = GetPostString("aftermemotype");
  5529. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5530. string aftersakereason = GetPostString("aftersakereason");
  5531. if (aftersakereason.Length > 0)
  5532. {
  5533. if (aftersakereason == "1")
  5534. {
  5535. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5536. }
  5537. if (aftersakereason == "2")
  5538. {
  5539. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5540. }
  5541. }
  5542. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5543. string poscode = CurrentUser.UserPost.Post.Code;
  5544. if (poscode != "SysAdmin")
  5545. {
  5546. string shopid = CurrentUser.User.pemShop;
  5547. lw.Add(string.Format("shopId in ({0})", shopid));
  5548. }
  5549. string searchType = GetPostString("searchType");
  5550. if (searchType == "wait")
  5551. {
  5552. lw.Add(string.Format("HandleTime is null"));
  5553. }
  5554. if (searchType == "handling")
  5555. {
  5556. lw.Add(string.Format("HandleTime is not null "));
  5557. }
  5558. if (searchType == "back" || searchType == "puBack")
  5559. {
  5560. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5561. }
  5562. if (searchType == "reBack")
  5563. {
  5564. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5565. }
  5566. if (searchType == "moreBack")
  5567. {
  5568. lw.Add(string.Format("backNum > 1"));
  5569. }
  5570. lw.Add(string.Format("(AfterSaleState=5)"));
  5571. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5572. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5573. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5574. writeGridDataTableJson(dStruct.TotalCount, dt);
  5575. }
  5576. public void get_erp_handlingaftersalelist()
  5577. {
  5578. DataStruct dStruct = GetPostStruct();
  5579. List<string> lw = new List<string>();
  5580. int st = 2;
  5581. string tid = GetPostString("ctid");
  5582. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5583. string shopname = GetPostString("shopname");
  5584. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5585. string buyernick = GetPostString("buyer_nick");
  5586. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5587. string sellermemo = GetPostString("seller_memo");
  5588. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5589. string orderState = GetPostString("orderState");
  5590. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5591. string afterState = GetPostString("afterstate");
  5592. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5593. string date1 = GetPostString("date1");
  5594. string date2 = GetPostString("date2");
  5595. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5596. if (dw.Length > 0) lw.Add(dw);
  5597. string price1 = GetPostString("price1");
  5598. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5599. string price2 = GetPostString("price2");
  5600. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5601. //lw.Add(string.Format("IsRefund!={0}", 1));
  5602. string reason = GetPostString("reason");
  5603. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5604. string method = GetPostString("method");
  5605. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5606. string handler = GetPostString("handler");
  5607. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5608. string handledate1 = GetPostString("handledate1");
  5609. string handledate2 = GetPostString("handledate2");
  5610. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5611. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5612. string afterdate1 = GetPostString("afterdate1");
  5613. string afterdate2 = GetPostString("afterdate2");
  5614. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5615. if (afterDate.Length > 0) lw.Add(afterDate);
  5616. string supplier = GetPostString("supplier");
  5617. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5618. string responsible = GetPostString("responsibleman");
  5619. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5620. string customer = GetPostString("customer");
  5621. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5622. string design = GetPostString("design");
  5623. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5624. string afterSaleMemo = GetPostString("afterSaleMemo");
  5625. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5626. string afterMemoType = GetPostString("aftermemotype");
  5627. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5628. string afterresult = GetPostString("afterresult");
  5629. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5630. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5631. string poscode = CurrentUser.UserPost.Post.Code;
  5632. if (poscode != "SysAdmin")
  5633. {
  5634. string shopid = CurrentUser.User.pemShop;
  5635. lw.Add(string.Format("shopId in ({0})", shopid));
  5636. }
  5637. string searchType = GetPostString("searchType");
  5638. if (searchType == "wait")
  5639. {
  5640. lw.Add(string.Format("HandleTime is null"));
  5641. }
  5642. if (searchType == "documentary")
  5643. {
  5644. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5645. }
  5646. if (searchType == "handling")
  5647. {
  5648. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5649. }
  5650. if (searchType == "back" || searchType == "puBack")
  5651. {
  5652. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5653. }
  5654. if (searchType == "reBack")
  5655. {
  5656. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5657. }
  5658. if (afterState.Length <= 0)
  5659. {
  5660. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5661. }
  5662. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5663. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5664. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5665. writeGridDataTableJson(dStruct.TotalCount, dt);
  5666. }
  5667. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5668. //public void get_erp_back_handlingaftersalelist()
  5669. //{
  5670. // DataStruct dStruct = GetPostStruct();
  5671. // List<string> lw = new List<string>();
  5672. // string tid = GetPostString("ctid");
  5673. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5674. // string shopname = GetPostString("shopname");
  5675. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5676. // string buyernick = GetPostString("buyer_nick");
  5677. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5678. // string sellermemo = GetPostString("seller_memo");
  5679. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5680. // string orderState = GetPostString("orderState");
  5681. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5682. // string afterState = GetPostString("afterstate");
  5683. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5684. // string date1 = GetPostString("date1");
  5685. // string date2 = GetPostString("date2");
  5686. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5687. // if (dw.Length > 0) lw.Add(dw);
  5688. // string price1 = GetPostString("price1");
  5689. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5690. // string price2 = GetPostString("price2");
  5691. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5692. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5693. // string reason = GetPostString("reason");
  5694. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5695. // string method = GetPostString("method");
  5696. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5697. // string handler = GetPostString("handler");
  5698. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5699. // string handledate1 = GetPostString("handledate1");
  5700. // string handledate2 = GetPostString("handledate2");
  5701. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5702. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5703. // string afterdate1 = GetPostString("afterdate1");
  5704. // string afterdate2 = GetPostString("afterdate2");
  5705. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5706. // if (afterDate.Length > 0) lw.Add(afterDate);
  5707. // string supplier = GetPostString("supplier");
  5708. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5709. // string responsible = GetPostString("responsibleman");
  5710. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5711. // string customer = GetPostString("customer");
  5712. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5713. // string design = GetPostString("design");
  5714. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5715. // string afterMemoType = GetPostString("aftermemotype");
  5716. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5717. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5718. // if (afterState.Length <= 0)
  5719. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5720. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5721. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5722. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5723. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5724. //}
  5725. public void get_erp_aftersaleverifylist()
  5726. {
  5727. DataStruct dStruct = GetPostStruct();
  5728. List<string> lw = new List<string>();
  5729. string tid = GetPostString("ctid");
  5730. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5731. string shopname = GetPostString("shopname");
  5732. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5733. string buyernick = GetPostString("buyer_nick");
  5734. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5735. string sellermemo = GetPostString("seller_memo");
  5736. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5737. string orderState = GetPostString("orderState");
  5738. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5739. //lw.Add(string.Format("IsRefund!={0}", 1));
  5740. string reason = GetPostString("reason");
  5741. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5742. string method = GetPostString("method");
  5743. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5744. string handler = GetPostString("handler");
  5745. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5746. string handledate1 = GetPostString("handledate1");
  5747. string handledate2 = GetPostString("handledate2");
  5748. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5749. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5750. string finish1 = GetPostString("finishdate1");
  5751. string finish2 = GetPostString("finishdate2");
  5752. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5753. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5754. string supplier = GetPostString("supplier");
  5755. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5756. string responsible = GetPostString("responsibleman");
  5757. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5758. string posCode = CurrentUser.UserPost.Post.Code;
  5759. string vstate = GetPostString("vstate");
  5760. if (vstate.Length > 0)
  5761. {
  5762. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5763. }
  5764. if (posCode == "Supplier")
  5765. {
  5766. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5767. lw.Add(string.Format("VerifyState = 0"));
  5768. lw.Add("type = 1");
  5769. lw.Add(string.Format("AfterSaleState={0}", 3));
  5770. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5771. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5772. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5773. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5774. writeGridDataTableJson(dStruct.TotalCount, dt);
  5775. }
  5776. else if (posCode == "logistics")
  5777. {
  5778. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5779. lw.Add(string.Format("VerifyState = 0"));
  5780. lw.Add("type = 2");
  5781. lw.Add(string.Format("AfterSaleState={0}", 3));
  5782. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5783. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5784. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5785. writeGridDataTableJson(dStruct.TotalCount, dt);
  5786. }
  5787. else
  5788. {
  5789. lw.Add(string.Format("(AfterSaleState = 3)"));
  5790. string reasonState = GetPostString("reasonState");
  5791. lw.Add("type = 0");
  5792. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5793. || posCode == "Summarize" || posCode == "Finance")
  5794. {
  5795. if (reasonState == "2")
  5796. {
  5797. lw.Add("VerifyState = 3");
  5798. }
  5799. else if (reasonState == "1")
  5800. {
  5801. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5802. }
  5803. else
  5804. {
  5805. lw.Add("VerifyState in (0,3)");
  5806. }
  5807. //不加条件,可以看全部
  5808. }
  5809. 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")
  5810. {
  5811. int orgid = CurrentUser.UserPost.OrgID;
  5812. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5813. if (string.IsNullOrEmpty(manageOrgId))
  5814. {
  5815. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5816. }
  5817. else
  5818. {
  5819. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5820. }
  5821. if (reasonState == "1")
  5822. {
  5823. lw.Add("VerifyState = 3");
  5824. }
  5825. else if (reasonState == "2")
  5826. {
  5827. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5828. }
  5829. else
  5830. {
  5831. }
  5832. }
  5833. else
  5834. {
  5835. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5836. }
  5837. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5838. //{
  5839. // int org_id = CurrentUser.UserPost.OrgID;
  5840. // lw.Add(string.Format("OrgID={0}", org_id));
  5841. //}
  5842. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5843. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5844. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5845. writeGridDataTableJson(dStruct.TotalCount, dt);
  5846. }
  5847. }
  5848. public void get_erp_finishaftersalelist()
  5849. {
  5850. DataStruct dStruct = GetPostStruct();
  5851. List<string> lw = new List<string>();
  5852. int st = 4;
  5853. string tid = GetPostString("ctid");
  5854. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5855. string shopname = GetPostString("shopname");
  5856. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5857. //lw.Add(string.Format("IsRefund!={0}", 1));
  5858. string reason = GetPostString("reason");
  5859. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5860. string method = GetPostString("method");
  5861. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5862. string buyernick = GetPostString("buyer_nick");
  5863. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5864. string handler = GetPostString("handler");
  5865. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5866. string handledate1 = GetPostString("handledate1");
  5867. string handledate2 = GetPostString("handledate2");
  5868. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5869. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5870. string finish1 = GetPostString("finishdate1");
  5871. string finish2 = GetPostString("finishdate2");
  5872. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5873. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5874. string supplier = GetPostString("supplier");
  5875. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5876. string responsible = GetPostString("responsibleman");
  5877. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5878. string vstate = GetPostString("vstate");
  5879. if (vstate.Length > 0)
  5880. {
  5881. if ("3".Equals(vstate))
  5882. {
  5883. lw.Add(string.Format("IsTem=1"));
  5884. }
  5885. else
  5886. {
  5887. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5888. }
  5889. }
  5890. lw.Add(string.Format("AfterSaleState=4"));
  5891. string code = CurrentUser.UserPost.Post.Code;
  5892. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5893. {
  5894. //不加条件,可以看全部
  5895. }
  5896. else if (code == "Supplier")
  5897. {
  5898. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5899. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5900. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5901. }
  5902. else if (code == "logistics")
  5903. {
  5904. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5905. lw.Add("type = 2");
  5906. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5907. }
  5908. 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")
  5909. {
  5910. int orgid = CurrentUser.UserPost.OrgID;
  5911. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5912. if (string.IsNullOrEmpty(manageOrgIds))
  5913. {
  5914. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5915. }
  5916. else
  5917. {
  5918. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5919. }
  5920. }
  5921. else
  5922. {
  5923. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5924. }
  5925. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5926. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5927. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5928. writeGridDataTableJson(dStruct.TotalCount, dt);
  5929. }
  5930. public void handle_erp_aftersale()
  5931. {
  5932. if (UrlPostParmsCheck("ctid"))
  5933. {
  5934. string eid = GetPostString("ctid");
  5935. string responStr = GetPostString("AfterSaleResponsible");
  5936. if (responStr.Length <= 0)
  5937. {
  5938. returnErrorMsg("售后责任人不能为空");
  5939. return;
  5940. }
  5941. bool isDesign = false;
  5942. double designFree = 0.00;
  5943. int responsibleId = 0;
  5944. CeErpTradeCell entity = null;
  5945. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5946. if (entity != null)
  5947. {
  5948. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5949. string afterMethod = GetPostString("AfterSaleMethod");
  5950. if (isNeedNewOrder == 1)
  5951. {
  5952. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5953. bool ishav = true;
  5954. if (newentity == null)
  5955. {
  5956. newentity = entity.Clone() as CeErpTradeCell;
  5957. ishav = false;
  5958. newentity.ctid = "S_" + entity.ctid;
  5959. newentity.OrderState = 0;
  5960. }
  5961. //唯一标识
  5962. newentity.OrderSn = newentity.ctid;
  5963. /* string orderSn = dataHelper.getSaleOrderSn();
  5964. if (orderSn != "")
  5965. {
  5966. newentity.OrderSn = orderSn;
  5967. }*/
  5968. newentity.AfterSaleState = 0;
  5969. newentity.AfterSaleMethod = afterMethod;
  5970. if (!ishav)
  5971. {
  5972. string memo_str = newentity.seller_memo;
  5973. memo_str = memo_str.Replace("(", "(");
  5974. memo_str = memo_str.Replace(")", ")");
  5975. int sIndex = memo_str.IndexOf("(");
  5976. int eIndex = memo_str.IndexOf(")");
  5977. if (sIndex == -1 || eIndex == -1)
  5978. {
  5979. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5980. return;
  5981. }
  5982. string first = memo_str.Substring(0, sIndex + 1);
  5983. string memoCtid = newentity.OrderSn;
  5984. //if (memoCtid.IndexOf("C") != -1)
  5985. //{
  5986. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5987. //if (CIdx.IndexOf("+") != -1)
  5988. //{
  5989. //CIdx = "C" + CIdx.Split('+')[1];
  5990. //}
  5991. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5992. //}
  5993. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5994. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5995. string newMemo = first + memoCtid + last;
  5996. newentity.seller_memo = newMemo;
  5997. newentity.FinishPlaceTime = null;
  5998. newentity.UnusualTag = 0;
  5999. newentity.UnusualCon = "";
  6000. newentity.UnusualTime = null;
  6001. newentity.AfterSaleMemo = "";
  6002. newentity.AfterSaleMethod = afterMethod;
  6003. newentity.AfterSalePreTime = null;
  6004. newentity.AfterSaleReason = "";
  6005. newentity.AfterSaleResponsible = "";
  6006. newentity.AfterSaleState = 0;
  6007. newentity.AfterSaleTime = null;
  6008. newentity.AfterSaleUserId = 0;
  6009. newentity.AfterSaleSupplierState = 0;
  6010. newentity.LastBillWaybillCode = "";
  6011. newentity.LastBillCpCode = "";
  6012. newentity.FinishAfterSaleTime = null;
  6013. newentity.HandleTime = null;
  6014. newentity.IsSF = 0;
  6015. newentity.IsOldCustomer = 0;
  6016. newentity.UrgencyTime = null;
  6017. newentity.ResponsibleUserId = "";
  6018. newentity.IsVerifyToSupplier = false;
  6019. newentity.payment = 0;
  6020. newentity.CheckMemo = "";
  6021. newentity.OutSid = "";
  6022. newentity.CheckOrderTime = null;
  6023. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6024. }
  6025. newentity.isAfterSaleOrder = 1;
  6026. newentity.IsRefund = 0;
  6027. string receiveMobile = GetPostString("receiver_mobile");
  6028. if (receiveMobile.Length > 0)
  6029. {
  6030. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6031. if (trade != null)
  6032. {
  6033. trade.receiver_name = GetPostString("receiver_name");
  6034. trade.receiver_mobile = receiveMobile;
  6035. trade.receiver_state = GetPostString("receiver_state");
  6036. trade.receiver_city = GetPostString("receiver_city");
  6037. trade.receiver_district = GetPostString("receiver_district");
  6038. trade.receiver_address = GetPostString("receiver_address");
  6039. newentity.IsOffLineOrder = 1;
  6040. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6041. }
  6042. }
  6043. string st = GetPostString("ToState");
  6044. if (st.Length > 0)
  6045. {
  6046. if (newentity.OrderState <= 3)
  6047. {
  6048. newentity.WaitDesignTime = DateTime.Now;
  6049. newentity.StartDesignTime = null;
  6050. newentity.FinishDesignTime = null;
  6051. newentity.OrderState = 3;
  6052. if (st == "下单员")
  6053. {
  6054. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6055. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6056. {
  6057. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6058. }
  6059. }
  6060. else
  6061. {
  6062. newentity.WaitDesignTime = DateTime.Now;
  6063. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6064. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6065. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6066. {
  6067. DataRow user = dt1.Rows[0];
  6068. //找主管
  6069. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6070. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6071. if (dt != null && dt.Rows.Count > 0)
  6072. {
  6073. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6074. newentity.DesignUserId = designMr;
  6075. string key = "aftersale_order_" + designMr;
  6076. if (RedisHelper.HasKey(key))
  6077. {
  6078. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6079. list.Add(newentity.ctid);
  6080. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6081. }
  6082. }
  6083. //账号正常
  6084. if (user["State"].ToString() == "0")
  6085. {
  6086. newentity.DesignUserId = entity.DesignUserId;
  6087. string key = "aftersale_order_" + entity.DesignUserId;
  6088. if (RedisHelper.HasKey(key))
  6089. {
  6090. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6091. list.Add(newentity.ctid);
  6092. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6093. }
  6094. }
  6095. }
  6096. }
  6097. }
  6098. if (entity.IsXianHuo == 1)
  6099. {
  6100. newentity.OrderState = 6;
  6101. entity.FinishPlaceTime = DateTime.Now;
  6102. }
  6103. }
  6104. if (ishav)
  6105. {
  6106. newentity.Update();
  6107. }
  6108. else
  6109. {
  6110. newentity.Create();
  6111. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6112. newCellExtend.ctid = newentity.ctid;
  6113. newCellExtend.orderFrom = 20;
  6114. newCellExtend.orderType = 30;
  6115. if (st == "下单员")
  6116. {
  6117. }
  6118. else
  6119. {
  6120. newCellExtend.ReprintTime = DateTime.Now;
  6121. }
  6122. newCellExtend.Create();
  6123. }
  6124. if (st != "下单员")
  6125. {
  6126. designHelper.API_GetPrintData_CreateOrder(newentity);
  6127. }
  6128. }
  6129. //处理售后扩展
  6130. string resIdStr = GetPostString("ResponsibleUserId");
  6131. string refundFees = GetPostString("refundFrees");
  6132. int IsComplain = GetPostInt("isComplain");
  6133. int IsBad = GetPostInt("isBad");
  6134. string IsOriginal = GetPostString("isOriginal");
  6135. double diffResultPrice = GetPostDouble("diffResultPrice");
  6136. string textResult = GetPostString("textResult");
  6137. string supplierResponsible = GetPostString("supplierResponsible");
  6138. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6139. if (ceErpTradeAfterSaleExtend == null)
  6140. {
  6141. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6142. ceErpTradeAfterSaleExtend.tid = eid;
  6143. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6144. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6145. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6146. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6147. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6148. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6149. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6150. ceErpTradeAfterSaleExtend.Create();
  6151. }
  6152. else
  6153. {
  6154. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6155. {
  6156. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6157. }
  6158. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6159. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6160. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6161. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6162. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6163. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6164. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6165. ceErpTradeAfterSaleExtend.Update();
  6166. }
  6167. int gysid = GetPostInt("ResponsibleSupId");
  6168. if (entity.AfterSaleUserId == 0)
  6169. {
  6170. entity.AfterSaleUserId = CurrentUser.UserID;
  6171. }
  6172. entity.ResponsibleUserId = resIdStr;
  6173. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6174. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6175. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6176. {
  6177. CeErpTradeResponsible.DelByTid(eid, -1);
  6178. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6179. int backNum = 0;
  6180. if (number != null)
  6181. {
  6182. backNum = number.BackNum;
  6183. }
  6184. char[] separator = { ',' };
  6185. string[] sArray = resIdStr.Split(separator);
  6186. string[] refundFreeList = { };
  6187. if (refundFees.Length > 0)
  6188. {
  6189. refundFreeList = refundFees.Split(separator);
  6190. }
  6191. int index = -1;
  6192. foreach (string i in sArray)
  6193. {
  6194. index++;
  6195. if (i.Length <= 0) continue;
  6196. char[] separator2 = { '_' };
  6197. string idstr = i.Split(separator2)[0];
  6198. string idtype = i.Split(separator2)[1];
  6199. double refudFree = 0;
  6200. if (refundFreeList.Length > 0)
  6201. {
  6202. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6203. }
  6204. if (idtype == "s")
  6205. {
  6206. isDesign = true;
  6207. designFree = refudFree;
  6208. }
  6209. int userId = Convert.ToInt32(idstr);
  6210. int type = 0;
  6211. if (idtype == "g")
  6212. {
  6213. type = 1;
  6214. }
  6215. if (idtype == "w")
  6216. {
  6217. type = 2;
  6218. }
  6219. if (idtype == "t")
  6220. {
  6221. type = 3;
  6222. }
  6223. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6224. if (ceErpTradeResponsible == null)
  6225. {
  6226. ceErpTradeResponsible = new CeErpTradeResponsible();
  6227. ceErpTradeResponsible.tid = eid;
  6228. ceErpTradeResponsible.UserId = userId;
  6229. ceErpTradeResponsible.createdTime = DateTime.Now;
  6230. ceErpTradeResponsible.type = type;
  6231. if (type == 1)
  6232. {
  6233. ceErpTradeResponsible.IsSup = 1;
  6234. }
  6235. if (type == 2)
  6236. {
  6237. ceErpTradeResponsible.IsFlow = 1;
  6238. }
  6239. }
  6240. ceErpTradeResponsible.RefundFee = refudFree;
  6241. ceErpTradeResponsible.VerifyState = 0;
  6242. if (userId == 2125 || idtype == "w")
  6243. {
  6244. ceErpTradeResponsible.VerifyState = 1;
  6245. }
  6246. if (idtype == "w" && userId == 101)
  6247. {
  6248. ceErpTradeResponsible.VerifyState = 0;
  6249. }
  6250. if (ceErpTradeResponsible.ID > 0)
  6251. {
  6252. ceErpTradeResponsible.Update();
  6253. }
  6254. else
  6255. {
  6256. ceErpTradeResponsible.Create();
  6257. }
  6258. if (isDesign)
  6259. {
  6260. responsibleId = ceErpTradeResponsible.ID;
  6261. }
  6262. }
  6263. CeErpTradeResponsible.NumByTid(backNum, eid);
  6264. }
  6265. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6266. if (ceErpTradeCellExtend != null)
  6267. {
  6268. ceErpTradeCellExtend.returnVisit = 0;
  6269. ceErpTradeCellExtend.Update();
  6270. }
  6271. if (entity.HandleTime != null)
  6272. {
  6273. if (entity.AfterSaleState == 1)
  6274. {
  6275. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6276. }
  6277. else
  6278. {
  6279. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6280. }
  6281. }
  6282. else
  6283. {
  6284. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6285. entity.HandleTime = DateTime.Now;
  6286. }
  6287. bool isCompale = false;
  6288. if (entity.AfterSaleState == 5)
  6289. {
  6290. isCompale = true;
  6291. entity.AfterSaleState = 3;
  6292. }
  6293. entity.AfterSaleSupplierState = 0;
  6294. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6295. {
  6296. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6297. }
  6298. string sImgs = GetPostString("img");
  6299. entity.AfterSaleSupplierImg = sImgs;
  6300. entity.supRefundType = GetPostString("supRefundType");
  6301. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6302. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6303. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6304. entity.AfterSaleMemoType = GetPostString("MemoType");
  6305. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6306. {
  6307. //entity.AfterSaleSupplierState = 2;
  6308. }
  6309. string df = GetPostString("DeductFee");
  6310. if (df == "")
  6311. {
  6312. df = "0";
  6313. }
  6314. string rf = GetPostString("RefundFee");
  6315. if (rf == "")
  6316. {
  6317. rf = "0";
  6318. }
  6319. string pm = GetPostString("AfterSalePayment");
  6320. if (pm == "")
  6321. {
  6322. pm = "0";
  6323. }
  6324. entity.AfterSalePayment = Convert.ToDouble(pm);
  6325. entity.DeductFee = Convert.ToDouble(df);
  6326. entity.RefundFee = Convert.ToDouble(rf);
  6327. entity.Update();
  6328. string toState = GetPostString("ToState");
  6329. string original = GetPostString("isOriginal");
  6330. ApiVo apiVo = new ApiVo();
  6331. apiVo.orderNumber = entity.ctid;
  6332. apiVo.actionName = "afterDesign";
  6333. apiVo.orderRemarks = entity.AfterSaleMethod;
  6334. apiVo.reasonRemarks = entity.AfterSaleReason;
  6335. apiVo.isDesign = isDesign;
  6336. apiVo.designFree = designFree;
  6337. apiVo.responsibleId = responsibleId;
  6338. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6339. if (toState == "设计师")
  6340. {
  6341. apiVo.isOriginal = Convert.ToBoolean(original);
  6342. }
  6343. designHelper.API_WorkCore(apiVo);//afterDesign
  6344. CeErpMethod methodSql = new CeErpMethod();
  6345. methodSql.con = entity.AfterSaleMethod;
  6346. methodSql.addTime = DateTime.Now;
  6347. methodSql.Create();
  6348. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6349. CeErpMethod.ExecuteNonQuery(delsql);
  6350. if (isCompale)
  6351. {
  6352. aftersale_data_change(entity.ctid);
  6353. }
  6354. returnSuccessMsg("操作成功!");
  6355. return;
  6356. }
  6357. returnErrorMsg("找不到订单记录");
  6358. }
  6359. }
  6360. public void ins_erp_toresponsible()
  6361. {
  6362. if (UrlPostParmsCheck("ctid"))
  6363. {
  6364. string eid = GetPostString("ctid");
  6365. CeErpTradeCell entity = null;
  6366. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6367. if (entity != null)
  6368. {
  6369. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6370. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6371. {
  6372. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6373. return;
  6374. }
  6375. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6376. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6377. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6378. if (entity.AfterSalePreTime == null)
  6379. {
  6380. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6381. {
  6382. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6383. }
  6384. }
  6385. entity.AfterSalePreTime = DateTime.Now;
  6386. //预完成给售后主管审核客户问题直接完成
  6387. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6388. {
  6389. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6390. {
  6391. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6392. }
  6393. }
  6394. ceErpTradeAfterSaleExtend.Update();
  6395. entity.AfterSaleState = 2;
  6396. entity.Update();
  6397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6398. aftersale_data_change(entity.ctid);
  6399. returnSuccessMsg("操作成功!");
  6400. return;
  6401. }
  6402. returnErrorMsg("找不到订单记录");
  6403. }
  6404. }
  6405. public void cancel_erp_aftersaleanddelnew()
  6406. {
  6407. if (UrlPostParmsCheck("ctid"))
  6408. {
  6409. string eid = GetPostString("ctid");
  6410. CeErpTradeCell entity = null;
  6411. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6412. if (entity != null)
  6413. {
  6414. entity.AfterSaleState = 0;
  6415. entity.AfterSaleReason = "";
  6416. entity.AfterSaleMethod = "";
  6417. entity.AfterSaleMemo = "";
  6418. entity.AfterSaleResponsible = "";
  6419. entity.ResponsibleUserId = "";
  6420. entity.DeductFee = 0;
  6421. entity.RefundFee = 0;
  6422. entity.IsArbitrate = 0;
  6423. CeErpTradeResponsible.DelByTid(eid, -1);
  6424. entity.Update();
  6425. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6426. if (after != null)
  6427. {
  6428. if (after.OrderState < 5)
  6429. CeErpTradeCell.DelByCtid("S_" + eid);
  6430. }
  6431. returnSuccessMsg("操作成功!");
  6432. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6433. return;
  6434. }
  6435. returnErrorMsg("找不到订单记录");
  6436. }
  6437. }
  6438. public void get_erp_aftersale_pregather()
  6439. {
  6440. List<string> lw = new List<string>();
  6441. int st = GetInt("st");
  6442. string tid = GetPostString("ctid");
  6443. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6444. string shopname = GetPostString("shopname");
  6445. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6446. string buyernick = GetPostString("buyer_nick");
  6447. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6448. string sellermemo = GetPostString("seller_memo");
  6449. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6450. string orderState = GetPostString("orderState");
  6451. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6452. string reason = GetPostString("reason");
  6453. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6454. string method = GetPostString("method");
  6455. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6456. string handler = GetPostString("handler");
  6457. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6458. string handledate1 = GetPostString("handledate1");
  6459. string handledate2 = GetPostString("handledate2");
  6460. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6461. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6462. string supplier = GetPostString("supplier");
  6463. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6464. string responsible = GetPostString("responsibleman");
  6465. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6466. string customer = GetPostString("customer");
  6467. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6468. string design = GetPostString("design");
  6469. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6470. string afterMemoType = GetPostString("aftermemotype");
  6471. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6472. string afterSaleMemo = GetPostString("afterSaleMemo");
  6473. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6474. string afterresult = GetPostString("afterresult");
  6475. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6476. string poscode = CurrentUser.UserPost.Post.Code;
  6477. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6478. {
  6479. string shopid = CurrentUser.User.pemShop;
  6480. lw.Add(string.Format("shopId in ({0})", shopid));
  6481. }
  6482. var mainwhere = string.Join(" and ", lw.ToArray());
  6483. string ro_json = "";
  6484. string type = GetPostString("gather_type");
  6485. if (poscode == "AfterSale")
  6486. {
  6487. //处理中
  6488. if (type == "Handling")
  6489. {
  6490. 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) : ""));
  6491. DataTable dt = null;
  6492. try
  6493. {
  6494. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6495. }
  6496. catch (Exception e)
  6497. {
  6498. dt = new DataTable();
  6499. }
  6500. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6501. return;
  6502. }
  6503. if (type == "Wait")
  6504. {
  6505. //待处理
  6506. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6507. DataTable dt1 = null;
  6508. try
  6509. {
  6510. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6511. }
  6512. catch (Exception e)
  6513. {
  6514. dt1 = new DataTable();
  6515. }
  6516. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6517. return;
  6518. }
  6519. if (type == "back")
  6520. {
  6521. //打回
  6522. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6523. DataTable dt2 = null;
  6524. try
  6525. {
  6526. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6527. }
  6528. catch (Exception e)
  6529. {
  6530. dt2 = new DataTable();
  6531. }
  6532. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6533. return;
  6534. }
  6535. if (type == "preCompletion")
  6536. {
  6537. //预完成
  6538. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6539. DataTable dt3 = null;
  6540. try
  6541. {
  6542. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6543. }
  6544. catch (Exception e)
  6545. {
  6546. dt3 = new DataTable();
  6547. }
  6548. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6549. return;
  6550. }
  6551. if (type == "documentary")
  6552. {
  6553. //跟单中
  6554. 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) : ""));
  6555. DataTable dt4 = null;
  6556. try
  6557. {
  6558. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6559. }
  6560. catch (Exception e)
  6561. {
  6562. dt4 = new DataTable();
  6563. }
  6564. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6565. return;
  6566. }
  6567. if (type == "reBack")
  6568. {
  6569. //被打回
  6570. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6571. DataTable dt1 = null;
  6572. try
  6573. {
  6574. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6575. }
  6576. catch (Exception e)
  6577. {
  6578. dt1 = new DataTable();
  6579. }
  6580. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6581. return;
  6582. }
  6583. }
  6584. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6585. {
  6586. if (type == "puBack")
  6587. {
  6588. //退回
  6589. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6590. DataTable dt = null;
  6591. try
  6592. {
  6593. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6594. }
  6595. catch (Exception e)
  6596. {
  6597. dt = new DataTable();
  6598. }
  6599. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6600. return;
  6601. }
  6602. if (type == "reBack")
  6603. {
  6604. //打回
  6605. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6606. DataTable dt1 = null;
  6607. try
  6608. {
  6609. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6610. }
  6611. catch (Exception e)
  6612. {
  6613. dt1 = new DataTable();
  6614. }
  6615. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6616. return;
  6617. }
  6618. if (type == "examEd")
  6619. {
  6620. //已审核
  6621. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6622. DataTable dt2 = null;
  6623. try
  6624. {
  6625. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6626. }
  6627. catch (Exception e)
  6628. {
  6629. dt2 = new DataTable();
  6630. }
  6631. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6632. return;
  6633. }
  6634. if (type == "waitExam")
  6635. {
  6636. //待审核
  6637. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6638. DataTable dt3 = null;
  6639. try
  6640. {
  6641. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6642. }
  6643. catch (Exception e)
  6644. {
  6645. dt3 = new DataTable();
  6646. }
  6647. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6648. return;
  6649. }
  6650. if (type == "Handling")
  6651. {
  6652. //处理中
  6653. 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) : ""));
  6654. DataTable dt4 = null;
  6655. try
  6656. {
  6657. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6658. }
  6659. catch (Exception e)
  6660. {
  6661. dt4 = new DataTable();
  6662. }
  6663. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6664. return;
  6665. }
  6666. if (type == "Wait")
  6667. {
  6668. //待处理
  6669. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6670. DataTable dt5 = null;
  6671. try
  6672. {
  6673. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6674. }
  6675. catch (Exception e)
  6676. {
  6677. dt5 = new DataTable();
  6678. }
  6679. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6680. return;
  6681. }
  6682. if (type == "documentary")
  6683. {
  6684. //跟单中
  6685. 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) : ""));
  6686. DataTable dt6 = null;
  6687. try
  6688. {
  6689. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6690. }
  6691. catch (Exception e)
  6692. {
  6693. dt6 = new DataTable();
  6694. }
  6695. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6696. return;
  6697. }
  6698. }
  6699. returnSuccess(ro_json);
  6700. }
  6701. public void end_erp_aftersale()
  6702. {
  6703. if (UrlPostParmsCheck("ctid"))
  6704. {
  6705. string eid = GetPostString("ctid");
  6706. CeErpTradeCell entity = null;
  6707. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6708. if (entity != null)
  6709. {
  6710. string stype = GetPostString("stype");
  6711. string typeStr = stype;
  6712. entity.AfterSaleState = 4;
  6713. entity.FinishAfterSaleTime = DateTime.Now;
  6714. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6715. entity.Update();
  6716. ApiVo apiVo = new ApiVo();
  6717. apiVo.orderNumber = entity.ctid;
  6718. apiVo.actionName = "afterOver";
  6719. designHelper.API_WorkCore(apiVo); //afterOver
  6720. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6721. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6722. CeErpSukuraData.createInfo(entity.ctid, 8);
  6723. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6724. returnSuccessMsg("操作成功!");
  6725. return;
  6726. }
  6727. returnErrorMsg("找不到订单记录");
  6728. }
  6729. }
  6730. public void ins_erp_finishaftersale()
  6731. {
  6732. if (UrlPostParmsCheck("id"))
  6733. {
  6734. string eid = GetPostString("id");
  6735. CeErpTradeResponsible entity = null;
  6736. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6737. if (entity != null)
  6738. {
  6739. entity.VerifyState = 1;
  6740. entity.VerifyTime = DateTime.Now;
  6741. entity.Update();
  6742. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6743. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6744. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6745. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6746. if (dt.Rows.Count <= 0)
  6747. {
  6748. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6749. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6750. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6751. CeErpSukuraData.createInfo(entity.tid, 8);
  6752. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6753. {
  6754. CeErpDesignerBill.Del(entity.tid);
  6755. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6756. }
  6757. }
  6758. returnSuccessMsg("操作成功!");
  6759. return;
  6760. }
  6761. returnErrorMsg("找不到订单记录");
  6762. }
  6763. }
  6764. public void upd_erp_arbitrateaftersale()
  6765. {
  6766. if (UrlPostParmsCheck("id"))
  6767. {
  6768. string eid = GetPostString("id");
  6769. CeErpTradeResponsible entity = null;
  6770. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6771. if (entity != null)
  6772. {
  6773. entity.IsArbitrate = 1;
  6774. entity.ArbitradeMemo = GetPostString("reason");
  6775. entity.VerifyState = 2;
  6776. entity.Update();
  6777. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6778. if (tradecell != null)
  6779. {
  6780. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6781. tradecell.IsArbitrate = 1;
  6782. tradecell.Update();
  6783. }
  6784. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6785. returnSuccessMsg("操作成功!");
  6786. return;
  6787. }
  6788. returnErrorMsg("找不到订单记录");
  6789. }
  6790. }
  6791. public void upd_erp_backaftersale()
  6792. {
  6793. if (UrlPostParmsCheck("tid"))
  6794. {
  6795. string eid = GetPostString("tid");
  6796. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6797. int backNum = 0;
  6798. if (number != null)
  6799. {
  6800. backNum = number.BackNum;
  6801. }
  6802. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6803. CeErpTradeCell entity = null;
  6804. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6805. if (entity != null)
  6806. {
  6807. entity.AfterSaleBackReason = GetPostString("backreason");
  6808. entity.AfterSaleState = 1;
  6809. entity.AfterSaleSupplierState = 0;
  6810. entity.Update();
  6811. returnSuccessMsg("操作成功!");
  6812. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6813. return;
  6814. }
  6815. returnErrorMsg("找不到订单记录");
  6816. }
  6817. }
  6818. public void get_erp_supplieraftersalelist()
  6819. {
  6820. DataStruct dStruct = GetPostStruct();
  6821. List<string> lw = new List<string>();
  6822. string tid = GetPostString("ctid");
  6823. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6824. string shopname = GetPostString("shopname");
  6825. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6826. string buyernick = GetPostString("buyer_nick");
  6827. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6828. string sellermemo = GetPostString("seller_memo");
  6829. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6830. string orderState = GetPostString("orderState");
  6831. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6832. string afterState = GetPostString("afterstate");
  6833. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6834. string date1 = GetPostString("date1");
  6835. string date2 = GetPostString("date2");
  6836. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6837. if (dw.Length > 0) lw.Add(dw);
  6838. string price1 = GetPostString("price1");
  6839. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6840. string price2 = GetPostString("price2");
  6841. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6842. string reason = GetPostString("reason");
  6843. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6844. string method = GetPostString("method");
  6845. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6846. string handledate1 = GetPostString("handledate1");
  6847. string handledate2 = GetPostString("handledate2");
  6848. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6849. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6850. string handler = GetPostString("handler");
  6851. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6852. string afterdate1 = GetPostString("afterdate1");
  6853. string afterdate2 = GetPostString("afterdate2");
  6854. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6855. if (afterDate.Length > 0) lw.Add(afterDate);
  6856. string customer = GetPostString("customer");
  6857. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6858. string design = GetPostString("design");
  6859. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6860. string afterMemoType = GetPostString("aftermemotype");
  6861. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6862. string vstate = GetPostString("vstate");
  6863. if (vstate.Length > 0)
  6864. {
  6865. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6866. }
  6867. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6868. string supplier = GetPostString("supplier");
  6869. int supid = commonHelper.getSupplierIDByName(supplier);
  6870. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6871. string posCode = CurrentUser.UserPost.Post.Code;
  6872. if (posCode == "Supplier")
  6873. {
  6874. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6875. }
  6876. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6877. {
  6878. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6879. }
  6880. else
  6881. {
  6882. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6883. }
  6884. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6885. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6886. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6887. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6888. writeGridDataTableJson(dStruct.TotalCount, dt);
  6889. }
  6890. public void upd_erp_supverifyaftersale()
  6891. {
  6892. if (UrlPostParmsCheck("id"))
  6893. {
  6894. string id = GetPostString("id");
  6895. int st = GetPostInt("afterstate");
  6896. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6897. CeErpTradeCell entity = null;
  6898. if (ceErpTradeResponsible != null)
  6899. {
  6900. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6901. }
  6902. string afmemo = GetPostString("supmemo");
  6903. string image = GetPostString("image");
  6904. if (entity != null)
  6905. {
  6906. entity.AfterSaleSupplierState = st;
  6907. entity.AfterSaleSupplierMemo = afmemo;
  6908. if (st == 1)
  6909. {
  6910. ceErpTradeResponsible.VerifyState = 1;
  6911. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6912. ceErpTradeResponsible.Update();
  6913. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6914. if (isAll)
  6915. {
  6916. entity.AfterSaleState = 4;
  6917. entity.FinishAfterSaleTime = DateTime.Now;
  6918. }
  6919. }
  6920. else
  6921. {
  6922. CeErpTradeResponsible.dateByTid(entity.ctid);
  6923. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6924. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6925. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6926. if (num <= 1)
  6927. {
  6928. entity.AfterSaleState = 1;
  6929. }
  6930. else
  6931. {
  6932. entity.AfterSaleState = 5;
  6933. }
  6934. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6935. if (ceErpTradeAfterSaleExtend != null)
  6936. {
  6937. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6938. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6939. ceErpTradeAfterSaleExtend.Update();
  6940. }
  6941. else
  6942. {
  6943. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6944. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6945. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6946. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6947. ceErpTradeAfterSaleExtend.Create();
  6948. }
  6949. }
  6950. if (entity.AfterSaleState == 4)
  6951. {
  6952. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6953. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6954. {
  6955. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6956. }
  6957. ApiVo apiVo = new ApiVo();
  6958. apiVo.orderNumber = entity.ctid;
  6959. apiVo.actionName = "afterOver";
  6960. designHelper.API_WorkCore(apiVo); //afterOver
  6961. }
  6962. entity.Update();
  6963. returnSuccessMsg("操作成功!");
  6964. CeErpSukuraData.createInfo(entity.ctid, 8);
  6965. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6966. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6967. return;
  6968. }
  6969. returnErrorMsg("找不到订单记录");
  6970. }
  6971. }
  6972. public void upd_erp_masteraftersale()
  6973. {
  6974. if (UrlPostParmsCheck("id"))
  6975. {
  6976. string id = GetPostString("id");
  6977. int st = GetPostInt("afterstate");
  6978. string afmemo = GetPostString("supmemo");
  6979. string image = GetPostString("image");
  6980. string textResult = GetPostString("textResult");
  6981. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6982. if (ceErpTradeResponsible != null)
  6983. {
  6984. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6985. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6986. ceErpTradeResponsible.Update();
  6987. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6988. if (entity != null)
  6989. {
  6990. entity.AfterSaleSupplierState = st;
  6991. entity.AfterSaleSupplierMemo = afmemo;
  6992. if (st == 1)
  6993. {
  6994. }
  6995. else
  6996. {
  6997. CeErpTradeResponsible.dateByTid(entity.ctid);
  6998. //退回到售后
  6999. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7000. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7001. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7002. if (num <= 1)
  7003. {
  7004. entity.AfterSaleState = 1;
  7005. }
  7006. else
  7007. {
  7008. entity.AfterSaleState = 5;
  7009. }
  7010. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7011. if (ceErpTradeAfterSaleExtend != null)
  7012. {
  7013. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7014. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7015. ceErpTradeAfterSaleExtend.Update();
  7016. }
  7017. else
  7018. {
  7019. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7020. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7021. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7022. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7023. ceErpTradeAfterSaleExtend.Create();
  7024. }
  7025. }
  7026. entity.Update();
  7027. returnSuccessMsg("操作成功!");
  7028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7029. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7030. return;
  7031. }
  7032. }
  7033. returnErrorMsg("找不到订单记录");
  7034. }
  7035. }
  7036. public void upd_erp_personaftersale()
  7037. {
  7038. if (UrlPostParmsCheck("id"))
  7039. {
  7040. string id = GetPostString("id");
  7041. int st = GetPostInt("afterstate");
  7042. string afmemo = GetPostString("supmemo");
  7043. string image = GetPostString("image");
  7044. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7045. if (ceErpTradeResponsible != null)
  7046. {
  7047. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7048. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7049. ceErpTradeResponsible.Update();
  7050. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7051. if (entity != null)
  7052. {
  7053. entity.AfterSaleSupplierMemo = afmemo;
  7054. entity.AfterSaleSupplierState = st;
  7055. if (st == 1)
  7056. {
  7057. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7058. if (isAll)
  7059. {
  7060. entity.AfterSaleState = 4;
  7061. entity.FinishAfterSaleTime = DateTime.Now;
  7062. }
  7063. }
  7064. else
  7065. {
  7066. CeErpTradeResponsible.dateByTid(entity.ctid);
  7067. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7068. if (ceErpTradeAfterSaleExtend != null)
  7069. {
  7070. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7071. ceErpTradeAfterSaleExtend.Update();
  7072. }
  7073. else
  7074. {
  7075. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7076. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7077. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7078. ceErpTradeAfterSaleExtend.Create();
  7079. }
  7080. //退回到主管
  7081. //entity.AfterSaleState = 2;
  7082. }
  7083. if (entity.AfterSaleState == 4)
  7084. {
  7085. ApiVo apiVo = new ApiVo();
  7086. apiVo.orderNumber = entity.ctid;
  7087. apiVo.actionName = "afterOver";
  7088. designHelper.API_WorkCore(apiVo); //afterOver
  7089. }
  7090. entity.Update();
  7091. returnSuccessMsg("操作成功!");
  7092. CeErpSukuraData.createInfo(entity.ctid, 8);
  7093. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7094. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7095. return;
  7096. }
  7097. }
  7098. returnErrorMsg("找不到订单记录");
  7099. }
  7100. }
  7101. public void set_erp_supplierrefundtag()
  7102. {
  7103. if (UrlPostParmsCheck("ctid"))
  7104. {
  7105. string eid = GetPostString("ctid");
  7106. CeErpTradeCell entity = null;
  7107. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7108. if (entity != null)
  7109. {
  7110. entity.IsSupplierRefund = GetPostInt("tag");
  7111. entity.Update();
  7112. returnSuccessMsg("操作成功!");
  7113. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7114. return;
  7115. }
  7116. returnErrorMsg("找不到订单记录");
  7117. }
  7118. }
  7119. public void get_erp_refundlist()
  7120. {
  7121. DataStruct dStruct = GetPostStruct();
  7122. List<string> lw = new List<string>();
  7123. string tid = GetPostString("tid");
  7124. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7125. //string rid = GetPostString("refund_id");
  7126. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7127. string shopname = GetPostString("shopname");
  7128. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7129. string buyernick = GetPostString("buyer_nick");
  7130. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7131. string customer = GetPostString("customer");
  7132. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7133. string design = GetPostString("design");
  7134. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7135. string sellermemo = GetPostString("seller_memo");
  7136. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7137. //string date1 = GetPostString("date1");
  7138. //string date2 = GetPostString("date2");
  7139. //string dateType = GetPostString("dateType");
  7140. //if (dateType.Length > 0)
  7141. //{
  7142. // if (dateType == "1001") dateType = "0";
  7143. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7144. // if (searchDT.Count == 2)
  7145. // {
  7146. // date1 = searchDT[0].ToString();
  7147. // date2 = searchDT[1].ToString();
  7148. // }
  7149. //}
  7150. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7151. //if (dw.Length > 0) lw.Add(dw);
  7152. string redate1 = GetPostString("refunddate1");
  7153. string redate2 = GetPostString("refunddate2");
  7154. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7155. if (dwdate.Length > 0) lw.Add(dwdate);
  7156. string price1 = GetPostString("price1");
  7157. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7158. string price2 = GetPostString("price2");
  7159. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7160. string ispartrefund = GetPostString("ispartrefund");
  7161. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7162. string refundState = GetPostString("refundvstate");
  7163. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7164. int st = GetInt("st");
  7165. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7166. {
  7167. string responsible = GetPostString("responsibleman");
  7168. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7169. lw.Add(string.Format("RefundState>={0}", st));
  7170. string code = CurrentUser.UserPost.Post.Code;
  7171. if (code == "CustomerService")
  7172. {
  7173. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7174. }
  7175. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7176. {
  7177. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7178. }
  7179. else if (code == "Place" || code == "PlaceMr")
  7180. {
  7181. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7182. }
  7183. dStruct.Order = "RefundState asc,created desc";
  7184. }
  7185. else if (st == 10)
  7186. {
  7187. string responsible = GetPostString("responsibleman");
  7188. if (responsible == "空白")
  7189. {
  7190. lw.Add(string.Format("ResponsibleUserName = ''"));
  7191. }
  7192. else if (responsible.Length > 0)
  7193. {
  7194. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7195. }
  7196. lw.Add(string.Format("RefundState>=0"));
  7197. dStruct.Order = "created desc";
  7198. }
  7199. else
  7200. {
  7201. string responsible = GetPostString("responsibleman");
  7202. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7203. lw.Add(string.Format("RefundState={0}", st));
  7204. dStruct.Order = "created desc";
  7205. }
  7206. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7207. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7208. dt.Columns.Add("refund_fees");
  7209. foreach (DataRow dr in dt.Rows)
  7210. {
  7211. String status = dr["status"].ToString();
  7212. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7213. {
  7214. dr["refund_fees"] = dr["refund_fee"];
  7215. }
  7216. else
  7217. {
  7218. dr["refund_fees"] = "0.0";
  7219. }
  7220. }
  7221. writeGridDataTableJson(dStruct.TotalCount, dt);
  7222. }
  7223. public void get_erp_refunddesignlist()
  7224. {
  7225. DataStruct dStruct = GetPostStruct();
  7226. List<string> lw = new List<string>();
  7227. string tid = GetPostString("tid");
  7228. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7229. string shopname = GetPostString("shopname");
  7230. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7231. string buyernick = GetPostString("buyer_nick");
  7232. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7233. string customer = GetPostString("customer");
  7234. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7235. string design = GetPostString("design");
  7236. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7237. string sellermemo = GetPostString("seller_memo");
  7238. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7239. string redate1 = GetPostString("refunddate1");
  7240. string redate2 = GetPostString("refunddate2");
  7241. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7242. if (dwdate.Length > 0) lw.Add(dwdate);
  7243. string price1 = GetPostString("price1");
  7244. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7245. string price2 = GetPostString("price2");
  7246. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7247. string ispartrefund = GetPostString("ispartrefund");
  7248. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7249. string designerorg = GetPostString("designerorg");
  7250. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7251. string refundState = GetPostString("refundState");
  7252. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7253. int myOrgid = CurrentUser.UserPost.OrgID;
  7254. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7255. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7256. {
  7257. if (CurrentUser.User.TeamIds.Length > 0)
  7258. {
  7259. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7260. }
  7261. else
  7262. {
  7263. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7264. }
  7265. }
  7266. else if ("SysAdmin".Equals(myOrgCode))
  7267. {
  7268. }
  7269. else
  7270. {
  7271. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7272. {
  7273. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7274. }
  7275. else
  7276. {
  7277. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7278. }
  7279. }
  7280. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7281. dStruct.Order = "created desc";
  7282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7283. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7284. dt.Columns.Add("refund_fees");
  7285. foreach (DataRow dr in dt.Rows)
  7286. {
  7287. String status = dr["status"].ToString();
  7288. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7289. {
  7290. dr["refund_fees"] = dr["refund_fee"];
  7291. }
  7292. else
  7293. {
  7294. dr["refund_fees"] = "0.0";
  7295. }
  7296. }
  7297. writeGridDataTableJson(dStruct.TotalCount, dt);
  7298. }
  7299. public void handle_erp_refundtag()
  7300. {
  7301. if (UrlPostParmsCheck("refund_id"))
  7302. {
  7303. string eid = GetPostString("refund_id");
  7304. string respMan = GetPostString("ResponsibleName");
  7305. if (respMan.Length <= 0)
  7306. {
  7307. returnErrorMsg("责任人不能为空");
  7308. return;
  7309. }
  7310. CeErpTradeRefund entity = null;
  7311. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7312. if (entity != null)
  7313. {
  7314. entity.ResponsibleUserName = respMan;
  7315. string userid = GetPostString("ResponsibleUserId");
  7316. if (userid.Length > 0)
  7317. {
  7318. entity.ResponsibleUserId = userid;
  7319. }
  7320. entity.Memo = GetPostString("Memo");
  7321. if (respMan.IndexOf("客服") != -1 ||
  7322. respMan.IndexOf("设计师") != -1 ||
  7323. respMan.IndexOf("下单员") != -1)
  7324. {
  7325. entity.RefundState = 2;
  7326. }
  7327. else
  7328. {
  7329. entity.RefundState = 3;
  7330. }
  7331. entity.modified = DateTime.Now;
  7332. entity.Update();
  7333. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7334. returnSuccessMsg("操作成功!");
  7335. return;
  7336. }
  7337. returnErrorMsg("找不到订单记录");
  7338. }
  7339. }
  7340. public void handle_erp_designrefundtag()
  7341. {
  7342. if (UrlPostParmsCheck("refund_id"))
  7343. {
  7344. string eid = GetPostString("refund_id");
  7345. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7346. if (ceErpTradeCellExtend == null)
  7347. {
  7348. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7349. ceErpTradeCellExtend.ctid = eid;
  7350. }
  7351. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7352. if (ceErpTradeCellExtend.ID > 0)
  7353. {
  7354. ceErpTradeCellExtend.Update();
  7355. }
  7356. else
  7357. {
  7358. ceErpTradeCellExtend.Create();
  7359. }
  7360. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7361. returnSuccessMsg("操作成功!");
  7362. return;
  7363. }
  7364. returnErrorMsg("找不到订单记录");
  7365. }
  7366. public void upd_erp_refundverify()
  7367. {
  7368. if (UrlPostParmsCheck("refund_id"))
  7369. {
  7370. string eid = GetPostString("refund_id");
  7371. CeErpTradeRefund entity = null;
  7372. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7373. if (entity != null)
  7374. {
  7375. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7376. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7377. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7378. {
  7379. entity.RefundState = 2;
  7380. }
  7381. else
  7382. {
  7383. entity.RefundState = 3;
  7384. }
  7385. entity.Update();
  7386. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7387. returnSuccessMsg("操作成功!");
  7388. return;
  7389. }
  7390. returnErrorMsg("找不到订单记录");
  7391. }
  7392. }
  7393. public void upd_erp_refundapprove()
  7394. {
  7395. if (UrlPostParmsCheck("refund_id"))
  7396. {
  7397. string eid = GetPostString("refund_id");
  7398. CeErpTradeRefund entity = null;
  7399. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7400. if (entity != null)
  7401. {
  7402. int apr = GetPostInt("approve");
  7403. if (apr == 0)
  7404. {
  7405. entity.RefundState = 1;
  7406. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7407. }
  7408. else if (apr == 1)
  7409. {
  7410. entity.RefundState = 3;
  7411. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7412. }
  7413. entity.modified = DateTime.Now;
  7414. entity.Update();
  7415. returnSuccessMsg("操作成功!");
  7416. return;
  7417. }
  7418. returnErrorMsg("找不到订单记录");
  7419. }
  7420. }
  7421. public void get_erp_billlist()
  7422. {
  7423. DataStruct dStruct = GetPostStruct();
  7424. List<string> lw = new List<string>();
  7425. string title = GetPostString("title");
  7426. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7427. string tid = GetPostString("tid");
  7428. string tids = GetPostString("tids");
  7429. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7430. if (tids.Length > 0)
  7431. {
  7432. tids = "'" + tids + "'";
  7433. tids = tids.Replace(",", "','");
  7434. lw.Add(string.Format("tid in ({0})", tids));
  7435. }
  7436. string shopname = GetPostString("shopname");
  7437. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7438. string buyernick = GetPostString("buyer_nick");
  7439. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7440. string customer = GetPostString("customer");
  7441. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7442. string date1 = GetPostString("date1");
  7443. string date2 = GetPostString("date2");
  7444. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7445. if (dw.Length > 0) lw.Add(dw);
  7446. string price1 = GetPostString("price1");
  7447. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7448. string price2 = GetPostString("price2");
  7449. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7450. string returndate1 = GetPostString("returndate1");
  7451. string returndate2 = GetPostString("returndate2");
  7452. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7453. if (dw1.Length > 0) lw.Add(dw1);
  7454. string billtype = GetPostString("billtype");
  7455. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7456. string billstate = GetPostString("billstate");
  7457. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7458. string usershop = CurrentUser.User.pemShop;
  7459. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7460. dStruct.Order = "createTime desc";
  7461. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7462. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7463. //foreach (DataRow dr in dt.Rows)
  7464. //{
  7465. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7466. //}
  7467. writeGridDataTableJson(dStruct.TotalCount, dt);
  7468. }
  7469. public void modify_erp_billinfo()
  7470. {
  7471. if (UrlPostParmsCheck("ID"))
  7472. {
  7473. string eid = GetPostString("ID");
  7474. CeErpBill bill_entity = null;
  7475. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7476. if (bill_entity != null)
  7477. {
  7478. bill_entity.tid = GetPostString("tid");
  7479. bill_entity.title = GetPostString("title");
  7480. bill_entity.tax = GetPostString("tax");
  7481. bill_entity.bank = GetPostString("bank");
  7482. bill_entity.bankac = GetPostString("bankac");
  7483. bill_entity.address = GetPostString("address");
  7484. bill_entity.phone = GetPostString("phone");
  7485. bill_entity.price = GetPostString("price");
  7486. bill_entity.productId = GetPostInt("ProductName");
  7487. bill_entity.num = GetPostInt("num");
  7488. bill_entity.unit = GetPostString("unit");
  7489. bill_entity.type = GetPostString("type");
  7490. bill_entity.sendType = GetPostString("SendType");
  7491. bill_entity.email = GetPostString("email");
  7492. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7493. bill_entity.shopName = GetPostString("ShopName");
  7494. bill_entity.applymemo = GetPostString("applymemo");
  7495. bill_entity.modifyTime = DateTime.Now;
  7496. bill_entity.createTime = DateTime.Now;
  7497. bill_entity.state = 0;
  7498. bill_entity.Update();
  7499. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7500. returnSuccessMsg("发票修改成功!");
  7501. return;
  7502. }
  7503. returnErrorMsg("找不到对应记录");
  7504. }
  7505. }
  7506. public void set_erp_invoicing()
  7507. {
  7508. if (UrlPostParmsCheck("id"))
  7509. {
  7510. try
  7511. {
  7512. string eid = GetPostString("id");
  7513. CeErpBill bill_entity = null;
  7514. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7515. if (bill_entity != null)
  7516. {
  7517. int ComId = GetPostInt("ComId");
  7518. //string memo = GetPostString("Memo");
  7519. int allInfo = GetPostInt("allinfo");
  7520. string clert = CurrentUser.User.Name;
  7521. //string detailValue = GetPostString("detailvalue");
  7522. string billId = bill_entity.billOrderId;
  7523. string[] billIdList = billId.Split(',');
  7524. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7525. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7526. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7527. {
  7528. billCount += 1;
  7529. }
  7530. if (billId.Length <= 0 || billIdList.Length != billCount)
  7531. {
  7532. bill_entity.billOrderId = "";
  7533. string prebill = "ltb";
  7534. for (int idx = 1; idx <= billCount; idx++)
  7535. {
  7536. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7537. string billoid = prebill + idx + dtstr;
  7538. bill_entity.billOrderId += billoid;
  7539. if (idx < billCount)
  7540. {
  7541. bill_entity.billOrderId += ",";
  7542. }
  7543. }
  7544. }
  7545. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7546. if (bill_entity.state == 5)
  7547. {
  7548. string errMsg = bill_entity.failerror;
  7549. string[] errlist = errMsg.Split('|');
  7550. string[] errTags = new string[errlist.Length];
  7551. for (int itag = 0; itag < errlist.Length; itag++)
  7552. {
  7553. if (errlist[itag].Length <= 0) continue;
  7554. errTags[itag] = errlist[itag].Split('&')[0];
  7555. }
  7556. for (int iii = 0; iii < errTags.Length; iii++)
  7557. {
  7558. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7559. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7560. if (billOrderList.Length >= erroBillOrderTag)
  7561. {
  7562. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7563. if (needModifyBillId.Length <= 19)
  7564. {
  7565. needModifyBillId = needModifyBillId + "1";
  7566. }
  7567. else
  7568. {
  7569. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7570. last = last + 1;
  7571. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7572. }
  7573. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7574. }
  7575. }
  7576. }
  7577. bool isHaveBillSucces = false;
  7578. string totalRes = "";
  7579. bill_entity.failerror = "";
  7580. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7581. {
  7582. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7583. totalRes += res;
  7584. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7585. {
  7586. isHaveBillSucces = true;
  7587. bill_entity.comId = ComId;
  7588. bill_entity.state = 1;
  7589. bill_entity.executeTime = DateTime.Now;
  7590. bill_entity.executeUser = clert;
  7591. }
  7592. else
  7593. {
  7594. bill_entity.state = 5;
  7595. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7596. }
  7597. }
  7598. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7599. bill_entity.Update();
  7600. if (isHaveBillSucces)
  7601. {
  7602. StringBuilder sql = new StringBuilder();
  7603. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7604. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7605. }
  7606. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7607. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7608. {
  7609. returnErrorMsg("开票失败");
  7610. }
  7611. else
  7612. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7613. return;
  7614. }
  7615. returnErrorMsg("找不到对应记录");
  7616. }
  7617. catch (Exception ex)
  7618. {
  7619. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7620. returnErrorMsg("操作失败");
  7621. }
  7622. }
  7623. }
  7624. public void get_erp_invoicing_back()
  7625. {
  7626. if (UrlPostParmsCheck("id"))
  7627. {
  7628. try
  7629. {
  7630. string id = GetPostString("id");
  7631. CeErpBill entiy = CeErpBill.Get(id);
  7632. if (entiy != null)
  7633. {
  7634. if (entiy.state == 0)
  7635. {
  7636. returnErrorMsg("发票还未开具");
  7637. return;
  7638. }
  7639. string[] billOrderList = entiy.billOrderId.Split(',');
  7640. int iTag = 0;
  7641. entiy.fplsh = "";
  7642. entiy.fpdm = "";
  7643. entiy.fphm = "";
  7644. foreach (string billOrderId in billOrderList)
  7645. {
  7646. iTag++;
  7647. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7648. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7649. {
  7650. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7651. try
  7652. {
  7653. Invoicing_get_response_Obj iObj = null;
  7654. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7655. if (iObj != null)
  7656. {
  7657. entiy.state = 2;
  7658. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7659. entiy.fpdm += iObj.list[0].c_fpdm;
  7660. entiy.fphm += iObj.list[0].c_fphm;
  7661. if (iTag < billOrderList.Length)
  7662. {
  7663. entiy.fplsh += ",";
  7664. entiy.fpdm += ",";
  7665. entiy.fphm += ",";
  7666. }
  7667. entiy.Update();
  7668. }
  7669. StringBuilder sql = new StringBuilder();
  7670. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7671. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7672. returnSuccessMsg("开票成功");
  7673. }
  7674. catch (Exception ex)
  7675. {
  7676. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7677. }
  7678. return;
  7679. }
  7680. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7681. {
  7682. var res_obj = new
  7683. {
  7684. data = "开票中"
  7685. };
  7686. string ro_json = JsonConvert.SerializeObject(res_obj);
  7687. returnSuccess(ro_json);
  7688. return;
  7689. }
  7690. else
  7691. {
  7692. int eidx = res.IndexOf("c_resultmsg");
  7693. int lidx = res.IndexOf("c_status");
  7694. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7695. entiy.state = 5;
  7696. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7697. entiy.Update();
  7698. returnErrorMsg("开票失败");
  7699. return;
  7700. }
  7701. }
  7702. }
  7703. }
  7704. catch (Exception ex)
  7705. {
  7706. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7707. }
  7708. return;
  7709. }
  7710. }
  7711. public void get_erp_invoicing()
  7712. {
  7713. if (UrlPostParmsCheck("id"))
  7714. {
  7715. try
  7716. {
  7717. string id = GetPostString("id");
  7718. CeErpBill entiy = CeErpBill.Get(id);
  7719. if (entiy != null)
  7720. {
  7721. if (entiy.state == 0)
  7722. {
  7723. returnErrorMsg("发票还未开具");
  7724. return;
  7725. }
  7726. if (entiy.sendType == "纸质发票")
  7727. {
  7728. if (entiy.img.Length <= 0)
  7729. {
  7730. returnErrorMsg("查无纸质发票");
  7731. return;
  7732. }
  7733. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7734. returnSuccess(returnres);
  7735. return;
  7736. }
  7737. string[] billOrderList = entiy.billOrderId.Split(',');
  7738. int iTag = 0;
  7739. string fpUrl = "";
  7740. entiy.fplsh = "";
  7741. entiy.fpdm = "";
  7742. entiy.fphm = "";
  7743. foreach (string billOrderId in billOrderList)
  7744. {
  7745. iTag++;
  7746. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7747. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7748. {
  7749. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7750. Invoicing_get_response_Obj iObj = null;
  7751. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7752. if (iObj != null)
  7753. {
  7754. //entiy.state = 2;
  7755. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7756. entiy.fpdm += iObj.list[0].c_fpdm;
  7757. entiy.fphm += iObj.list[0].c_fphm;
  7758. if (iTag < billOrderList.Length)
  7759. {
  7760. entiy.fplsh += ",";
  7761. entiy.fpdm += ",";
  7762. entiy.fphm += ",";
  7763. }
  7764. entiy.Update();
  7765. fpUrl += iObj.list[0].c_url + ",";
  7766. }
  7767. //returnSuccess(res);
  7768. StringBuilder sql = new StringBuilder();
  7769. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7770. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7771. }
  7772. else
  7773. {
  7774. int eidx = res.IndexOf("c_resultmsg");
  7775. //int lidx = res.IndexOf("c_status");
  7776. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7777. //开票失败
  7778. entiy.state = 5;
  7779. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7780. entiy.Update();
  7781. returnErrorMsg("开票失败");
  7782. return;
  7783. }
  7784. }
  7785. var returnObj = new
  7786. {
  7787. data = fpUrl
  7788. };
  7789. string ro_json = JsonConvert.SerializeObject(returnObj);
  7790. returnSuccess(ro_json);
  7791. }
  7792. }
  7793. catch (Exception ex)
  7794. {
  7795. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7796. }
  7797. return;
  7798. }
  7799. }
  7800. public void save_erp_billimg()
  7801. {
  7802. if (UrlPostParmsCheck("id"))
  7803. {
  7804. string eid = GetPostString("id");
  7805. CeErpBill bill_entity = null;
  7806. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7807. if (bill_entity != null)
  7808. {
  7809. bill_entity.img = GetPostString("img");
  7810. bill_entity.executeTime = DateTime.Now;
  7811. bill_entity.state = 2;
  7812. bill_entity.Update();
  7813. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7814. returnSuccessMsg("保存成功");
  7815. }
  7816. return;
  7817. }
  7818. }
  7819. public void upd_erp_billreturnback()
  7820. {
  7821. if (UrlPostParmsCheck("id"))
  7822. {
  7823. int eid = GetPostInt("id");
  7824. CeErpBill bill_entity = null;
  7825. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7826. if (bill_entity != null)
  7827. {
  7828. bill_entity.state = 3;
  7829. bill_entity.returnReason = GetPostString("reason");
  7830. bill_entity.Update();
  7831. returnSuccessMsg("驳回成功!");
  7832. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7833. }
  7834. return;
  7835. }
  7836. }
  7837. public void cancel_erp_bill()
  7838. {
  7839. if (UrlPostParmsCheck("id"))
  7840. {
  7841. int eid = GetPostInt("id");
  7842. int detailValue = GetPostInt("detailvalue");
  7843. CeErpBill bill_entity = null;
  7844. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7845. string cres = "";
  7846. string gres = "";
  7847. if (bill_entity != null)
  7848. {
  7849. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7850. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7851. {
  7852. int iTag = 0;
  7853. bill_entity.fplsh = "";
  7854. bill_entity.fpdm = "";
  7855. bill_entity.fphm = "";
  7856. foreach (string billOrderId in billOrderList)
  7857. {
  7858. iTag++;
  7859. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7860. if (gres.IndexOf("success") != -1)
  7861. {
  7862. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7863. Invoicing_get_response_Obj iObj = null;
  7864. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7865. if (iObj != null)
  7866. {
  7867. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7868. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7869. bill_entity.fphm += iObj.list[0].c_fphm;
  7870. if (iTag < billOrderList.Length)
  7871. {
  7872. bill_entity.fplsh += ",";
  7873. bill_entity.fpdm += ",";
  7874. bill_entity.fphm += ",";
  7875. }
  7876. bill_entity.Update();
  7877. }
  7878. }
  7879. else
  7880. {
  7881. returnErrorMsg(gres);
  7882. return;
  7883. }
  7884. }
  7885. }
  7886. if (bill_entity.sendType == "纸质发票")
  7887. {
  7888. //作废
  7889. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7890. //if (DateTime.Now.Month == extime.Month)
  7891. //{
  7892. //cres = taobaoHelper.cancel_invoicing(eid);
  7893. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7894. //{
  7895. bill_entity.state = 4;//已作废
  7896. bill_entity.Update();
  7897. returnSuccessMsg("发票已作废");
  7898. return;
  7899. //}
  7900. //else
  7901. //{
  7902. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7903. // bill_entity.Update();
  7904. // returnErrorMsg(cres);
  7905. // return;
  7906. //}
  7907. //}
  7908. //else
  7909. //{
  7910. // returnErrorMsg("纸质发票只能作废本月的发票");
  7911. // return;
  7912. //}
  7913. }
  7914. //红冲
  7915. int redTag = 0;
  7916. string[] fpdmList = bill_entity.fpdm.Split(',');
  7917. string[] fphmList = bill_entity.fphm.Split(',');
  7918. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7919. {
  7920. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7921. return;
  7922. }
  7923. foreach (string billOrderId in billOrderList)
  7924. {
  7925. redTag++;
  7926. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7927. cres += onecres;
  7928. cres += ",";
  7929. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7930. {
  7931. bill_entity.state = 4;//已作废
  7932. //bill_entity.Update();
  7933. //returnSuccessMsg("发票已红冲");
  7934. }
  7935. else if (onecres.IndexOf("重复冲红") != -1)
  7936. {
  7937. bill_entity.state = 4;//已作废
  7938. //bill_entity.Update();
  7939. //returnSuccessMsg("发票已红冲");
  7940. }
  7941. else
  7942. {
  7943. string errmsg = commonHelper.KeepChinese(onecres);
  7944. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7945. }
  7946. }
  7947. bill_entity.Update();
  7948. if (cres.IndexOf("失败") != -1)
  7949. returnErrorMsg("红冲失败");
  7950. else
  7951. returnSuccessMsg("发票已红冲");
  7952. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7953. return;
  7954. }
  7955. return;
  7956. }
  7957. }
  7958. public void del_erp_billorder()
  7959. {
  7960. if (UrlPostParmsCheck("id"))
  7961. {
  7962. string eid = GetPostString("id");
  7963. CeErpBill.Del(eid);
  7964. CeErpBill bill = CeErpBill.Get(eid);
  7965. if (bill != null)
  7966. {
  7967. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7968. }
  7969. returnSuccessMsg("删除成功");
  7970. }
  7971. }
  7972. public void finish_erp_bill()
  7973. {
  7974. if (UrlPostParmsCheck("ids"))
  7975. {
  7976. string eids = GetPostString("ids");
  7977. string[] list = eids.Split(',');
  7978. foreach (string eid in list)
  7979. {
  7980. CeErpBill bill = CeErpBill.Get(eid);
  7981. if (bill != null)
  7982. {
  7983. bill.state = 2;
  7984. bill.Update();
  7985. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7986. }
  7987. }
  7988. returnSuccessMsg("操作成功");
  7989. }
  7990. }
  7991. public void get_erp_returncash()
  7992. {
  7993. DataStruct dStruct = GetPostStruct();
  7994. List<string> lw = new List<string>();
  7995. string tid = GetPostString("tid");
  7996. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7997. string shopname = GetPostString("shopname");
  7998. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7999. string buyernick = GetPostString("buyer_nick");
  8000. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8001. string customer = GetPostString("customer");
  8002. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8003. string returndate1 = GetPostString("returndate1");
  8004. string returndate2 = GetPostString("returndate2");
  8005. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8006. if (dw.Length > 0) lw.Add(dw);
  8007. string finishDate1 = GetPostString("finishdate1");
  8008. string finishDate2 = GetPostString("finishdate2");
  8009. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8010. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8011. string returntype = GetPostString("returntype");
  8012. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8013. string returnvstate = GetPostString("returnvstate");
  8014. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8015. dStruct.Order = "created desc";
  8016. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8017. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8018. writeGridDataTableJson(dStruct.TotalCount, dt);
  8019. }
  8020. public void get_erp_staygoods()
  8021. {
  8022. DataStruct dStruct = GetPostStruct();
  8023. List<string> lw = new List<string>();
  8024. string tid = GetPostString("tid");
  8025. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8026. string shopname = GetPostString("shopname");
  8027. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8028. string wangwang = GetPostString("wangwang");
  8029. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8030. string customer = GetPostString("customer");
  8031. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8032. string returndate1 = GetPostString("returndate1");
  8033. string returndate2 = GetPostString("returndate2");
  8034. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8035. if (dw.Length > 0) lw.Add(dw);
  8036. string finishDate1 = GetPostString("finishdate1");
  8037. string finishDate2 = GetPostString("finishdate2");
  8038. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8039. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8040. string returnvstate = GetPostString("returnvstate");
  8041. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8042. string persuadetype = GetPostString("persuadetype");
  8043. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8044. string customerOrg = GetPostString("customerOrg");
  8045. if (customerOrg.Length > 0)
  8046. {
  8047. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8048. }
  8049. dStruct.Order = "creata_time desc";
  8050. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8051. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8052. writeGridDataTableJson(dStruct.TotalCount, dt);
  8053. }
  8054. public void upd_erp_staygoods()
  8055. {
  8056. if (UrlPostParmsCheck("id"))
  8057. {
  8058. int eid = GetPostInt("id");
  8059. CeErpStayGoods entity = null;
  8060. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8061. if (entity != null)
  8062. {
  8063. entity.audit_type = 1;
  8064. entity.audit_time = DateTime.Now;
  8065. entity.audit_u_id = CurrentUser.UserID;
  8066. entity.audit_u_name = CurrentUser.UserName;
  8067. entity.Update();
  8068. returnSuccessMsg("审核成功!");
  8069. return;
  8070. }
  8071. returnErrorMsg("找不到订单记录");
  8072. }
  8073. }
  8074. public void upd_erp_stayGoodsback()
  8075. {
  8076. if (UrlPostParmsCheck("id"))
  8077. {
  8078. int eid = GetPostInt("id");
  8079. CeErpStayGoods entity = null;
  8080. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8081. if (entity != null)
  8082. {
  8083. entity.audit_text = GetPostString("reason");
  8084. entity.audit_type = 2;
  8085. entity.audit_time = DateTime.Now;
  8086. entity.audit_u_id = CurrentUser.UserID;
  8087. entity.audit_u_name = CurrentUser.UserName;
  8088. entity.Update();
  8089. returnSuccessMsg("退回成功!");
  8090. return;
  8091. }
  8092. returnErrorMsg("找不到订单记录");
  8093. }
  8094. }
  8095. public void upd_erp_returncashverify()
  8096. {
  8097. if (UrlPostParmsCheck("ID"))
  8098. {
  8099. int eid = GetPostInt("ID");
  8100. CeErpReturnCash entity = null;
  8101. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8102. if (entity != null)
  8103. {
  8104. entity.cashstate = 1;
  8105. entity.verifytime = DateTime.Now;
  8106. entity.verifyuserid = CurrentUser.UserID;
  8107. entity.Update();
  8108. returnSuccessMsg("审核成功!");
  8109. return;
  8110. }
  8111. returnErrorMsg("找不到订单记录");
  8112. }
  8113. }
  8114. public void upd_all_erp_returncashverify()
  8115. {
  8116. if (UrlPostParmsCheck("ID"))
  8117. {
  8118. String[] list = GetPostString("ID").Split(',');
  8119. CeErpReturnCash entity = null;
  8120. for (int i = 0; i < list.Length; i++)
  8121. {
  8122. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8123. if (entity != null)
  8124. {
  8125. if (entity.cashstate == 1)
  8126. {
  8127. returnErrorMsg("已审核过的订单不需要在审核!");
  8128. return;
  8129. }
  8130. entity.cashstate = 1;
  8131. entity.verifytime = DateTime.Now;
  8132. entity.verifyuserid = CurrentUser.UserID;
  8133. entity.Update();
  8134. }
  8135. }
  8136. returnSuccessMsg("审核成功!");
  8137. return;
  8138. }
  8139. }
  8140. public void upd_erp_returncashback()
  8141. {
  8142. if (UrlPostParmsCheck("ID"))
  8143. {
  8144. int eid = GetPostInt("ID");
  8145. CeErpReturnCash entity = null;
  8146. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8147. if (entity != null)
  8148. {
  8149. entity.backreason = GetPostString("reason");
  8150. entity.cashstate = 2;
  8151. entity.verifytime = DateTime.Now;
  8152. entity.verifyuserid = CurrentUser.UserID;
  8153. entity.Update();
  8154. returnSuccessMsg("退回成功!");
  8155. return;
  8156. }
  8157. returnErrorMsg("找不到订单记录");
  8158. }
  8159. }
  8160. public void upd_erp_returnprice()
  8161. {
  8162. if (UrlPostParmsCheck("ID"))
  8163. {
  8164. int eid = GetPostInt("ID");
  8165. CeErpReturnCash entity = null;
  8166. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8167. if (entity != null)
  8168. {
  8169. if (entity.cashstate == 1)
  8170. {
  8171. returnErrorMsg("审核通过了不能改");
  8172. return;
  8173. }
  8174. entity.returnprice = GetPostDouble("returnprice");
  8175. entity.Update();
  8176. returnSuccessMsg("修改成功!");
  8177. return;
  8178. }
  8179. returnErrorMsg("找不到订单记录");
  8180. }
  8181. }
  8182. public void del_erp_returncash()
  8183. {
  8184. if (UrlPostParmsCheck("ID"))
  8185. {
  8186. int eid = GetPostInt("ID");
  8187. CeErpReturnCash.Del(eid);
  8188. returnSuccessMsg("操作成功");
  8189. return;
  8190. }
  8191. }
  8192. public void test_for_do_sql()
  8193. {
  8194. string sql = GetPostString("sqlstr");
  8195. if (sql.Length > 0)
  8196. {
  8197. try
  8198. {
  8199. DbHelper.DbConn.ExecuteNonQuery(sql);
  8200. var res_obj = new
  8201. {
  8202. data = "成功",
  8203. };
  8204. string ro_json = JsonConvert.SerializeObject(res_obj);
  8205. returnSuccess(ro_json);
  8206. }
  8207. catch (Exception ex)
  8208. {
  8209. var res_obj = new
  8210. {
  8211. data = ex.Message,
  8212. };
  8213. string ro_json = JsonConvert.SerializeObject(res_obj);
  8214. returnSuccess(ro_json);
  8215. }
  8216. }
  8217. }
  8218. public void get_user_info()
  8219. {
  8220. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8221. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8222. }
  8223. public void get_total_data()
  8224. {
  8225. int userId = CurrentUser.UserID;
  8226. string sql = "";
  8227. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8228. {
  8229. 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);
  8230. }
  8231. else
  8232. {
  8233. 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 " +
  8234. "(select ID from CE_ErpUser where ID = {0}) d " +
  8235. "left join " +
  8236. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8237. ") a on d.ID = a.id left join " +
  8238. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8239. ") b on a.id = b.id1 left join" +
  8240. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8241. ") c on a.id = c.id2;", userId);
  8242. }
  8243. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8244. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8245. }
  8246. public void get_date_area_total_data2()
  8247. {
  8248. int userId = CurrentUser.UserID;
  8249. string date_type = GetPostString("timetype");
  8250. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8251. string sql = "";
  8252. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8253. {
  8254. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8255. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8256. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8257. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8258. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8259. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8260. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8261. ") a on e.ID = a.id left join " +
  8262. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8263. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8264. ") b on a.id = b.id1 " +
  8265. "left join " +
  8266. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8267. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8268. ") c on a.id = c.id2 " +
  8269. "left join " +
  8270. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8271. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8272. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8273. }
  8274. else
  8275. {
  8276. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8277. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8278. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8279. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8280. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8281. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8282. ") a on e.ID = a.id left join " +
  8283. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8284. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8285. ") c on a.id = c.id2 " +
  8286. "left join " +
  8287. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8288. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8289. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8290. }
  8291. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8292. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8293. }
  8294. public void get_date_area_total_data()
  8295. {
  8296. int userId = CurrentUser.UserID;
  8297. string date_type = GetPostString("timetype");
  8298. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8299. string date1 = searchDT[0].ToString();
  8300. string date2 = searchDT[1].ToString();
  8301. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8302. {
  8303. SqlParameter[] sqlParameter ={
  8304. new SqlParameter("@userId", SqlDbType.Int,4),
  8305. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8306. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8307. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8308. };
  8309. sqlParameter[0].Value = userId;
  8310. sqlParameter[1].Value = date1;
  8311. sqlParameter[2].Value = date2;
  8312. sqlParameter[3].Direction = ParameterDirection.Output;
  8313. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8314. string res = sqlParameter[3].Value.ToString();
  8315. var res_obj = new
  8316. {
  8317. data = res
  8318. };
  8319. string ro_json = JsonConvert.SerializeObject(res_obj);
  8320. returnSuccess(ro_json);
  8321. }
  8322. else
  8323. {
  8324. SqlParameter[] sqlParameter ={
  8325. new SqlParameter("@userId", SqlDbType.Int,4),
  8326. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8327. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8328. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8329. };
  8330. sqlParameter[0].Value = userId;
  8331. sqlParameter[1].Value = date1;
  8332. sqlParameter[2].Value = date2;
  8333. sqlParameter[3].Direction = ParameterDirection.Output;
  8334. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8335. string res = sqlParameter[3].Value.ToString();
  8336. var res_obj = new
  8337. {
  8338. data = res
  8339. };
  8340. string ro_json = JsonConvert.SerializeObject(res_obj);
  8341. returnSuccess(ro_json);
  8342. }
  8343. //writeGridDataViewJson(dt.Rows.Count, dv);
  8344. }
  8345. public void get_order_list()
  8346. {
  8347. string strFields = GetPostString("paraFields");
  8348. string strOrder = GetPostString("paraOrder");
  8349. string strWhere = GetPostString("paraWhere");
  8350. string strPageSize = GetPostString("paraPageSize");
  8351. DataStruct dStruct = GetPostStruct();
  8352. dStruct.PageSize = int.Parse(strPageSize);
  8353. dStruct.Fileds = strFields;
  8354. dStruct.Order = strOrder;
  8355. dStruct.MainWhere = strWhere;
  8356. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8357. writeGridDataTableJson(dStruct.TotalCount, dt);
  8358. }
  8359. ////获取待开始订单列表
  8360. //public void get_wait_design_order_list()
  8361. //{
  8362. // string date_type = GetPostString("date_type");
  8363. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8364. // DataStruct dStruct = GetPostStruct();
  8365. // dStruct.PageSize = 1000;
  8366. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8367. // List<string> lw = new List<string>();
  8368. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8369. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8370. // dStruct.Order = "WaitDesignTime asc";
  8371. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8372. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8373. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8374. //}
  8375. //获取完成单量排名
  8376. public void get_finish_order_count_ranking()
  8377. {
  8378. /* string date_type = GetPostString("date_type");
  8379. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8380. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8381. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8382. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8383. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8384. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8385. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8386. writeGridDataTableJson(0, new DataTable());
  8387. }
  8388. public void get_finish_order_amount_ranking()
  8389. {
  8390. /*string date_type = GetPostString("date_type");
  8391. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8392. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8393. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8394. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8395. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8396. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8397. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8398. writeGridDataTableJson(0, new DataTable());
  8399. }
  8400. public void get_finish_refund_count_ranking()
  8401. {
  8402. string date_type = GetPostString("date_type");
  8403. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8404. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8405. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8406. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8407. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8408. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8409. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8410. writeGridDataTableJson(dt.Rows.Count, dt);
  8411. }
  8412. public void get_finish_refund_amount_ranking()
  8413. {
  8414. string date_type = GetPostString("date_type");
  8415. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8416. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8417. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8418. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8419. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8420. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8421. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8422. writeGridDataTableJson(dt.Rows.Count, dt);
  8423. }
  8424. public void set_erp_finishorder_director()
  8425. {
  8426. if (UrlPostParmsCheck("ctid"))
  8427. {
  8428. string eid = GetPostString("ctid");
  8429. CeErpTradeCell entity = null;
  8430. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8431. if (entity != null)
  8432. {
  8433. entity.OrderState = 8;
  8434. entity.Update();
  8435. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8436. returnSuccessMsg("操作成功!");
  8437. return;
  8438. }
  8439. returnErrorMsg("找不到记录");
  8440. }
  8441. }
  8442. public void get_erp_placeregistlist()
  8443. {
  8444. DataStruct dStruct = GetPostStruct();
  8445. List<string> lw = new List<string>();
  8446. string outsid = GetPostString("outsid");
  8447. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8448. string memo = GetPostString("memo");
  8449. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8450. string filename = GetPostString("filename");
  8451. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8452. string islate = GetPostString("islate");
  8453. if (islate.Length > 0)
  8454. {
  8455. if (islate == "1")
  8456. lw.Add(string.Format("OutLate>0"));
  8457. else
  8458. lw.Add(string.Format("OutLate=0"));
  8459. }
  8460. string placedate1 = GetPostString("placedate1");
  8461. string placedate2 = GetPostString("placedate2");
  8462. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8463. if (dw.Length > 0) lw.Add(dw);
  8464. string deliveryDate1 = GetPostString("deliverydate1");
  8465. string deliveryDate2 = GetPostString("deliverydate2");
  8466. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8467. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8468. dStruct.Order = "ID desc";
  8469. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8470. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8471. writeGridDataTableJson(dStruct.TotalCount, dt);
  8472. }
  8473. public void ins_erp_placeregist()
  8474. {
  8475. if (UrlPostParmsCheck("id"))
  8476. {
  8477. string eid = GetPostString("id");
  8478. CeErpPlaceRegister entity = null;
  8479. if (eid == "0")//新增
  8480. {
  8481. entity = new CeErpPlaceRegister();
  8482. string xdTime = GetPostString("placeTime");
  8483. if (xdTime.Length > 0)
  8484. {
  8485. entity.PlactTime = Convert.ToDateTime(xdTime);
  8486. }
  8487. string fhTime = GetPostString("deliveryTime");
  8488. if (fhTime.Length > 0)
  8489. {
  8490. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8491. }
  8492. string preTime = GetPostString("preOutTime");
  8493. if (preTime.Length > 0)
  8494. {
  8495. entity.PreOutTime = Convert.ToDateTime(preTime);
  8496. }
  8497. entity.DeliveryCount = GetPostInt("deliveryCount");
  8498. entity.ReceiveCount = GetPostInt("receiveCount");
  8499. entity.OutSid = GetPostString("outSid");
  8500. entity.FileName = GetPostString("fileName");
  8501. entity.Memo = GetPostString("memo");
  8502. entity.AddUserId = CurrentUser.UserID;
  8503. entity.CreateTime = DateTime.Now;
  8504. entity.Img = GetPostString("img");
  8505. entity.Supplier = GetPostInt("supplier");
  8506. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8507. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8508. {
  8509. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8510. DateTime dt2 = (DateTime)entity.PreOutTime;
  8511. TimeSpan span = dt1.Subtract(dt2);
  8512. if (span.Days > 0)
  8513. {
  8514. entity.OutLate = span.Days;
  8515. }
  8516. }
  8517. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8518. entity.Create();
  8519. returnSuccessMsg("添加成功!");
  8520. return;
  8521. }
  8522. else //修改
  8523. {
  8524. entity = CeErpPlaceRegister.Get(eid);
  8525. if (entity != null)
  8526. {
  8527. string xdTime = GetPostString("placeTime");
  8528. if (xdTime.Length > 0)
  8529. {
  8530. entity.PlactTime = Convert.ToDateTime(xdTime);
  8531. }
  8532. string fhTime = GetPostString("deliveryTime");
  8533. if (fhTime.Length > 0)
  8534. {
  8535. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8536. }
  8537. string preTime = GetPostString("preOutTime");
  8538. if (preTime.Length > 0)
  8539. {
  8540. entity.PreOutTime = Convert.ToDateTime(preTime);
  8541. }
  8542. entity.DeliveryCount = GetPostInt("deliveryCount");
  8543. entity.ReceiveCount = GetPostInt("receiveCount");
  8544. if (entity.DeliveryCount == entity.ReceiveCount)
  8545. {
  8546. entity.CurState = "已完成";
  8547. }
  8548. else
  8549. {
  8550. entity.CurState = "未完成";
  8551. }
  8552. entity.OutSid = GetPostString("outSid");
  8553. entity.FileName = GetPostString("fileName");
  8554. entity.Memo = GetPostString("memo");
  8555. entity.Img = GetPostString("img");
  8556. entity.Supplier = GetPostInt("supplier");
  8557. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8558. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8559. {
  8560. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8561. DateTime dt2 = (DateTime)entity.PreOutTime;
  8562. TimeSpan span = dt1.Subtract(dt2);
  8563. if (span.Days > 0)
  8564. {
  8565. entity.OutLate = span.Days;
  8566. }
  8567. }
  8568. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8569. entity.Update();
  8570. returnSuccessMsg("修改成功");
  8571. return;
  8572. }
  8573. returnErrorMsg("找不到对应的记录");
  8574. return;
  8575. }
  8576. }
  8577. returnErrorMsg("缺少必要参数");
  8578. }
  8579. public void del_erp_placeregist()
  8580. {
  8581. string eid = GetPostString("id");
  8582. CeErpPlaceRegister.Del(eid);
  8583. returnSuccessMsg("删除成功!");
  8584. return;
  8585. }
  8586. public void ins_erp_placeregistbyorder()
  8587. {
  8588. string ctid = GetPostString("ctid");
  8589. if (ctid.Length > 0)
  8590. {
  8591. StringBuilder sql = new StringBuilder();
  8592. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8593. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8594. if (dt.Rows.Count > 0)
  8595. {
  8596. foreach (DataRow dr in dt.Rows)
  8597. {
  8598. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8599. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8600. entity.AddUserId = CurrentUser.UserID;
  8601. entity.tid = dr["tid"].ToString();
  8602. entity.Did = Convert.ToString(dr["ctid"]);
  8603. entity.splitTag = dr["SplitTag"].ToString();
  8604. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8605. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8606. if (pre_ctid.Length > 0)
  8607. {
  8608. sellmemo = sellmemo.Replace(pre_ctid, "");
  8609. }
  8610. sellmemo = sellmemo.Replace("[", "");
  8611. sellmemo = sellmemo.Replace("]", "");
  8612. entity.FileName = sellmemo;
  8613. string count = dr["ProductCount"].ToString();
  8614. int usecount = commonHelper.getIntCountFromString(count);
  8615. entity.DeliveryCount = usecount;
  8616. entity.CurState = "未完成";
  8617. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8618. {
  8619. entity.Supplier = 24;//dl手提袋定制
  8620. }
  8621. else
  8622. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8623. entity.CreateTime = DateTime.Now;
  8624. entity.Create();
  8625. }
  8626. returnSuccessMsg("操作成功");
  8627. return;
  8628. }
  8629. returnErrorMsg("没有找到对应订单");
  8630. return;
  8631. }
  8632. returnErrorMsg("缺少订单编号");
  8633. return;
  8634. }
  8635. public void get_erp_persuadelist()
  8636. {
  8637. DataStruct dStruct = GetPostStruct();
  8638. List<string> lw = new List<string>();
  8639. string ctid = GetPostString("ctid");
  8640. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8641. string shopname = GetPostString("shopname");
  8642. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8643. string buyernick = GetPostString("buyer_nick");
  8644. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8645. string customer = GetPostString("customer");
  8646. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8647. string returndate1 = GetPostString("returndate1");
  8648. string returndate2 = GetPostString("returndate2");
  8649. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8650. if (dw.Length > 0) lw.Add(dw);
  8651. string finishDate1 = GetPostString("finishdate1");
  8652. string finishDate2 = GetPostString("finishdate2");
  8653. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8654. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8655. string persuadetype = GetPostString("persuadetype");
  8656. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8657. string returnvstate = GetPostString("returnvstate");
  8658. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8659. dStruct.Order = "created desc";
  8660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8661. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8662. writeGridDataTableJson(dStruct.TotalCount, dt);
  8663. }
  8664. public void upd_erp_returnpersuadeback()
  8665. {
  8666. if (UrlPostParmsCheck("ID"))
  8667. {
  8668. int eid = GetPostInt("ID");
  8669. CeErpPersuade entity = null;
  8670. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8671. if (entity != null)
  8672. {
  8673. entity.backreason = GetPostString("reason");
  8674. entity.pstate = 2;
  8675. entity.verifytime = DateTime.Now;
  8676. entity.verifyuserid = CurrentUser.UserID;
  8677. entity.Update();
  8678. returnSuccessMsg("退回成功!");
  8679. return;
  8680. }
  8681. returnErrorMsg("找不到订单记录");
  8682. }
  8683. }
  8684. public void upd_erp_returnpersuadeverify()
  8685. {
  8686. if (UrlPostParmsCheck("ID"))
  8687. {
  8688. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8689. {
  8690. returnErrorMsg("暂无权限审核");
  8691. return;
  8692. }
  8693. int eid = GetPostInt("ID");
  8694. CeErpPersuade entity = null;
  8695. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8696. if (entity != null)
  8697. {
  8698. entity.pstate = 1;
  8699. entity.verifytime = DateTime.Now;
  8700. entity.verifyuserid = CurrentUser.UserID;
  8701. entity.Update();
  8702. returnSuccessMsg("审核成功!");
  8703. return;
  8704. }
  8705. returnErrorMsg("找不到订单记录");
  8706. }
  8707. }
  8708. public void del_erp_persuade()
  8709. {
  8710. if (UrlPostParmsCheck("ID"))
  8711. {
  8712. int eid = GetPostInt("ID");
  8713. CeErpPersuade.Del(eid);
  8714. returnSuccessMsg("操作成功");
  8715. return;
  8716. }
  8717. }
  8718. public void get_erp_oldcustoupload()
  8719. {
  8720. DataStruct dStruct = GetPostStruct();
  8721. List<string> lw = new List<string>();
  8722. string buyernick = GetPostString("buyer_nick");
  8723. if (buyernick.Length > 0)
  8724. {
  8725. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8726. }
  8727. else
  8728. return;
  8729. dStruct.Order = "pay_time desc";
  8730. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8731. DataTable dt = null;
  8732. dt = WebCache.GetData("view_erptradecell", dStruct);
  8733. writeGridDataTableJson(dStruct.TotalCount, dt);
  8734. }
  8735. public void get_erp_checkorderlist()
  8736. {
  8737. DataStruct dStruct = GetPostStruct();
  8738. List<string> lw = new List<string>();
  8739. string tid = GetPostString("ctid");
  8740. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8741. string shopname = GetPostString("shopname");
  8742. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8743. string buyernick = GetPostString("buyer_nick");
  8744. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8745. string customer = GetPostString("customer");
  8746. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8747. string design = GetPostString("design");
  8748. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8749. string orderState = GetPostString("orderState");
  8750. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8751. string address = GetPostString("address");
  8752. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8753. string sellermemo = GetPostString("seller_memo");
  8754. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8755. string supplier = GetPostString("supplier");
  8756. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8757. {
  8758. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8759. }
  8760. else
  8761. {
  8762. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8763. }
  8764. string date1 = GetPostString("date1");
  8765. string date2 = GetPostString("date2");
  8766. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8767. if (dw.Length > 0) lw.Add(dw);
  8768. string placedate1 = GetPostString("placedate1");
  8769. string placedate2 = GetPostString("placedate2");
  8770. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8771. if (fdw.Length > 0) lw.Add(fdw);
  8772. string price1 = GetPostString("price1");
  8773. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8774. string price2 = GetPostString("price2");
  8775. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8776. string checkst = GetPostString("checkstate");
  8777. if (checkst.Length > 0 && "10".Equals(checkst))
  8778. {
  8779. lw.Add(string.Format("CheckOut>0"));
  8780. }
  8781. else
  8782. {
  8783. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8784. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8785. }
  8786. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8787. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8788. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8789. writeGridDataTableJson(dStruct.TotalCount, dt);
  8790. }
  8791. public void ins_erp_startCheck()
  8792. {
  8793. if (UrlPostParmsCheck("ctid"))
  8794. {
  8795. string eid = GetPostString("ctid");
  8796. CeErpTradeCell entity = null;
  8797. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8798. if (entity != null)
  8799. {
  8800. entity.MemoOpt = 4;
  8801. entity.Update();
  8802. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8803. CeErpSukuraData.createInfo(entity.ctid, 6);
  8804. returnSuccessMsg("操作成功!");
  8805. return;
  8806. }
  8807. returnErrorMsg("找不到记录");
  8808. }
  8809. }
  8810. public void upd_erp_sendXlw()
  8811. {
  8812. if (UrlPostParmsCheck("ctid"))
  8813. {
  8814. string eid = GetPostString("ctid");
  8815. CeErpTradeCell entity = null;
  8816. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8817. if (entity != null)
  8818. {
  8819. if (entity.IsSendGift == 1)
  8820. {
  8821. returnErrorMsg("请勿重复标记");
  8822. return;
  8823. }
  8824. entity.IsSendGift = 1;
  8825. entity.Update();
  8826. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8827. returnSuccessMsg("操作成功!");
  8828. return;
  8829. }
  8830. returnErrorMsg("找不到记录");
  8831. }
  8832. }
  8833. public void cancel_sendXlw()
  8834. {
  8835. if (UrlPostParmsCheck("ctid"))
  8836. {
  8837. string eid = GetPostString("ctid");
  8838. CeErpTradeCell entity = null;
  8839. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8840. if (entity != null)
  8841. {
  8842. if (entity.IsSendGift == 0)
  8843. {
  8844. returnErrorMsg("未标记小礼物");
  8845. return;
  8846. }
  8847. entity.IsSendGift = 0;
  8848. entity.Update();
  8849. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8850. returnSuccessMsg("操作成功!");
  8851. return;
  8852. }
  8853. returnErrorMsg("找不到记录");
  8854. }
  8855. }
  8856. public void get_erp_designbill()
  8857. {
  8858. DataStruct dStruct = GetPostStruct();
  8859. List<string> lw = new List<string>();
  8860. int isMy = GetInt("my");
  8861. if (isMy == 1)
  8862. {
  8863. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8864. }
  8865. string tid = GetPostString("tid");
  8866. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8867. string userName = GetPostString("design");
  8868. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8869. string price1 = GetPostString("price1");
  8870. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8871. string price2 = GetPostString("price2");
  8872. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8873. string rePrice1 = GetPostString("rePrice1");
  8874. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8875. string rePrice2 = GetPostString("rePrice2");
  8876. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8877. string designerType = GetPostString("designerType");
  8878. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8879. string orderState = GetPostString("orderState");
  8880. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8881. string endTime1 = GetPostString("endTime1");
  8882. string endTime2 = GetPostString("endTime2");
  8883. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8884. if (dw.Length > 0) lw.Add(dw);
  8885. string isDk = GetPostString("isDk");
  8886. if (isDk == "1")
  8887. {
  8888. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8889. }
  8890. else if (isDk == "0")
  8891. {
  8892. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8893. }
  8894. dStruct.Order = "oid, create_time desc";
  8895. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8896. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8897. writeGridDataTableJson(dStruct.TotalCount, dt);
  8898. }
  8899. public void upd_erp_designerbill()
  8900. {
  8901. if (UrlPostParmsCheck("ID"))
  8902. {
  8903. string eid = GetPostString("ID");
  8904. CeErpDesignerBill entity = null;
  8905. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8906. if (entity != null)
  8907. {
  8908. if (GetPostDouble("designerpirce") > 0)
  8909. {
  8910. entity.realPrice = GetPostDouble("designerpirce");
  8911. entity.update_time = DateTime.Now;
  8912. entity.update_u_id = CurrentUser.UserID;
  8913. entity.update_u_name = CurrentUser.UserName;
  8914. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8915. entity.Update();
  8916. returnSuccessMsg("操作成功!");
  8917. return;
  8918. }
  8919. else
  8920. {
  8921. entity.price = GetPostDouble("price");
  8922. entity.update_time = DateTime.Now;
  8923. entity.update_u_id = CurrentUser.UserID;
  8924. entity.update_u_name = CurrentUser.UserName;
  8925. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8926. entity.Update();
  8927. returnSuccessMsg("操作成功!");
  8928. return;
  8929. }
  8930. }
  8931. returnErrorMsg("找不到记录");
  8932. }
  8933. }
  8934. public void audit_erp_designerbill()
  8935. {
  8936. if (UrlPostParmsCheck("ID"))
  8937. {
  8938. string eid = GetPostString("ID");
  8939. CeErpDesignerBill entity = null;
  8940. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8941. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8942. if (entity != null)
  8943. {
  8944. entity.realPrice = GetPostDouble("designerpirce");
  8945. entity.update_time = DateTime.Now;
  8946. entity.update_u_id = CurrentUser.UserID;
  8947. entity.update_u_name = CurrentUser.UserName;
  8948. entity.isAudit = 1;
  8949. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8950. entity.Update();
  8951. if (orderEntity != null)
  8952. {
  8953. orderEntity.IsReadTag = 3;
  8954. orderEntity.Update();
  8955. }
  8956. returnSuccessMsg("操作成功!");
  8957. return;
  8958. }
  8959. returnErrorMsg("找不到记录");
  8960. }
  8961. }
  8962. public void all_audit_erp_designerbill()
  8963. {
  8964. if (UrlPostParmsCheck("idList"))
  8965. {
  8966. string[] list = GetPostString("idList").Split(',');
  8967. CeErpDesignerBill entity = null;
  8968. for (int i = 0; i < list.Length; i++)
  8969. {
  8970. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8971. if (entity == null) return;
  8972. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8973. if (orderEntity == null) return;
  8974. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8975. entity.update_time = DateTime.Now;
  8976. entity.update_u_id = CurrentUser.UserID;
  8977. entity.update_u_name = CurrentUser.UserName;
  8978. entity.isAudit = 1;
  8979. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8980. entity.Update();
  8981. orderEntity.IsReadTag = 3;
  8982. orderEntity.Update();
  8983. }
  8984. returnSuccessMsg("操作成功!");
  8985. return;
  8986. }
  8987. }
  8988. public void get_erp_sameorders()
  8989. {
  8990. if (UrlPostParmsCheck("ctid"))
  8991. {
  8992. string eid = GetPostString("ctid");
  8993. CeErpTradeCell entity = null;
  8994. entity = CeErpTradeCell.GetByCtid(eid);
  8995. if (entity != null)
  8996. {
  8997. StringBuilder sql = new StringBuilder();
  8998. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8999. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9000. var res = new
  9001. {
  9002. data = dt.Rows.Count
  9003. };
  9004. string ro_jsond = JsonConvert.SerializeObject(res);
  9005. returnSuccess(ro_jsond);
  9006. return;
  9007. }
  9008. returnErrorMsg("未找到订单");
  9009. return;
  9010. }
  9011. returnErrorMsg("缺少必要的参数");
  9012. }
  9013. public void get_erp_islasthavesameorder()
  9014. {
  9015. if (UrlPostParmsCheck("ctid"))
  9016. {
  9017. string eid = GetPostString("ctid");
  9018. string[] ctidList = eid.Split(',');
  9019. StringBuilder sql = new StringBuilder();
  9020. string tisCtid = "";
  9021. foreach (string ctid in ctidList)
  9022. {
  9023. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9024. if (entity != null)
  9025. {
  9026. sql = new StringBuilder();
  9027. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9028. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9029. if (dth.Rows.Count > 0)
  9030. {
  9031. tisCtid += entity.ctid;
  9032. tisCtid += ",";
  9033. }
  9034. }
  9035. }
  9036. if (tisCtid.Length > 0)
  9037. {
  9038. var res = new
  9039. {
  9040. data = tisCtid
  9041. };
  9042. string ro_jsond = JsonConvert.SerializeObject(res);
  9043. returnSuccess(ro_jsond);
  9044. }
  9045. else
  9046. {
  9047. var res = new
  9048. {
  9049. data = ""
  9050. };
  9051. string ro_jsond = JsonConvert.SerializeObject(res);
  9052. returnSuccess(ro_jsond);
  9053. }
  9054. return;
  9055. }
  9056. returnErrorMsg("缺少必要的参数");
  9057. }
  9058. public void file_client_down_url()
  9059. {
  9060. if (!UrlPostParmsCheck("userId"))
  9061. {
  9062. returnErrorMsg("缺少必要的参数");
  9063. }
  9064. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9065. }
  9066. public void checkout_form_data()
  9067. {
  9068. if (!UrlPostParmsCheck("tid"))
  9069. {
  9070. returnErrorMsg("缺少必要的参数");
  9071. }
  9072. string tid = GetPostString("tid");
  9073. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9074. if (ceErpOrderFormData != null)
  9075. {
  9076. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9077. returnSuccess(ro_jsond);
  9078. return;
  9079. }
  9080. returnErrorMsg("尚未有文件!");
  9081. }
  9082. public void back_supplier_audit()
  9083. {
  9084. int userId = CurrentUser.UserID;
  9085. StringBuilder sql = new StringBuilder();
  9086. 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);
  9087. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9088. if (dt.Rows.Count > 0)
  9089. {
  9090. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9091. }
  9092. else
  9093. {
  9094. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9095. }
  9096. }
  9097. public void back_supplier_query()
  9098. {
  9099. string eid = GetPostString("ctid");
  9100. if (eid != "")
  9101. {
  9102. StringBuilder sql = new StringBuilder();
  9103. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9104. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9105. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9106. }
  9107. else
  9108. {
  9109. returnErrorMsg("找不到订单记录");
  9110. return;
  9111. }
  9112. }
  9113. public void verified_to_order()
  9114. {
  9115. int userId = CurrentUser.UserID;
  9116. StringBuilder sql = new StringBuilder();
  9117. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9118. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9119. if (dt.Rows.Count > 0)
  9120. {
  9121. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9122. }
  9123. else
  9124. {
  9125. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9126. }
  9127. }
  9128. public void upd_supplier_audit()
  9129. {
  9130. if (UrlPostParmsCheck("ctid"))
  9131. {
  9132. string eid = GetPostString("ctid");
  9133. string reason = GetPostString("returnreason");
  9134. CeErpTradeCell entity = null;
  9135. CeWithdraw withdraw = null;
  9136. withdraw = CeWithdraw.GetByTid(eid);
  9137. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9138. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9139. {
  9140. if (withdraw != null)
  9141. {
  9142. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9143. {
  9144. returnSuccessMsg("您没有权限操作!");
  9145. return;
  9146. }
  9147. else
  9148. {
  9149. if (reason.Equals("1"))
  9150. {
  9151. if (entity.OrderState == -1)
  9152. {
  9153. if (entity.FinishPlaceTime == null)
  9154. {
  9155. entity.OrderState = 2;
  9156. }
  9157. else
  9158. {
  9159. entity.OrderState = 6;
  9160. }
  9161. }
  9162. entity.Update();
  9163. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9164. if (withdraw != null)
  9165. {
  9166. withdraw.status = int.Parse(reason);
  9167. withdraw.Update();
  9168. }
  9169. returnSuccessMsg("操作成功!");
  9170. return;
  9171. }
  9172. else
  9173. {
  9174. withdraw.status = int.Parse(reason);
  9175. withdraw.acknowledgingtime = DateTime.Now;
  9176. withdraw.Update();
  9177. returnSuccessMsg("查看详细请点击线下订单查询");
  9178. return;
  9179. }
  9180. }
  9181. }
  9182. // 第一个字符是 'N'
  9183. }
  9184. if (eid[0] != 'N')
  9185. {
  9186. }
  9187. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9188. {
  9189. entity.IsVerifyToSupplier = false;
  9190. entity.IsReturn = 1;
  9191. entity.ReturnTime = DateTime.Now;
  9192. entity.ReturnReason = reason;
  9193. if (entity.OrderState == 6)
  9194. {
  9195. entity.OrderState = 5;
  9196. }
  9197. entity.Update();
  9198. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9199. if (withdraw != null)
  9200. {
  9201. withdraw.status = int.Parse(reason);
  9202. withdraw.Update();
  9203. }
  9204. returnSuccessMsg("操作成功!");
  9205. return;
  9206. }
  9207. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9208. {
  9209. ;
  9210. if (withdraw != null)
  9211. {
  9212. withdraw.status = int.Parse(reason);
  9213. withdraw.acknowledgingtime = DateTime.Now;
  9214. withdraw.Update();
  9215. returnSuccessMsg("供应商取消撤回!");
  9216. return;
  9217. }
  9218. }
  9219. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9220. {
  9221. if (entity.OrderState == -1)
  9222. {
  9223. if (entity.FinishPlaceTime == null)
  9224. {
  9225. entity.OrderState = 2;
  9226. }
  9227. else
  9228. {
  9229. entity.OrderState = 3;
  9230. }
  9231. commonHelper.getCytPrice(entity);
  9232. }
  9233. entity.Update();
  9234. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9235. if (withdraw != null)
  9236. {
  9237. withdraw.status = int.Parse(reason);
  9238. withdraw.Update();
  9239. }
  9240. returnSuccessMsg("操作成功!");
  9241. return;
  9242. }
  9243. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9244. {
  9245. if (withdraw == null)
  9246. {
  9247. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9248. return;
  9249. }
  9250. }
  9251. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9252. {
  9253. if (withdraw != null)
  9254. {
  9255. withdraw.status = int.Parse(reason);
  9256. withdraw.acknowledgingtime = DateTime.Now;
  9257. withdraw.Update();
  9258. returnSuccessMsg("查看详细请点击线下订单查询");
  9259. return;
  9260. }
  9261. }
  9262. return;
  9263. }
  9264. }
  9265. //校验报价
  9266. public void refund_order_tip()
  9267. {
  9268. int userid = CurrentUser.UserID;
  9269. int sectionId = CurrentUser.UserPost.OrgID;
  9270. StringBuilder sql = new StringBuilder();
  9271. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9272. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9273. List<string> ids = new List<string>();
  9274. if (dth.Rows.Count > 0)
  9275. {
  9276. foreach (DataRow dr in dth.Rows)
  9277. {
  9278. ids.Add(dr["ID"].ToString());
  9279. }
  9280. try
  9281. {
  9282. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9283. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9284. }
  9285. catch (Exception ex)
  9286. {
  9287. }
  9288. }
  9289. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9290. }
  9291. public void refund_order_Design()
  9292. {
  9293. int userid = CurrentUser.UserID;
  9294. int sectionId = CurrentUser.UserPost.OrgID;
  9295. StringBuilder sql = new StringBuilder();
  9296. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9297. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9298. List<string> ids = new List<string>();
  9299. if (dth.Rows.Count > 0)
  9300. {
  9301. foreach (DataRow dr in dth.Rows)
  9302. {
  9303. ids.Add(dr["ID"].ToString());
  9304. }
  9305. try
  9306. {
  9307. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9308. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9309. }
  9310. catch (Exception ex)
  9311. {
  9312. }
  9313. }
  9314. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9315. }
  9316. public void change_order_info()
  9317. {
  9318. int userid = CurrentUser.UserID;
  9319. StringBuilder sql = new StringBuilder();
  9320. 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);
  9321. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9322. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9323. }
  9324. public void change_win_mome()
  9325. {
  9326. if (UrlPostParmsCheck("id,ctid"))
  9327. {
  9328. string id = GetPostString("id");
  9329. string ctid = GetPostString("ctid");
  9330. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9331. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9332. if (ce == null || ceErpMessageTip == null)
  9333. {
  9334. returnSuccessMsg("未找到对应的订单!");
  9335. return;
  9336. }
  9337. int type = GetPostInt("type");
  9338. string content = GetPostString("content");
  9339. if (type == 0)
  9340. {
  9341. content = content.Replace("(", "(");
  9342. content = content.Replace(")", ")");
  9343. string check = MidStrEx(content, "(", ")").Trim();
  9344. if (string.IsNullOrEmpty(check))
  9345. {
  9346. returnSuccessMsg("文件名格式不正确");
  9347. return;
  9348. }
  9349. }
  9350. ce.seller_memo = content;
  9351. ce.Update();
  9352. ceErpMessageTip.isVisit = true;
  9353. ceErpMessageTip.Update();
  9354. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9355. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9356. ApiVo apiVo = new ApiVo();
  9357. apiVo.orderNumber = ce.ctid;
  9358. apiVo.actionName = "demandDesign";
  9359. apiVo.orderRemarks = content;
  9360. apiVo.demandExamine = type + 1;
  9361. designHelper.API_WorkCore(apiVo);//demandDesign
  9362. returnSuccessMsg("修改成功!");
  9363. }
  9364. }
  9365. public static string MidStrEx(string sourse, string startstr, string endstr)
  9366. {
  9367. string result = string.Empty;
  9368. int startindex, endindex;
  9369. try
  9370. {
  9371. startindex = sourse.IndexOf(startstr);
  9372. if (startindex == -1)
  9373. return result;
  9374. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9375. endindex = tmpstr.IndexOf(endstr);
  9376. if (endindex == -1)
  9377. return result;
  9378. result = tmpstr.Remove(endindex);
  9379. }
  9380. catch (Exception ex)
  9381. {
  9382. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9383. }
  9384. return result;
  9385. }
  9386. public void refund_order_list()
  9387. {
  9388. int userid = CurrentUser.UserID;
  9389. int sectionId = CurrentUser.UserPost.OrgID;
  9390. StringBuilder sql = new StringBuilder();
  9391. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9392. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9393. DataStruct dStruct = GetPostStruct();
  9394. DataTable dt = null;
  9395. List<string> ids = new List<string>();
  9396. List<string> tids = new List<string>();
  9397. if (dth.Rows.Count > 0)
  9398. {
  9399. foreach (DataRow dr in dth.Rows)
  9400. {
  9401. tids.Add("'" + dr["tid"].ToString() + "'");
  9402. ids.Add(dr["id"].ToString());
  9403. }
  9404. try
  9405. {
  9406. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9407. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9408. List<string> lw = new List<string>();
  9409. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9410. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9411. dt = WebCache.GetData("view_orderlist", dStruct);
  9412. }
  9413. catch (Exception ex)
  9414. {
  9415. }
  9416. }
  9417. writeGridDataTableJson(dStruct.TotalCount, dt);
  9418. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9419. }
  9420. //新增
  9421. public void order_batch_downloads()
  9422. {
  9423. string ceid = GetPostString("tid");
  9424. String[] tid = ceid.Split(',');
  9425. order_batch_caiyingtong(tid);
  9426. /* (string success, string errors) = UploadFiles(tid);
  9427. returnSuccessMsg(success + errors);*/
  9428. return;
  9429. }
  9430. //报价接口
  9431. public void Get_To_Quote()
  9432. {
  9433. string ceid = GetPostString("ctid");
  9434. if (ceid != null)
  9435. {
  9436. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9437. if (entity != null)
  9438. {
  9439. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9440. {
  9441. return;
  9442. }
  9443. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9444. double price = 0;
  9445. if (cp == null)
  9446. {
  9447. JObject jsonObject12 = new JObject
  9448. {
  9449. { "UserId", "77886" },
  9450. { "Pwd", "lt666888" },
  9451. { "Filename", entity.seller_memo }
  9452. };
  9453. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9454. JObject jsonObjects1 = JObject.Parse(response1);
  9455. string ms1g = (string)jsonObjects1["msg"];
  9456. if (ms1g == "报价成功")
  9457. {
  9458. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9459. string data = (string)jsonObject1["price"];
  9460. 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 + "');";
  9461. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9462. returnSuccessMsg("获取报价成功:" + data);
  9463. price = Convert.ToDouble(data);
  9464. }
  9465. else
  9466. {
  9467. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9468. return;
  9469. }
  9470. }
  9471. String[] beizhu = entity.seller_memo.Split('-');
  9472. String chanp = "";
  9473. if (beizhu.Length > 0)
  9474. {
  9475. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9476. }
  9477. else
  9478. {
  9479. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9480. }
  9481. JObject jsonObject = new JObject
  9482. {
  9483. { "UserId", "77886" },
  9484. { "Pwd", "lt666888" },
  9485. { "Filename", chanp }
  9486. };
  9487. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9488. JObject jsonObjects = JObject.Parse(response);
  9489. string msg = (string)jsonObjects["msg"];
  9490. if (msg == "报价成功")
  9491. {
  9492. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9493. string data = (string)jsonObject1["price"];
  9494. 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 + "');";
  9495. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9496. returnSuccessMsg("获取报价成功:" + data);
  9497. price = Convert.ToDouble(data);
  9498. }
  9499. else
  9500. {
  9501. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9502. return;
  9503. }
  9504. if (price > 0)
  9505. {
  9506. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9507. if (ceErpTradeCellExtend == null)
  9508. {
  9509. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9510. ceErpTradeCellExtend.ctid = entity.ctid;
  9511. ceErpTradeCellExtend.payment_cyt = price;
  9512. ceErpTradeCellExtend.Create();
  9513. }
  9514. else
  9515. {
  9516. ceErpTradeCellExtend.payment_cyt = price;
  9517. ceErpTradeCellExtend.Update();
  9518. }
  9519. }
  9520. return;
  9521. }
  9522. }
  9523. else
  9524. {
  9525. returnErrorMsg("请至少选择一条数据");
  9526. return;
  9527. }
  9528. }
  9529. //新增
  9530. public void order_To_Supplier()
  9531. {
  9532. string ceid = GetPostString("tid");
  9533. String[] tid = ceid.Split(',');
  9534. if (tid.Length > 0)
  9535. {
  9536. try
  9537. {
  9538. for (int i = 0; i < tid.Length; i++)
  9539. {
  9540. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9541. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9542. entity.SupplierId = suid;
  9543. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9544. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9545. entity.Update();
  9546. }
  9547. }
  9548. catch (Exception ex)
  9549. {
  9550. returnErrorMsg("自动匹配供应商失败");
  9551. return;
  9552. }
  9553. }
  9554. else
  9555. {
  9556. returnErrorMsg("请至少选择一条数据");
  9557. return;
  9558. }
  9559. returnSuccessMsg("自动匹配供应商成功");
  9560. return;
  9561. }
  9562. public (string, string) UploadFiles(string[] urls)
  9563. {
  9564. string success = "";
  9565. string errors = "";
  9566. int userid = CurrentUser.UserID;
  9567. foreach (string url in urls)
  9568. {
  9569. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9570. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9571. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9572. {
  9573. JObject jsonObject = new JObject
  9574. {
  9575. { "Userid", "77886" },
  9576. { "pwd", "cyt86435015" },
  9577. { "content", base64FileContent },
  9578. { "ext", Path.GetExtension(fileName) }
  9579. };
  9580. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9581. JObject jsonObjects = JObject.Parse(response);
  9582. string msg = (string)jsonObjects["msg"];
  9583. if (msg.Equals("上传成功"))
  9584. {
  9585. success += url + " 上传成功";
  9586. }
  9587. else
  9588. {
  9589. errors += url + " 上传失败";
  9590. }
  9591. }
  9592. else
  9593. {
  9594. errors += url + " 格式出现问题";
  9595. }
  9596. }
  9597. if (urls.Length == 0)
  9598. {
  9599. return (success, errors);
  9600. }
  9601. return (success, errors);
  9602. }
  9603. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9604. {
  9605. return true; //总是接受
  9606. }
  9607. public static string HttpPost(string url, string param = null)
  9608. {
  9609. HttpWebRequest request;
  9610. //如果是发送HTTPS请求
  9611. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9612. {
  9613. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9614. request = WebRequest.Create(url) as HttpWebRequest;
  9615. request.ProtocolVersion = HttpVersion.Version10;
  9616. }
  9617. else
  9618. {
  9619. request = WebRequest.Create(url) as HttpWebRequest;
  9620. }
  9621. request.Method = "POST";
  9622. request.ContentType = "application/json";
  9623. request.Accept = "*/*";
  9624. request.Timeout = 120000;
  9625. request.AllowAutoRedirect = false;
  9626. StreamWriter requestStream = null;
  9627. WebResponse response = null;
  9628. string responseStr = null;
  9629. try
  9630. {
  9631. requestStream = new StreamWriter(request.GetRequestStream());
  9632. requestStream.Write(param);
  9633. requestStream.Close();
  9634. response = request.GetResponse();
  9635. if (response != null)
  9636. {
  9637. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9638. responseStr = reader.ReadToEnd();
  9639. reader.Close();
  9640. }
  9641. }
  9642. catch (Exception ex)
  9643. {
  9644. return ex.Message;
  9645. }
  9646. finally
  9647. {
  9648. request = null;
  9649. requestStream = null;
  9650. response = null;
  9651. }
  9652. return responseStr;
  9653. }
  9654. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9655. {
  9656. string base64FileContent;
  9657. string fileName;
  9658. using (WebClient webClient = new WebClient())
  9659. {
  9660. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9661. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9662. {
  9663. using (Stream stream = response.GetResponseStream())
  9664. {
  9665. using (MemoryStream memoryStream = new MemoryStream())
  9666. {
  9667. stream.CopyTo(memoryStream);
  9668. byte[] fileBytes = memoryStream.ToArray();
  9669. base64FileContent = Convert.ToBase64String(fileBytes);
  9670. fileName = response.Headers["Content-Disposition"];
  9671. if (!string.IsNullOrEmpty(fileName))
  9672. {
  9673. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9674. if (index >= 0)
  9675. {
  9676. fileName = fileName.Substring(index + 9).Trim('\"');
  9677. }
  9678. }
  9679. else
  9680. {
  9681. fileName = Path.GetFileName(downloadUrl);
  9682. }
  9683. }
  9684. }
  9685. }
  9686. }
  9687. return (fileName, base64FileContent);
  9688. }
  9689. //新增
  9690. public void order_batch_caiyingtong(string[] downloadUrls)
  9691. {
  9692. try
  9693. {
  9694. //遍历文件
  9695. DataStruct dStruct = GetPostStruct();
  9696. DataTable dt = null;
  9697. int userid = CurrentUser.UserID;
  9698. List<string> ids = new List<string>();//失败组
  9699. List<string> tids = new List<string>();
  9700. using (WebClient webClient = new WebClient())
  9701. {
  9702. foreach (var url in downloadUrls)
  9703. {
  9704. try
  9705. {
  9706. tids.Add("'" + url + "'");
  9707. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9708. if (entity != null)
  9709. {
  9710. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9711. if (cp == null)
  9712. {
  9713. JObject jsonObject = new JObject
  9714. {
  9715. { "Userid", "77886" },
  9716. { "pwd", "lt666888" },
  9717. { "Filename",entity.seller_memo }
  9718. };
  9719. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9720. JObject jsonObjects = JObject.Parse(response);
  9721. string msg = (string)jsonObjects["msg"];
  9722. if (msg == "报价成功")
  9723. {
  9724. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9725. DownloadAndConvertToBase64(url1);
  9726. }
  9727. else
  9728. {
  9729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9730. }
  9731. }
  9732. else
  9733. {
  9734. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9735. JObject jsonObject = new JObject
  9736. {
  9737. { "Userid", "77886" },
  9738. { "pwd", "lt666888" },
  9739. { "Filename",chanp }
  9740. };
  9741. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9742. JObject jsonObjects = JObject.Parse(response);
  9743. string msg = (string)jsonObjects["msg"];
  9744. if (msg == "报价成功")
  9745. {
  9746. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9747. DownloadAndConvertToBase64(url1);
  9748. }
  9749. else
  9750. {
  9751. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9752. }
  9753. }
  9754. }
  9755. // 上传文件到FTP
  9756. }
  9757. catch (Exception ex)
  9758. {
  9759. Console.WriteLine($"An error occurred: {ex.Message}");
  9760. }
  9761. }
  9762. List<string> lw = new List<string>();
  9763. lw.Add(string.Format("( OrderState < 6 )"));
  9764. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9765. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9766. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9767. if (dt.Rows.Count > 0)
  9768. {
  9769. foreach (DataRow dr in dt.Rows)
  9770. {
  9771. ids.Add(dr["ctid"].ToString());
  9772. }
  9773. }
  9774. String ErrorMsgs = "";
  9775. foreach (String id in ids)
  9776. {
  9777. ErrorMsgs += id + ",";
  9778. }
  9779. if (ErrorMsgs.Length > 1)
  9780. {
  9781. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9782. }
  9783. if (ErrorMsgs.Length < 1)
  9784. {
  9785. ErrorMsgs = "上传成功";
  9786. returnSuccessMsg(ErrorMsgs);
  9787. }
  9788. else
  9789. {
  9790. returnErrorMsg("以下订单" + ErrorMsgs);
  9791. }
  9792. }
  9793. // 删除文件夹及其内容
  9794. /* Directory.Delete(localDirectory, true);*/
  9795. }
  9796. catch { }
  9797. }
  9798. public void get_center_data()
  9799. {
  9800. int userId = CurrentUser.UserID;
  9801. string postCode = CurrentUser.UserPost.Post.Code;
  9802. List<string> lw = new List<string>();
  9803. List<string> ww = new List<string>();
  9804. DateTime currentTime = DateTime.Now;
  9805. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9806. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9807. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9808. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9809. string sql = " SELECT ";
  9810. string startTime = "2023-10-01 11:22:31";
  9811. //设计
  9812. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9813. {
  9814. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9815. 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));
  9816. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9817. 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));
  9818. }
  9819. //客服
  9820. else if (postCode == "CustomerService" || postCode == "Director")
  9821. {
  9822. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9823. 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));
  9824. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9825. 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));
  9826. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9827. 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));
  9828. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9829. 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));
  9830. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9831. 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));
  9832. }
  9833. //售后
  9834. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9835. {
  9836. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9837. 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));
  9838. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9839. 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));
  9840. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9841. 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));
  9842. }
  9843. //下单部
  9844. else if (postCode == "Place" || postCode == "PlaceMr")
  9845. {
  9846. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9847. 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));
  9848. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9849. 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));
  9850. }
  9851. //车间
  9852. else if (postCode == "Supplier")
  9853. {
  9854. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9855. 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));
  9856. }
  9857. DataTable dt = new DataTable();
  9858. if (lw.Count > 0)
  9859. {
  9860. sql += string.Join(" , ", lw);
  9861. sql += " FROM ";
  9862. sql += string.Join(" , ", ww);
  9863. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9864. }
  9865. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9866. }
  9867. public void get_center_data_list()
  9868. {
  9869. int userId = CurrentUser.UserID;
  9870. string postCode = CurrentUser.UserPost.Post.Code;
  9871. string shopIds = CurrentUser.User.pemShop;
  9872. DataStruct dStruct = GetPostStruct();
  9873. List<string> lw = new List<string>();
  9874. DateTime currentTime = DateTime.Now;
  9875. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9876. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9877. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9878. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9879. string startTime = "2023-10-01 11:22:31";
  9880. int order_type = GetPostInt("order_type");
  9881. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9882. {
  9883. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9884. if (order_type == 0)
  9885. {
  9886. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9887. }
  9888. else if (order_type == 3)
  9889. {
  9890. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9891. }
  9892. else
  9893. {
  9894. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9895. }
  9896. }
  9897. //客服
  9898. if (postCode == "CustomerService" || postCode == "Director")
  9899. {
  9900. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9901. if (order_type == 0)
  9902. {
  9903. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9904. }
  9905. else if (order_type == 1)
  9906. {
  9907. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9908. }
  9909. else if (order_type == 2)
  9910. {
  9911. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9912. }
  9913. else if (order_type == 3)
  9914. {
  9915. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9916. }
  9917. else if (order_type == 4)
  9918. {
  9919. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9920. }
  9921. else
  9922. {
  9923. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9924. }
  9925. }
  9926. //售后
  9927. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9928. {
  9929. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9930. if (shopIds != "")
  9931. {
  9932. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9933. }
  9934. if (order_type == 2)
  9935. {
  9936. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9937. }
  9938. else if (order_type == 4)
  9939. {
  9940. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9941. }
  9942. else if (order_type == 5)
  9943. {
  9944. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9945. }
  9946. else
  9947. {
  9948. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9949. }
  9950. }
  9951. //下单部
  9952. if (postCode == "Place" || postCode == "PlaceMr")
  9953. {
  9954. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9955. if (shopIds != "")
  9956. {
  9957. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9958. }
  9959. else if (order_type == 1)
  9960. {
  9961. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9962. }
  9963. else if (order_type == 2)
  9964. {
  9965. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9966. }
  9967. else
  9968. {
  9969. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9970. }
  9971. }
  9972. //车间
  9973. if (postCode == "Supplier")
  9974. {
  9975. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9976. if (order_type == 5)
  9977. {
  9978. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9979. }
  9980. else
  9981. {
  9982. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9983. }
  9984. }
  9985. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9986. dStruct.Fileds = "tid,ctid";
  9987. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9988. writeGridDataTableJson(dStruct.TotalCount, dt);
  9989. }
  9990. public void aftersale_audit_master()
  9991. {
  9992. if (UrlPostParmsCheck("ctid"))
  9993. {
  9994. string ctid = GetPostString("ctid");
  9995. if (ctid.Length > 0)
  9996. {
  9997. bool result = aftersale_data_change(ctid);
  9998. if (result)
  9999. {
  10000. returnSuccessMsg("修改成功!");
  10001. return;
  10002. }
  10003. }
  10004. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10005. }
  10006. }
  10007. public void aftersale_batch_audit_master()
  10008. {
  10009. if (UrlPostParmsCheck("ctids"))
  10010. {
  10011. string ctids = GetPostString("ctids");
  10012. if (ctids.Length > 0)
  10013. {
  10014. List<string> list = new List<string>();
  10015. string[] ctid_list = ctids.Split(',');
  10016. foreach (var item in ctid_list)
  10017. {
  10018. bool result = aftersale_data_change(item);
  10019. if (!result)
  10020. {
  10021. list.Add(item);
  10022. }
  10023. }
  10024. if (list.Count > 0)
  10025. {
  10026. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10027. return;
  10028. }
  10029. returnSuccessMsg("修改成功!");
  10030. return;
  10031. }
  10032. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10033. }
  10034. }
  10035. public bool aftersale_data_change(string ctid)
  10036. {
  10037. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10038. if (ceErpTradeCell != null)
  10039. {
  10040. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10041. ceErpTradeCell.AfterSaleSupplierState = 0;
  10042. StringBuilder sql = new StringBuilder();
  10043. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10044. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10045. CeErpTradeResponsible.DelByTid(ctid, 0);
  10046. 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 == "不理赔")
  10047. {
  10048. CeErpTradeResponsible.DelByTid(ctid, 1);
  10049. ceErpTradeCell.AfterSaleSupplierState = 1;
  10050. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10051. ceErpTradeCell.AfterSaleState = 4;
  10052. }
  10053. else
  10054. {
  10055. ceErpTradeCell.AfterSaleState = 3;
  10056. }
  10057. bool needCyt = false;
  10058. if (dt != null)
  10059. {
  10060. if (dt.Rows.Count == 1)
  10061. {
  10062. bool isEnd = false;
  10063. foreach (DataRow dr in dt.Rows)
  10064. {
  10065. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10066. {
  10067. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10068. isEnd = true;
  10069. }
  10070. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10071. {
  10072. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10073. isEnd = true;
  10074. }
  10075. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10076. {
  10077. needCyt = true;
  10078. }
  10079. }
  10080. if (isEnd)
  10081. {
  10082. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10083. ceErpTradeCell.AfterSaleState = 4;
  10084. ceErpTradeCell.AfterSaleSupplierState = 1;
  10085. }
  10086. }
  10087. else
  10088. {
  10089. bool isAll = true;
  10090. foreach (DataRow dr in dt.Rows)
  10091. {
  10092. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10093. {
  10094. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10095. continue;
  10096. }
  10097. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10098. {
  10099. string path = "";
  10100. int OrgID = 0;
  10101. if (!Convert.IsDBNull(dr["OrgPath"]))
  10102. {
  10103. path = dr["OrgPath"].ToString();
  10104. }
  10105. if (!Convert.IsDBNull(dr["OrgID"]))
  10106. {
  10107. OrgID = Convert.ToInt32(dr["OrgID"]);
  10108. }
  10109. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10110. {
  10111. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10112. continue;
  10113. }
  10114. }
  10115. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10116. {
  10117. needCyt = true;
  10118. }
  10119. isAll = false;
  10120. }
  10121. if (isAll)
  10122. {
  10123. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10124. ceErpTradeCell.AfterSaleState = 4;
  10125. ceErpTradeCell.AfterSaleSupplierState = 1;
  10126. }
  10127. }
  10128. }
  10129. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10130. {
  10131. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10132. }
  10133. if (ceErpTradeCell.AfterSaleState == 4)
  10134. {
  10135. ApiVo apiVo = new ApiVo();
  10136. apiVo.orderNumber = ceErpTradeCell.ctid;
  10137. apiVo.actionName = "afterOver";
  10138. designHelper.API_WorkCore(apiVo); //afterOver
  10139. }
  10140. ceErpTradeCell.Update();
  10141. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10142. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10143. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10144. return true;
  10145. }
  10146. return false;
  10147. }
  10148. public void get_erp_wechatorder()
  10149. {
  10150. DataStruct dStruct = GetPostStruct();
  10151. List<string> lw = new List<string>();
  10152. string tid = GetPostString("tid");
  10153. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10154. string shopname = GetPostString("shopname");
  10155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10156. string buyernick = GetPostString("buyer_nick");
  10157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10158. string customer = GetPostString("customer");
  10159. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10160. string returndate1 = GetPostString("returndate1");
  10161. string returndate2 = GetPostString("returndate2");
  10162. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10163. if (dw.Length > 0) lw.Add(dw);
  10164. string finishDate1 = GetPostString("finishdate1");
  10165. string finishDate2 = GetPostString("finishdate2");
  10166. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10167. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10168. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10169. dStruct.Order = "created desc";
  10170. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10171. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10172. writeGridDataTableJson(dStruct.TotalCount, dt);
  10173. }
  10174. public void get_erp_wechatlist_sumprice()
  10175. {
  10176. DataStruct dStruct = GetPostStruct();
  10177. List<string> lw = new List<string>();
  10178. string tid = GetPostString("tid");
  10179. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10180. string shopname = GetPostString("shopname");
  10181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10182. string buyernick = GetPostString("buyer_nick");
  10183. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10184. string customer = GetPostString("customer");
  10185. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10186. string returndate1 = GetPostString("returndate1");
  10187. string returndate2 = GetPostString("returndate2");
  10188. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10189. if (dw.Length > 0) lw.Add(dw);
  10190. string finishDate1 = GetPostString("finishdate1");
  10191. string finishDate2 = GetPostString("finishdate2");
  10192. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10193. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10194. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10195. string mainWhere = string.Join(" and ", lw.ToArray());
  10196. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10197. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10198. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10199. decimal total = 0;
  10200. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10201. {
  10202. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10203. }
  10204. var res = new
  10205. {
  10206. data = total
  10207. };
  10208. string ro_jsond = JsonConvert.SerializeObject(res);
  10209. returnSuccess(ro_jsond);
  10210. return;
  10211. }
  10212. public void get_erp_qr_waitdeliverylist()
  10213. {
  10214. DataStruct dStruct = GetPostStruct();
  10215. List<string> lw = new List<string>();
  10216. string tid = GetPostString("ctid");
  10217. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10218. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10219. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10220. var res_objz = new
  10221. {
  10222. restype = 1,
  10223. data = dt
  10224. };
  10225. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10226. returnSuccess(ro_jsonz);
  10227. }
  10228. public void get_erp_yield_list()
  10229. {
  10230. DataStruct dStruct = GetPostStruct();
  10231. List<string> lw = new List<string>();
  10232. string tid = GetPostString("ctid");
  10233. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10234. string shopname = GetPostString("shopname");
  10235. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10236. string buyernick = GetPostString("buyer_nick");
  10237. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10238. //if (tid.Length == 0 && buyernick.Length == 0)
  10239. //{
  10240. // lw.Add(string.Format("IsRefund<={0}", 1));
  10241. //}
  10242. string customer = GetPostString("customer");
  10243. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10244. string design = GetPostString("design");
  10245. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10246. string orderState = GetPostString("orderState");
  10247. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10248. string address = GetPostString("address");
  10249. 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));
  10250. string sellermemo = GetPostString("seller_memo");
  10251. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10252. string supplier = GetPostString("supplier");
  10253. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10254. string OrderArea = GetPostString("order_area");
  10255. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10256. string placedate1 = GetPostString("placedate1");
  10257. string placedate2 = GetPostString("placedate2");
  10258. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10259. if (fdw.Length > 0) lw.Add(fdw);
  10260. string price1 = GetPostString("price1");
  10261. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10262. string price2 = GetPostString("price2");
  10263. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10264. string unusualCon = GetPostString("unusualcon");
  10265. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10266. string posTag = CurrentUser.UserPost.Post.Code;
  10267. if (posTag == "Supplier")
  10268. {
  10269. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10270. }
  10271. lw.Add(string.Format("OrderState = 6 "));
  10272. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10273. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10274. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10275. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10276. writeGridDataTableJson(dStruct.TotalCount, dt);
  10277. }
  10278. public void change_erp_sup_state()
  10279. {
  10280. if (UrlPostParmsCheck("ctid"))
  10281. {
  10282. string ctid = GetPostString("ctid");
  10283. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10284. if (ceErpTradeCell != null)
  10285. {
  10286. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10287. if (ceErpTradeCellExtend == null)
  10288. {
  10289. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10290. ceErpTradeCellExtend.ctid = ctid;
  10291. ceErpTradeCellExtend.SupState = 1;
  10292. ceErpTradeCellExtend.Create();
  10293. }
  10294. else
  10295. {
  10296. ceErpTradeCellExtend.SupState = 1;
  10297. ceErpTradeCellExtend.Update();
  10298. }
  10299. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10300. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10301. return;
  10302. }
  10303. returnErrorMsg("找不到订单");
  10304. }
  10305. }
  10306. public void supplier_all_downs()
  10307. {
  10308. if (UrlPostParmsCheck("tids"))
  10309. {
  10310. string tids = GetPostString("tids");
  10311. if (tids != null && tids.Length > 0)
  10312. {
  10313. StringBuilder sql = new StringBuilder();
  10314. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10315. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10316. sql = new StringBuilder();
  10317. 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, "下载设计文件");
  10318. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10319. string[] list = tids.Split(',');
  10320. foreach (string ctid in list)
  10321. {
  10322. CeErpSukuraData.createInfo(ctid, 3);
  10323. }
  10324. designHelper.api_approveDesign(tids); //approveDesign
  10325. returnSuccessMsg("下载成功!");
  10326. return;
  10327. }
  10328. returnErrorMsg("下载订单更新失败");
  10329. }
  10330. }
  10331. public void uploaderFileSuccess()
  10332. {
  10333. if (UrlPostParmsCheck("fileName"))
  10334. {
  10335. string fileName = GetPostString("fileName");
  10336. ApiVo apiVo = new ApiVo();
  10337. apiVo.orderNumber = fileName;
  10338. apiVo.actionName = "finishDesign";
  10339. designHelper.API_WorkCore(apiVo);//finishDesign
  10340. returnSuccessMsg("");
  10341. }
  10342. }
  10343. public void get_sample2_order()
  10344. {
  10345. if (UrlPostParmsCheck("ctid"))
  10346. {
  10347. string ctid = GetPostString("ctid");
  10348. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10349. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10350. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10351. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10352. double total = 0.0;
  10353. double order_price = 0.0;
  10354. if (dt_bu.Rows.Count > 0)
  10355. {
  10356. foreach (DataRow dr in dt_bu.Rows)
  10357. {
  10358. total += Convert.ToDouble(dr["payment"]);
  10359. }
  10360. }
  10361. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10362. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10363. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10364. string tid = ctid.Replace("S_", "");
  10365. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10366. double paymant = 0.0;
  10367. if (entity != null)
  10368. {
  10369. paymant = entity.payment;
  10370. }
  10371. string return_reason = "";
  10372. if (dt_after != null && dt_after.Rows.Count > 0)
  10373. {
  10374. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10375. }
  10376. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10377. }
  10378. }
  10379. public void get_erp_design_status()
  10380. {
  10381. string designName = GetPostString("designName");
  10382. DataStruct dStruct = GetPostStruct();
  10383. if (designName.Length > 0)
  10384. {
  10385. 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";
  10386. sql_user += " and Name like '%" + designName + "%'";
  10387. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10388. List<string> ids_list = new List<string>();
  10389. if (user_table.Rows.Count > 0)
  10390. {
  10391. foreach (DataRow item in user_table.Rows)
  10392. {
  10393. ids_list.Add(item["id"].ToString());
  10394. string ids_s = item["TeamIds"].ToString();
  10395. if (ids_s.Length > 0)
  10396. {
  10397. ids_list.AddRange(ids_s.Split(','));
  10398. }
  10399. }
  10400. }
  10401. HashSet<string> set = new HashSet<string>(ids_list);
  10402. ids_list = set.ToList();
  10403. if (ids_list.Count > 0)
  10404. {
  10405. 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));
  10406. dStruct.MainWhere = sql;
  10407. DataTable dt = null;
  10408. dt = WebCache.GetData("view_ErpUser", dStruct);
  10409. writeGridDataTableJson(dStruct.TotalCount, dt);
  10410. }
  10411. }
  10412. }
  10413. public void change_erp_order_price()
  10414. {
  10415. string ctid = GetPostString("ctid");
  10416. double price = GetPostDouble("price");
  10417. if (ctid.Length > 0)
  10418. {
  10419. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10420. if (ceErpTradeCellExtend == null)
  10421. {
  10422. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10423. ceErpTradeCellExtend.ctid = ctid;
  10424. ceErpTradeCellExtend.payment_cyt = price;
  10425. ceErpTradeCellExtend.Create();
  10426. }
  10427. else
  10428. {
  10429. ceErpTradeCellExtend.payment_cyt = price;
  10430. ceErpTradeCellExtend.Update();
  10431. }
  10432. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10433. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10434. {
  10435. ceErpDataSendOrderInfo.isSync = false;
  10436. ceErpDataSendOrderInfo.Update();
  10437. }
  10438. if (ceErpDataSendOrderInfo == null)
  10439. {
  10440. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10441. ceErpDataSendOrderInfo.isSync = false;
  10442. ceErpDataSendOrderInfo.ctid = ctid;
  10443. ceErpDataSendOrderInfo.Create();
  10444. }
  10445. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10446. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10447. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10448. if (dth != null && dth.Rows.Count > 0)
  10449. {
  10450. dataSendOrderBean dataSendOrderBean = null;
  10451. foreach (DataRow item in dth.Rows)
  10452. {
  10453. try
  10454. {
  10455. dataSendOrderBean = new dataSendOrderBean();
  10456. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10457. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10458. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10459. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10460. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10461. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10462. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10463. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10464. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10465. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10466. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10467. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10468. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10469. if (result != null)
  10470. {
  10471. if ("0".Equals(result.errcode))
  10472. {
  10473. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10474. }
  10475. else
  10476. {
  10477. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10478. }
  10479. }
  10480. }
  10481. catch (Exception ex)
  10482. {
  10483. }
  10484. }
  10485. }
  10486. returnSuccessMsg("修改成功!");
  10487. return;
  10488. }
  10489. returnErrorMsg("找不到订单");
  10490. }
  10491. public void find_he_together()
  10492. {
  10493. string ctid = GetPostString("ctid");
  10494. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10495. List<string> list = new List<string>();
  10496. if (ceErpTradeCell != null)
  10497. {
  10498. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10499. {
  10500. 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);
  10501. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10502. if (table != null && table.Rows.Count > 0)
  10503. {
  10504. foreach (TableRow row in table.Rows)
  10505. {
  10506. }
  10507. }
  10508. }
  10509. }
  10510. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10511. }
  10512. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10513. {
  10514. //chy----19
  10515. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10516. //GD-CYT-----64
  10517. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10518. //ZHX----3
  10519. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10520. //JK----97
  10521. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10522. //ZT----70
  10523. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10524. //LHCY-----98
  10525. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10526. //XD-----90
  10527. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10528. //CYCY-----14
  10529. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10530. };
  10531. //其他改名
  10532. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10533. {
  10534. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10535. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10536. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10537. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10538. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10539. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10540. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10541. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10542. };
  10543. //不统计
  10544. List<int> no_suppliers = new List<int>()
  10545. {
  10546. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10547. };
  10548. //配件单
  10549. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10550. {
  10551. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10552. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10553. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10554. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10555. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10556. {"旗杆",new List<string>(){ "班旗" } },
  10557. {"牙签",new List<string>(){ "不干胶" } }
  10558. };
  10559. public void get_place_order_data()
  10560. {
  10561. string date1 = GetPostString("date1");
  10562. string date2 = GetPostString("date2");
  10563. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10564. DateTime start = DateTime.Parse(starttime);
  10565. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10566. DateTime end = DateTime.Parse(endtime);
  10567. if (date1 != null && date1.Length > 0)
  10568. {
  10569. DateTime dateTime = DateTime.Parse(date1);
  10570. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10571. start = DateTime.Parse(starttime);
  10572. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10573. end = DateTime.Parse(endtime);
  10574. }
  10575. if (date2 != null && date2.Length > 0)
  10576. {
  10577. DateTime dateTime = DateTime.Parse(date2);
  10578. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10579. end = DateTime.Parse(endtime);
  10580. }
  10581. 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);
  10582. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10583. //不干胶-----1,卡片-----29
  10584. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10585. foreach (DataRow row in data.Rows)
  10586. {
  10587. int productId = Convert.ToInt32(row["ProductId"]);
  10588. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10589. if (no_suppliers.Contains(supplierId))
  10590. {
  10591. continue;
  10592. }
  10593. string seller_memo = row["seller_memo"].ToString();
  10594. bool ispj = false;//是否配件单
  10595. bool isfirst = true;//第一个配
  10596. maps.Keys.ForEach(key =>
  10597. {
  10598. //备注包含配件
  10599. if (seller_memo.Contains(key) && isfirst)
  10600. {
  10601. List<string> list = maps[key];
  10602. ispj = true;
  10603. isfirst = false;
  10604. for (int i = 0; i < list.Count; i++)
  10605. {
  10606. if (seller_memo.Contains(list[i]))
  10607. {
  10608. ispj = false;
  10609. break;
  10610. }
  10611. }
  10612. }
  10613. });
  10614. if (ispj)
  10615. {
  10616. continue;
  10617. }
  10618. seller_memo = seller_memo.Replace("UV", "uv");
  10619. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10620. //吊牌归到卡片
  10621. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10622. seller_memo = seller_memo.Replace("卡套", "卡片");
  10623. seller_memo = seller_memo.Replace("封套", "卡片");
  10624. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10625. seller_memo = seller_memo.Replace("腰封", "卡片");
  10626. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10627. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10628. seller_memo = seller_memo.Replace("横幅", "条幅");
  10629. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10630. string map_key = "";
  10631. string type = "";
  10632. if (supplierMap.ContainsKey(supplierId))
  10633. {
  10634. foreach (var kvp in supplierMap[supplierId])
  10635. {
  10636. if (seller_memo.Contains(kvp.Key))
  10637. {
  10638. map_key = kvp.Value;
  10639. type = kvp.Value;
  10640. break;
  10641. }
  10642. }
  10643. }
  10644. if (map_key == "")
  10645. {
  10646. type = "其他";
  10647. map_key = "其他";
  10648. }
  10649. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10650. {
  10651. map_key = suppliers[supplierId];
  10652. }
  10653. if (supplierId == 70)
  10654. {
  10655. supplierId = 70;
  10656. }
  10657. map_key += "_" + row["SupplierName"].ToString();
  10658. Dictionary<string, int> map = null;
  10659. if (other_map.ContainsKey(map_key))
  10660. {
  10661. other_map.TryGetValue(map_key, out map);
  10662. }
  10663. else
  10664. {
  10665. map = new Dictionary<string, int>();
  10666. map.Add("dayDev", 0);//当天出货
  10667. map.Add("dayTotal", 0);//下单总数
  10668. map.Add("payTotal", 0);//500以上
  10669. map.Add("today", 0);//当天出货数量
  10670. map.Add("unusua", 0);//异常数
  10671. other_map.Add(map_key, map);
  10672. other_map.TryGetValue(map_key, out map);
  10673. }
  10674. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10675. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10676. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10677. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10678. {
  10679. map["dayTotal"]++;
  10680. if (supplierId == 97)
  10681. {
  10682. supplierId = 97;
  10683. }
  10684. }
  10685. if (Convert.ToDecimal(row["payment"]) >= 500)
  10686. {
  10687. map["payTotal"]++;
  10688. }
  10689. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10690. {
  10691. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10692. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10693. {
  10694. map["today"]++;
  10695. }
  10696. }
  10697. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10698. {
  10699. map["unusua"]++;
  10700. }
  10701. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10702. //GD-CYT-----64
  10703. DateTime two = palceTimeStart.AddHours(14);
  10704. DateTime three = palceTimeStart.AddHours(15);
  10705. DateTime four = palceTimeStart.AddHours(16);
  10706. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10707. {
  10708. //下午四点前 500-1000
  10709. string count = row["ProductCount"].ToString();
  10710. if (count != null && count.Length > 0)
  10711. {
  10712. int productCount = commonHelper.getPlaceProductCount(count);
  10713. if (productCount >= 500 && productCount <= 1000)
  10714. {
  10715. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10716. {
  10717. map["dayDev"]++;
  10718. }
  10719. }
  10720. }
  10721. }
  10722. //UV
  10723. else if ("uv".Equals(type))
  10724. {
  10725. //ZT----70
  10726. //ZHX----3
  10727. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10728. {
  10729. map["dayDev"]++;
  10730. }
  10731. //JK----97
  10732. //HZX----105
  10733. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10734. {
  10735. map["dayDev"]++;
  10736. if (supplierId == 97)
  10737. {
  10738. supplierId = 97;
  10739. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10740. }
  10741. }
  10742. }
  10743. //帆布---52|条幅---27
  10744. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10745. {
  10746. //LHCY-----98
  10747. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10748. {
  10749. map["dayDev"]++;
  10750. }
  10751. }
  10752. //条幅
  10753. else if ("条幅".Equals(type))
  10754. {
  10755. //XD-----90
  10756. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10757. {
  10758. map["dayDev"]++;
  10759. }
  10760. }
  10761. //桌布
  10762. else if ("桌布".Equals(type))
  10763. {
  10764. //XD-----90
  10765. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10766. {
  10767. map["dayDev"]++;
  10768. }
  10769. }
  10770. //DL---10
  10771. //AYTW---119
  10772. //FS-CYT-DY ----80
  10773. //JK----97
  10774. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10775. {
  10776. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10777. {
  10778. map["dayDev"]++;
  10779. }
  10780. }
  10781. }
  10782. DataTable dt = new DataTable();
  10783. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10784. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10785. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10786. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10787. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10788. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10789. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10790. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10791. other_map.Keys.ForEach(key =>
  10792. {
  10793. DataRow dr = dt.NewRow();
  10794. Dictionary<string, int> map = other_map[key];
  10795. string[] key_list = key.Split('_');
  10796. dr[0] = key_list[0];
  10797. dr[1] = key_list[1];
  10798. if (key_list.Length > 2)
  10799. {
  10800. dr[1] += "(" + key_list[2] + ")";
  10801. }
  10802. dr[2] = map["dayTotal"];
  10803. dr[3] = map["payTotal"];
  10804. dr[4] = map["today"];
  10805. dr[5] = map["unusua"];
  10806. dr[6] = map["dayDev"];
  10807. double rate = 0.00;
  10808. if (map["dayDev"] > 0)
  10809. {
  10810. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10811. }
  10812. dr[7] = rate.ToString();
  10813. dt.Rows.Add(dr);
  10814. });
  10815. DataView dv = new DataView(dt);
  10816. dv.Sort = "SupplierName";
  10817. //dv.Sort = "AllOrder desc";
  10818. DataTable dtNew = dv.ToTable();
  10819. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10820. }
  10821. public void check_order_desing_info()
  10822. {
  10823. string ctid = GetPostString("ctid");
  10824. if (!string.IsNullOrEmpty(ctid))
  10825. {
  10826. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10827. if (ceErpTradeCell != null)
  10828. {
  10829. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10830. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10831. return;
  10832. }
  10833. returnErrorMsg("找不到订单");
  10834. return;
  10835. }
  10836. returnErrorMsg("找不到订单");
  10837. }
  10838. public void get_timeout_detail()
  10839. {
  10840. string poscode = CurrentUser.UserPost.Post.Code;
  10841. DataStruct dStruct = GetPostStruct();
  10842. List<string> lw = new List<string>();
  10843. string id = GetPostString("id");
  10844. string pay_date1 = GetPostString("pay_date1");
  10845. string pay_date2 = GetPostString("pay_date2");
  10846. int type = GetPostInt("type");
  10847. if (type == 0)
  10848. {
  10849. if (pay_date1.Length > 0)
  10850. {
  10851. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10852. }
  10853. if (pay_date2.Length > 0)
  10854. {
  10855. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10856. }
  10857. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10858. }
  10859. if (type == 1)
  10860. {
  10861. if (pay_date1.Length > 0)
  10862. {
  10863. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10864. }
  10865. if (pay_date2.Length > 0)
  10866. {
  10867. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10868. }
  10869. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10870. }
  10871. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10872. DataTable dt = null;
  10873. dt = WebCache.GetData("view_orderlist", dStruct);
  10874. writeGridDataTableJson(dStruct.TotalCount, dt);
  10875. }
  10876. public void saveUrgentChargePrice()
  10877. {
  10878. string ctid = GetPostString("ctid");
  10879. if (!string.IsNullOrEmpty(ctid))
  10880. {
  10881. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10882. if (ceErpTradeCell != null)
  10883. {
  10884. double price = GetPostDouble("price");
  10885. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10886. if (ceErpTradeCellExtend == null)
  10887. {
  10888. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10889. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10890. }
  10891. ceErpTradeCellExtend.urgentCharge = price;
  10892. if (ceErpTradeCellExtend.ID > 0)
  10893. {
  10894. ceErpTradeCellExtend.Update();
  10895. }
  10896. else
  10897. {
  10898. ceErpTradeCellExtend.Save();
  10899. }
  10900. returnSuccessMsg("修改成功!");
  10901. return;
  10902. }
  10903. returnErrorMsg("找不到订单");
  10904. return;
  10905. }
  10906. returnErrorMsg("找不到订单");
  10907. }
  10908. public void finish_erp_order()
  10909. {
  10910. string ctid = GetPostString("ctid");
  10911. if (!string.IsNullOrEmpty(ctid))
  10912. {
  10913. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10914. {
  10915. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10916. if (ceErpTradeCell != null)
  10917. {
  10918. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10919. ceErpTradeCell.Update();
  10920. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10921. returnSuccessMsg("修改成功!");
  10922. return;
  10923. }
  10924. }
  10925. }
  10926. returnErrorMsg("找不到订单");
  10927. }
  10928. public void get_trade_order_list()
  10929. {
  10930. string tid = GetPostString("tid");
  10931. if (!string.IsNullOrEmpty(tid))
  10932. {
  10933. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10934. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10935. writeGridDataTableJson(data.Rows.Count, data);
  10936. return;
  10937. }
  10938. returnErrorMsg("找不到订单");
  10939. }
  10940. public void save_cell_spu()
  10941. {
  10942. string ctid = GetPostString("ctid");
  10943. string spu_id = GetPostString("spu_id");
  10944. if (!string.IsNullOrEmpty(ctid))
  10945. {
  10946. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10947. if (ceErpTradeCellExtend == null)
  10948. {
  10949. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10950. ceErpTradeCellExtend.ctid = ctid;
  10951. }
  10952. ceErpTradeCellExtend.spu_id = spu_id;
  10953. if (ceErpTradeCellExtend.ID == 0)
  10954. {
  10955. ceErpTradeCellExtend.Create();
  10956. }
  10957. else
  10958. {
  10959. ceErpTradeCellExtend.Update();
  10960. }
  10961. returnSuccessMsg("修改成功!");
  10962. return;
  10963. }
  10964. returnErrorMsg("找不到订单");
  10965. }
  10966. public void change_express_info()
  10967. {
  10968. string ctid = GetPostString("ctid");
  10969. string transNo = GetPostString("transNo");
  10970. string transCom = GetPostString("transCom");
  10971. if (!string.IsNullOrEmpty(ctid))
  10972. {
  10973. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10974. if (ceErpTradeCellExtend == null)
  10975. {
  10976. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10977. ceErpTradeCellExtend.ctid = ctid;
  10978. }
  10979. ceErpTradeCellExtend.modExpressNo = transNo;
  10980. ceErpTradeCellExtend.modExpressCom = transCom;
  10981. ceErpTradeCellExtend.readMod = 2;
  10982. if (ceErpTradeCellExtend.ID == 0)
  10983. {
  10984. ceErpTradeCellExtend.Create();
  10985. }
  10986. else
  10987. {
  10988. ceErpTradeCellExtend.Update();
  10989. }
  10990. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10991. returnSuccessMsg("修改成功!");
  10992. return;
  10993. }
  10994. returnErrorMsg("找不到订单");
  10995. }
  10996. public void get_change_express_list()
  10997. {
  10998. DataStruct dStruct = GetPostStruct();
  10999. List<string> lw = new List<string>();
  11000. int st = 2;
  11001. string tid = GetPostString("ctid");
  11002. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  11003. string shopname = GetPostString("shopname");
  11004. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11005. string buyernick = GetPostString("buyer_nick");
  11006. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11007. string sellermemo = GetPostString("seller_memo");
  11008. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11009. string supplier = GetPostString("supplier");
  11010. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11011. string customer = GetPostString("customer");
  11012. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11013. string design = GetPostString("design");
  11014. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11015. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11016. string poscode = CurrentUser.UserPost.Post.Code;
  11017. if (poscode != "SysAdmin")
  11018. {
  11019. string shopid = CurrentUser.User.pemShop;
  11020. lw.Add(string.Format("shopId in ({0})", shopid));
  11021. }
  11022. lw.Add("readMod = 2");
  11023. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11024. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11025. writeGridDataTableJson(dStruct.TotalCount, dt);
  11026. }
  11027. public void deal_express_complete()
  11028. {
  11029. string ctid = GetPostString("ctid");
  11030. if (!string.IsNullOrEmpty(ctid))
  11031. {
  11032. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11033. if (ceErpTradeCellExtend == null)
  11034. {
  11035. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11036. ceErpTradeCellExtend.ctid = ctid;
  11037. }
  11038. ceErpTradeCellExtend.readMod = 1;
  11039. if (ceErpTradeCellExtend.ID == 0)
  11040. {
  11041. ceErpTradeCellExtend.Create();
  11042. }
  11043. else
  11044. {
  11045. ceErpTradeCellExtend.Update();
  11046. }
  11047. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11048. returnSuccessMsg("修改成功!");
  11049. return;
  11050. }
  11051. returnErrorMsg("找不到订单");
  11052. }
  11053. public void aftersale_return_visit()
  11054. {
  11055. string ctid = GetPostString("ctid");
  11056. if (!string.IsNullOrEmpty(ctid))
  11057. {
  11058. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11059. if (ceErpTradeCellExtend == null)
  11060. {
  11061. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11062. ceErpTradeCellExtend.ctid = ctid;
  11063. }
  11064. ceErpTradeCellExtend.returnVisit = 1;
  11065. if (ceErpTradeCellExtend.ID == 0)
  11066. {
  11067. ceErpTradeCellExtend.Create();
  11068. }
  11069. else
  11070. {
  11071. ceErpTradeCellExtend.Update();
  11072. }
  11073. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11074. if (ceErpTradeAfterSaleExtend != null)
  11075. {
  11076. ceErpTradeAfterSaleExtend.TextResult = "";
  11077. ceErpTradeAfterSaleExtend.Update();
  11078. }
  11079. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11080. returnSuccessMsg("修改成功!");
  11081. return;
  11082. }
  11083. returnErrorMsg("找不到订单");
  11084. }
  11085. public void orderPlaceInfo()
  11086. {
  11087. string ctids = GetPostString("ctids");
  11088. string[] list = ctids.Split(',');
  11089. foreach (string ctid in list)
  11090. {
  11091. CeErpSukuraData.createInfo(ctid, 3);
  11092. }
  11093. designHelper.api_approveDesign(ctids); //approveDesign
  11094. returnSuccessMsg("");
  11095. }
  11096. }
  11097. }