sync.order.cs 648 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. namespace SiteCore.Handler
  51. {
  52. public partial class sync
  53. {
  54. public void get_erp_orderlist()
  55. {
  56. string poscode = CurrentUser.UserPost.Post.Code;
  57. DataStruct dStruct = GetPostStruct();
  58. //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
  59. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\uv特殊工艺价格(1).xls");
  60. //apiHelper.Api_SyncOrderByTime("598825");
  61. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  62. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  63. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  64. //banniuApiHelper.sendLogisticsInfo(null);
  65. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  66. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  67. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  68. //int sid = commonHelper.autoDistributeToSupplier(entity);
  69. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  70. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1752654175000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1752826970000,\"lines\":[{\"latestDeliveryTime\":1752826970000,\"mark2\":[],\"num\":23,\"outerId\":\"DGCP\",\"payment\":460.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2200806677467/O1CN01Wlpmej251wOGAuYd2_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":20.0,\"refOlId\":\"4634728491992436446\",\"refSkuId\":\"0\",\"refSpuId\":\"617207822351\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":20.0,\"singleFee\":20.0,\"spuOuterId\":\"DGCP\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"蛋糕logo插牌定制烘焙店插卡插排生日小卡片装饰甜品标签插件设计\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1752658857000,\"openBuyerId\":\"AAHqRHraABkUZRPgSx1P9I8b\",\"openBuyerNick\":\"b**\",\"openSellerNick\":\"翊喜旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1752654168000,\"payTime\":1752654170000,\"payment\":460.0,\"platServiceFee\":0.0,\"posCode\":\"yixi\",\"posId\":598788,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"佛山市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"禅城区\",\"receiverId\":\"882d7aaecddc7a9698cc36e36a46ba24$\",\"receiverState\":\"广东省\",\"receiverTown\":\"石湾镇街道\",\"refOid\":\"4634728491992436446\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"60x12mm-2款各500张-插卡-350克铜板纸-直角单面烫金模切-bowie_s-英子-240元-(纯烫金)-老客户204.02.20,40x40mm-2000张-插卡-350克铜板纸-方形直角裁切-bowie_s-英子-220元--老客户2024.02.20\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":460.0,\"totalPrice\":460.0,\"totalSellPrice\":460.0,\"type\":\"SALE\"}}");
  71. //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}}");
  72. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  73. //commonHelper.loginGetOrder(2152);
  74. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  75. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  76. List<string> lw = new List<string>();
  77. string tid = GetPostString("ctid");
  78. string date1 = GetPostString("date1");
  79. //12-1 修改
  80. string urgent = GetPostString("urgent");
  81. string back = GetPostString("back");
  82. string offlineSearch = GetPostString("offlineSearch");
  83. int paramsCount = 0;
  84. if (!string.IsNullOrWhiteSpace(urgent))
  85. {
  86. if (urgent.Equals("true"))
  87. {
  88. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  89. }
  90. }
  91. if (!string.IsNullOrWhiteSpace(back))
  92. {
  93. if (back.Equals("true"))
  94. {
  95. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  96. }
  97. }
  98. if (!string.IsNullOrWhiteSpace(offlineSearch))
  99. {
  100. if (offlineSearch.Equals("true"))
  101. {
  102. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  103. }
  104. }
  105. //end
  106. string date2 = GetPostString("date2");
  107. string buyernick = GetPostString("buyer_nick");
  108. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  109. {
  110. if (tid.Length <= 0 && buyernick.Length <= 0)
  111. {
  112. return;
  113. }
  114. }
  115. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  116. {
  117. if (tid.Length > 0)
  118. {
  119. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  120. if (ceErpTradeCell != null)
  121. {
  122. tid = ceErpTradeCell.tid;
  123. }
  124. List<string> select_tid = getTidByCtidMore(tid);
  125. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  126. }
  127. if (buyernick.Length > 0)
  128. {
  129. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  130. }
  131. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  132. if (dw.Length > 0)
  133. {
  134. lw.Add(dw);
  135. }
  136. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  137. {
  138. string usershop = CurrentUser.User.pemShop;
  139. lw.Add(string.Format("ShopId in ({0})", usershop));
  140. }
  141. }
  142. else
  143. {
  144. if (ex_psize == 0)
  145. {
  146. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  147. }
  148. if (PKey != "admin" && poscode != "SysAdmin")
  149. {
  150. string usershop = CurrentUser.User.pemShop;
  151. lw.Add(string.Format("ShopId in ({0})", usershop));
  152. paramsCount++;
  153. }
  154. }
  155. string uploaddate1 = GetPostString("uploaddate1");
  156. string uploaddate2 = GetPostString("uploaddate2");
  157. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  158. if (update.Length > 0) lw.Add(update);
  159. string deliverydate1 = GetPostString("deliverydate1");
  160. string deliverydate2 = GetPostString("deliverydate2");
  161. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  162. if (deliverydate.Length > 0)
  163. {
  164. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  165. };
  166. string shopname = GetPostString("shopname");
  167. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  168. string addwechat = GetPostString("addwechat");
  169. if (addwechat.Length > 0)
  170. {
  171. int addWt = Convert.ToInt32(addwechat);
  172. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  173. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  174. }
  175. string customer = GetPostString("customer");
  176. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  177. string design = GetPostString("design");
  178. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  179. string orderState = GetPostString("orderState");
  180. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  181. string address = GetPostString("address");
  182. 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));
  183. string sellermemo = GetPostString("seller_memo");
  184. if (sellermemo.Length > 0)
  185. {
  186. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  187. }
  188. string backReason = GetPostString("backReason");
  189. if (backReason.Length > 0)
  190. {
  191. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  192. }
  193. string apdate1 = GetPostString("apdate1");
  194. string apdate2 = GetPostString("apdate2");
  195. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  196. if (dwap.Length > 0) lw.Add(dwap);
  197. string price1 = GetPostString("price1");
  198. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  199. string price2 = GetPostString("price2");
  200. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  201. string isoldcustomer = GetPostString("isoldcus");
  202. string spudata = GetPostString("spudata");
  203. if ("0".Equals(spudata))
  204. {
  205. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  206. }
  207. if ("1".Equals(spudata))
  208. {
  209. lw.Add(string.Format("spu_id <> ''"));
  210. }
  211. string finishdate1 = GetPostString("finishdate1");
  212. string finishdate2 = GetPostString("finishdate2");
  213. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  214. bool isFinish = false;
  215. if (finishdate.Length > 0)
  216. {
  217. lw.Add(finishdate);
  218. isFinish = true;
  219. paramsCount++;
  220. }
  221. if (isoldcustomer.Length > 0)
  222. {
  223. if ("2".Equals(isoldcustomer))
  224. {
  225. lw.Add(string.Format("VipCustomer=1"));
  226. }
  227. else
  228. {
  229. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  230. }
  231. }
  232. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  233. if (ex_psize > 0)
  234. {
  235. int UserID = CurrentUser.UserID;
  236. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  237. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  238. {
  239. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  240. }
  241. dStruct.Order = "pay_time desc";
  242. }
  243. string isNew = GetPostString("isNew");
  244. if (isNew == "true")
  245. {
  246. lw.Add(string.Format("IsNew = {0}", 1));
  247. }
  248. string overtime = GetPostString("overtime");
  249. if (overtime == "1")
  250. {
  251. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  252. }
  253. String usePost = CurrentUser.UserPost.Post.Code;
  254. if (usePost.Equals("Operation") == true)
  255. {
  256. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  257. }
  258. else
  259. {
  260. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  261. }
  262. //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";
  263. if (dStruct.PageSize == 100000)
  264. {
  265. dStruct.Order = "";
  266. }
  267. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  268. DataTable dt = null;
  269. string tablename = "view_orderlist";
  270. if (isFinish)
  271. {
  272. tablename = "view_orderlist_end";
  273. }
  274. dt = WebCache.GetData(tablename, dStruct);
  275. if (dt != null && dt.Rows.Count > 0)
  276. {
  277. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  278. foreach (DataRow dr in dt.Rows)
  279. {
  280. try
  281. {
  282. if (dr["refund_fees"] != null)
  283. {
  284. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  285. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  286. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  287. if (payment == refund_fees)
  288. {
  289. dr["refund_fees"] = Math.Round(refund_fees, 2);
  290. }
  291. else if (refund_fees == total_fee)
  292. {
  293. dr["refund_fees"] = payment;
  294. }
  295. else
  296. {
  297. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  298. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  299. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  300. }
  301. }
  302. // 对象操作
  303. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  304. ceErpTradeCell.ctid = dr["ctid"].ToString();
  305. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  306. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  307. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  308. if (dStruct.PageSize != 100000)
  309. {
  310. if (dr["DispatchSort"].ToString() == "2")
  311. {
  312. dr["gongchuang"] = 200;
  313. }
  314. else if ("外协".Equals(dr["ToType"].ToString()))
  315. {
  316. dr["gongchuang"] = 200;
  317. }
  318. else if ("内部".Equals(dr["ToType"].ToString()))
  319. {
  320. dr["gongchuang"] = -1;
  321. }
  322. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  323. {
  324. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  325. dr["gongchuang"] = response.code;
  326. }
  327. }
  328. }
  329. catch (NullReferenceException ex)
  330. {
  331. // 处理空引用异常
  332. dr["refund_fees"] = "0.00";
  333. }
  334. }
  335. }
  336. writeGridDataTableJson(dStruct.TotalCount, dt);
  337. }
  338. public void get_erp_orderlist_sumprice()
  339. {
  340. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  341. return;
  342. List<string> lw = new List<string>();
  343. string tid = GetPostString("ctid");
  344. string date1 = GetPostString("date1");
  345. string date2 = GetPostString("date2");
  346. if (tid.Length > 0 || date1.Length > 0)
  347. {
  348. lw.Add(string.Format("ctid like '%{0}%'", tid));
  349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  350. if (dw.Length > 0) lw.Add(dw);
  351. }
  352. else
  353. {
  354. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  355. }
  356. string shopname = GetPostString("shopname");
  357. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  358. string buyernick = GetPostString("buyer_nick");
  359. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  360. string customer = GetPostString("customer");
  361. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  362. string design = GetPostString("design");
  363. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  364. string orderState = GetPostString("orderState");
  365. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  366. string address = GetPostString("address");
  367. 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));
  368. string sellermemo = GetPostString("seller_memo");
  369. if (sellermemo.Length > 0)
  370. {
  371. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  372. }
  373. string apdate1 = GetPostString("apdate1");
  374. string apdate2 = GetPostString("apdate2");
  375. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  376. if (dwap.Length > 0) lw.Add(dwap);
  377. string price1 = GetPostString("price1");
  378. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  379. string price2 = GetPostString("price2");
  380. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  381. string isoldcustomer = GetPostString("isoldcus");
  382. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  383. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  384. if (PKey != "admin")
  385. {
  386. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  387. lw.Add(string.Format("shopId in ({0})", usershop));
  388. }
  389. //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";
  390. string mainWhere = string.Join(" and ", lw.ToArray());
  391. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  392. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  393. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  394. decimal total = 0;
  395. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  396. {
  397. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  398. }
  399. var res = new
  400. {
  401. data = total
  402. };
  403. string ro_jsond = JsonConvert.SerializeObject(res);
  404. returnSuccess(ro_jsond);
  405. return;
  406. }
  407. public void get_erp_CustomerServiceGather()
  408. {
  409. string userWhere = "", orderWhere = "";
  410. List<string> lw = new List<string>();
  411. string customer = GetPostString("customer");
  412. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  413. string shopname = GetPostString("shopname");
  414. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  415. string date1 = GetPostString("date1");
  416. string date2 = GetPostString("date2");
  417. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  418. if (dw.Length > 0) lw.Add(dw);
  419. orderWhere = string.Join(" and ", lw.ToArray());
  420. 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 " +
  421. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  422. "left join " +
  423. "( " +
  424. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  425. ") as b on a.ID = b.CustomerUserId " +
  426. "left join " +
  427. "( " +
  428. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  429. ") as d on a.ID = d.CustomerUserId " +
  430. "left join " +
  431. "( " +
  432. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  433. ") as e on a.ID = e.CustomerUserId " +
  434. "left join " +
  435. "( " +
  436. " select CustomerUserId, RefundCount, RefundSum from " +
  437. " ( " +
  438. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  439. " from CE_ErpTradeRefund a " +
  440. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  441. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  442. " group by CustomerUserId " +
  443. " ) as a " +
  444. ") as f on a.ID = f.CustomerUserId " +
  445. "where a.PostCode = 'CustomerService'",
  446. userWhere, orderWhere);
  447. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  448. writeGridDataTableJson(dt.Rows.Count, dt);
  449. //writeGridDataTableJson(dt.Rows.Count, dt);
  450. }
  451. //设计汇总
  452. public void get_erp_DesignerGather()
  453. {
  454. string userWhere = "", orderWhere = "";
  455. List<string> lw = new List<string>();
  456. string Designer = GetPostString("designer");
  457. int org = GetPostInt("org");
  458. if (Designer.Length > 0)
  459. {
  460. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  461. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  462. }
  463. else if (org > 0)
  464. {
  465. userWhere = string.Format(" where OrgID ={0}", org);
  466. }
  467. string shopname = GetPostString("shopname");
  468. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  469. string state = GetPostString("state");
  470. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  471. string OrderArea = GetPostString("order_area");
  472. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  473. string date1 = GetPostString("date1");
  474. string date2 = GetPostString("date2");
  475. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  476. if (dw.Length > 0) lw.Add(dw);
  477. string UpDate1 = GetPostString("UpDate1");
  478. string UpDate2 = GetPostString("UpDate2");
  479. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  480. if (dw.Length > 0) lw.Add(dw);
  481. orderWhere = string.Join(" and ", lw.ToArray());
  482. 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 (" +
  483. "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 " +
  484. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  485. "left join " +
  486. "( " +
  487. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  488. ") as b on a.ID = b.DesignUserId " +
  489. "left join " +
  490. "( " +
  491. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  492. ") as d on a.ID = d.DesignUserId " +
  493. "left join " +
  494. "( " +
  495. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  496. ") as e on a.ID = e.DesignUserId " +
  497. "left join " +
  498. "( " +
  499. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  500. ") as g on a.ID = g.DesignUserId " +
  501. "left join " +
  502. "( " +
  503. " select CustomerUserId, RefundCount, RefundSum from " +
  504. " ( " +
  505. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  506. " from CE_ErpTradeRefund a " +
  507. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  508. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  509. " group by CustomerUserId " +
  510. " ) as a " +
  511. ") as f on a.ID = f.CustomerUserId " +
  512. "where a.PostCode = 'Designer') as z",
  513. userWhere, orderWhere);
  514. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  515. writeGridDataTableJson(dt.Rows.Count, dt);
  516. }
  517. //删除tradecell的订单
  518. public void del_erp_cellorder()
  519. {
  520. if (UrlPostParmsCheck("ctid"))
  521. {
  522. string eid = GetPostString("ctid");
  523. CeErpTradeCell.DelByCtid(eid);
  524. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  525. returnSuccessMsg("删除成功");
  526. }
  527. }
  528. public void clear_erp_refundstate()
  529. {
  530. if (UrlPostParmsCheck("ids"))
  531. {
  532. string eids = GetPostString("ids");
  533. string[] ctidList = eids.Split(',');
  534. foreach (string ctid in ctidList)
  535. {
  536. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  537. if (entity != null)
  538. {
  539. entity.IsRefund = 0;
  540. entity.Update();
  541. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  542. }
  543. else
  544. continue;
  545. }
  546. returnSuccessMsg("操作成功");
  547. return;
  548. }
  549. returnErrorMsg("缺少必要参数");
  550. }
  551. public void set_erp_urgency()
  552. {
  553. if (UrlPostParmsCheck("ctid"))
  554. {
  555. string eid = GetPostString("ctid");
  556. CeErpTradeCell entity = null;
  557. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  558. if (entity != null)
  559. {
  560. double prices = commonHelper.calculationPrice(entity);
  561. if (prices <= 100)
  562. {
  563. returnErrorMsg("此订单金额不足100元,无法加急。");
  564. return;
  565. }
  566. string utime = GetPostString("urgencytime");
  567. if (utime.Length > 0)
  568. {
  569. entity.UrgencyTime = Convert.ToDateTime(utime);
  570. }
  571. else
  572. {
  573. returnErrorMsg("请选择加急时间");
  574. return;
  575. }
  576. if (entity.OrderState <= 4)
  577. {
  578. //entity.seller_memo = entity.seller_memo + "-加急";
  579. string smemo = entity.seller_memo;
  580. int kindex = smemo.IndexOf(")");
  581. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  582. if (lastoneStr != "-")
  583. {
  584. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  585. }
  586. string prememo = smemo.Substring(0, kindex + 2);
  587. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  588. int lastkindex = lastmemo.IndexOf("(");
  589. DateTime urgtime = Convert.ToDateTime(utime);
  590. string newlastmemo = "";
  591. if (lastkindex == 0)
  592. {
  593. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  594. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  595. }
  596. else
  597. {
  598. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  599. }
  600. entity.seller_memo = prememo + newlastmemo;
  601. }
  602. entity.IsUrgency = true;
  603. entity.UpdateTime = DateTime.Now;
  604. entity.Update();
  605. ApiVo apiVo = new ApiVo();
  606. apiVo.orderNumber = entity.ctid;
  607. apiVo.actionName = "changeDesign";
  608. apiVo.orderRemarks = entity.seller_memo;
  609. apiVo.remarkSign = 3;
  610. designHelper.API_WorkCore(apiVo); //changeDesign
  611. CeErpSukuraData.createInfo(entity.ctid, 7);
  612. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  613. returnSuccessMsg("设置成功!");
  614. return;
  615. }
  616. returnErrorMsg("找不到记录");
  617. }
  618. }
  619. public void set_erp_reset()
  620. {
  621. if (UrlPostParmsCheck("ctid"))
  622. {
  623. string eid = GetPostString("ctid");
  624. CeErpTradeCell entity = null;
  625. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  626. if (entity != null)
  627. {
  628. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  629. {
  630. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  631. {
  632. returnErrorMsg("财务要求已下单已发货无法重置");
  633. return;
  634. }
  635. }
  636. entity.IsUrgency = false;
  637. entity.seller_memo = "";
  638. entity.OtherMemo = "";
  639. entity.OrderState = 0;
  640. entity.IsReturn = 0;
  641. //entity.IsRefund = 0;
  642. entity.MemoOpt = 0;
  643. entity.AfterSaleState = 0;
  644. entity.AfterSaleResponsible = "";
  645. entity.AfterSaleUserId = 0;
  646. entity.IsNeedBill = 0;
  647. entity.CustomerUserId = 0;
  648. entity.DesignUserId = 0;
  649. entity.SupplierId = 0;
  650. entity.PlaceUserId = 0;
  651. entity.ptid = "";
  652. entity.IsSample = 0;
  653. entity.IsXianHuo = 0;
  654. entity.isDianziOrder = 0;
  655. entity.DispatchSort = 0;
  656. entity.FinishPlaceTime = null;
  657. entity.Update();
  658. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  659. if (trade != null)
  660. {
  661. trade.seller_memo = "";
  662. trade.Update();
  663. }
  664. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  665. returnSuccessMsg("重置成功!");
  666. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  667. if (desginBill != null)
  668. {
  669. desginBill.isDel = 1;
  670. desginBill.Update();
  671. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  672. }
  673. ApiVo apiVo = new ApiVo();
  674. apiVo.orderNumber = entity.ctid;
  675. apiVo.actionName = "resetDesign";
  676. designHelper.API_WorkCore(apiVo);//resetDesign
  677. return;
  678. }
  679. returnErrorMsg("找不到记录");
  680. }
  681. }
  682. public void save_erp_sellermemo()
  683. {
  684. if (UrlPostParmsCheck("ctid"))
  685. {
  686. string ctid = GetPostString("ctid");
  687. CeErpTradeCell entity = null;
  688. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  689. if (entity != null)
  690. {
  691. string memo = GetPostString("seller_memo");
  692. memo = memo.Replace(" ", "");
  693. if (memo.Contains("补差"))
  694. {
  695. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  696. return;
  697. }
  698. List<string> bitList = new List<string>
  699. {
  700. "\\","/",":","*","?", "\"","<" ,">","|"
  701. };
  702. bool isIn = false;
  703. foreach (string bit in bitList)
  704. {
  705. if (memo.Contains(bit))
  706. {
  707. isIn = true;
  708. }
  709. }
  710. if (isIn)
  711. {
  712. returnErrorMsg("不能使用 一些符合作为文件名");
  713. return;
  714. }
  715. if (entity.seller_memo != memo)
  716. {
  717. if (entity.IsSample == 2)
  718. {
  719. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  720. return;
  721. }
  722. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  723. {
  724. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  725. {
  726. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  727. return;
  728. }
  729. /*if (CurrentUser.UserPost.Post.Code != "Place")
  730. {
  731. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  732. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  733. {
  734. returnErrorMsg("售前系统订单无法再此修改!");
  735. return;
  736. }
  737. }*/
  738. }
  739. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  740. }
  741. commonHelper.getCytPrice(entity);
  742. int memoopt = GetPostInt("MemoOpt");
  743. Boolean ismemoopt = false;
  744. if (memoopt > 0)
  745. {
  746. string stropt = "";
  747. if (memoopt == 1)
  748. {
  749. stropt = "“改稿”";
  750. ismemoopt = true;
  751. }
  752. else if (memoopt == 2)
  753. {
  754. stropt = "“定稿”";
  755. }
  756. else if (memoopt == 3)
  757. {
  758. stropt = "“查货”";
  759. CeErpSukuraData.createInfo(entity.ctid, 6);
  760. }
  761. entity.MemoOpt = Convert.ToInt32(memoopt);
  762. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  763. }
  764. if (entity.OrderState < 5)
  765. {
  766. memo = memo.Replace("(", "(");
  767. memo = memo.Replace(")", ")");
  768. }
  769. if (entity.OrderState < 3)
  770. {
  771. entity.DispatchSort = 0;
  772. }
  773. entity.seller_memo = memo;
  774. entity.UpdateTime = DateTime.Now;
  775. entity.Update();
  776. ApiVo apiVo = new ApiVo();
  777. apiVo.orderNumber = entity.ctid;
  778. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  779. apiVo.orderRemarks = memo;
  780. apiVo.remarkSign = memoopt;
  781. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  782. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  783. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  784. {
  785. dataHelper.api_orderBack(entity.ctid, "0", "");
  786. }
  787. if (entity.seller_memo.Contains("改稿"))
  788. {
  789. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  790. }
  791. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  792. returnSuccessMsg("保存成功!");
  793. return;
  794. }
  795. returnErrorMsg("找不到记录");
  796. }
  797. }
  798. public void ins_erp_checkorder()
  799. {
  800. if (UrlPostParmsCheck("ctid"))
  801. {
  802. string ctid = GetPostString("ctid");
  803. CeErpTradeCell entity = null;
  804. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  805. if (entity != null)
  806. {
  807. if (entity.OrderState < 6)
  808. {
  809. returnErrorMsg("下单完成后才可查货");
  810. return;
  811. }
  812. /*if (entity.OrderState > 6)
  813. {
  814. returnErrorMsg("订单已发货");
  815. return;
  816. }*/
  817. if (entity.FinishPlaceTime != null)
  818. {
  819. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  820. {
  821. returnErrorMsg("下单时间不足,无法查货");
  822. return;
  823. }
  824. }
  825. entity.MemoOpt = 3;
  826. entity.CheckOrderTime = DateTime.Now;
  827. entity.UpdateTime = DateTime.Now;
  828. entity.Update();
  829. CeErpSukuraData.createInfo(entity.ctid, 6);
  830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  831. returnSuccessMsg("操作成功!");
  832. return;
  833. }
  834. returnErrorMsg("找不到记录");
  835. }
  836. }
  837. public void save_erp_othermemo()
  838. {
  839. if (UrlPostParmsCheck("ctid"))
  840. {
  841. string ctid = GetPostString("ctid");
  842. CeErpTradeCell entity = null;
  843. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  844. if (entity != null)
  845. {
  846. entity.OtherMemo = GetPostString("otherMemo");
  847. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  848. {
  849. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  850. StringBuilder sql = new StringBuilder();
  851. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  852. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  853. if (dt != null && dt.Rows.Count > 0)
  854. {
  855. foreach (DataRow dr in dt.Rows)
  856. {
  857. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  858. {
  859. //品类一直
  860. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  861. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  862. if (ceErpSampleCustomer == null)
  863. {
  864. ceErpSampleCustomer = new CeErpSampleCustomer();
  865. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  866. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  867. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  868. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  869. ceErpSampleCustomer.shopId = entity.ShopId;
  870. }
  871. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  872. ceErpSampleCustomer.lastTid = entity.tid;
  873. if (ceErpSampleCustomer.ID > 0)
  874. {
  875. ceErpSampleCustomer.Update();
  876. }
  877. else
  878. {
  879. ceErpSampleCustomer.Create();
  880. }
  881. }
  882. }
  883. }
  884. }
  885. //if (entity.IsOldCustomer == 1)
  886. //{
  887. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  888. //{
  889. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  890. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  891. //}
  892. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  893. //{
  894. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  895. // {
  896. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  897. // {
  898. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  899. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  900. // }
  901. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  902. // {
  903. // entity.OrderState = 2;
  904. // entity.DesignUserId = 0;
  905. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  906. // }
  907. // else
  908. // {
  909. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  910. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  911. // }
  912. // }
  913. //}
  914. //}
  915. entity.UpdateTime = DateTime.Now;
  916. entity.Update();
  917. returnSuccessMsg("保存成功!");
  918. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  919. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  920. if (entity.OtherMemo.Contains("改稿"))
  921. {
  922. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  923. }
  924. return;
  925. }
  926. returnErrorMsg("找不到记录");
  927. }
  928. }
  929. public void save_erp_customermemo()
  930. {
  931. if (UrlPostParmsCheck("ctid"))
  932. {
  933. string ctid = GetPostString("ctid");
  934. CeErpTradeCell entity = null;
  935. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  936. if (entity != null)
  937. {
  938. entity.UpdateTime = DateTime.Now;
  939. entity.CustomerMemo = GetPostString("CustomerMemo");
  940. entity.Update();
  941. ApiVo apiVo = new ApiVo();
  942. apiVo.orderNumber = entity.ctid;
  943. apiVo.actionName = "followRemarks";
  944. apiVo.orderRemarks = entity.CustomerMemo;
  945. designHelper.API_WorkCore(apiVo);//followRemarks
  946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  947. returnSuccessMsg("保存成功!");
  948. return;
  949. }
  950. returnErrorMsg("找不到记录");
  951. }
  952. }
  953. public void upd_erp_addmemotag()
  954. {
  955. if (UrlPostParmsCheck("ctid"))
  956. {
  957. ;
  958. string eid = GetPostString("ctid");
  959. string sfTagstr = GetPostString("memotag");
  960. CeErpTradeCell entity = null;
  961. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  962. if (entity != null)
  963. {
  964. ApiVo apiVo = new ApiVo();
  965. if (entity.OrderState == 0)
  966. {
  967. returnErrorMsg("请先领单");
  968. return;
  969. }
  970. //撤销顺丰
  971. if (sfTagstr == "撤销顺丰")
  972. {
  973. entity.IsSF = 0;
  974. string reMsg = "";
  975. string oldmemo = entity.seller_memo;
  976. if (entity.OrderState < 5)
  977. {
  978. oldmemo = oldmemo.Replace("顺丰到付", "");
  979. oldmemo = oldmemo.Replace("顺丰寄付", "");
  980. entity.seller_memo = oldmemo;
  981. }
  982. else
  983. {
  984. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  985. {
  986. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  987. }
  988. }
  989. entity.Update();
  990. apiVo.orderNumber = entity.ctid;
  991. apiVo.actionName = "orderRemarks";
  992. apiVo.orderRemarks = entity.seller_memo;
  993. apiVo.isSf = entity.IsSF.ToString();
  994. designHelper.API_WorkCore(apiVo);//orderRemarks
  995. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  996. returnSuccessMsg("撤销成功!" + reMsg);
  997. return;
  998. }
  999. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1000. {
  1001. //string oldmemo = entity.seller_memo;
  1002. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1003. string sfStr = GetPostString("memotag");
  1004. string smemo = entity.seller_memo;
  1005. int kindex = smemo.IndexOf(")");
  1006. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1007. if (lastoneStr != "-")
  1008. {
  1009. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1010. }
  1011. string prememo = smemo.Substring(0, kindex + 2);
  1012. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1013. int lastkindex = lastmemo.IndexOf("(");
  1014. string newlastmemo = "";
  1015. if (lastkindex == 0)
  1016. {
  1017. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1018. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1019. }
  1020. else
  1021. {
  1022. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1023. }
  1024. entity.seller_memo = prememo + newlastmemo;
  1025. }
  1026. string sfTagMSg = "";
  1027. if (sfTagstr == "顺丰寄付")
  1028. {
  1029. entity.IsSF = 1;
  1030. sfTagMSg = "顺丰寄付";
  1031. }
  1032. else if (sfTagstr == "顺丰到付")
  1033. {
  1034. entity.IsSF = 2;
  1035. sfTagMSg = "顺丰到付";
  1036. }
  1037. entity.Update();
  1038. apiVo = new ApiVo();
  1039. apiVo.orderNumber = entity.ctid;
  1040. apiVo.actionName = "orderRemarks";
  1041. apiVo.orderRemarks = entity.seller_memo;
  1042. apiVo.isSf = entity.IsSF.ToString();
  1043. designHelper.API_WorkCore(apiVo);//orderRemarks
  1044. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1045. returnSuccessMsg("标记成功!");
  1046. return;
  1047. }
  1048. returnErrorMsg("找不到记录");
  1049. }
  1050. }
  1051. public void upd_erp_ordertag()
  1052. {
  1053. if (UrlPostParmsCheck("ctid"))
  1054. {
  1055. string eid = GetPostString("ctid");
  1056. CeErpTradeCell entity = null;
  1057. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1058. if (entity != null)
  1059. {
  1060. int tag = GetPostInt("wechattag");
  1061. //if(tag==4 && entity.IsSample == 2)
  1062. //{
  1063. // returnErrorMsg("补差价单不能标记微信单");
  1064. // return;
  1065. //}
  1066. entity.wechatTag = tag;
  1067. entity.Update();
  1068. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1069. if (tag == 1)
  1070. {
  1071. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1072. if (cash == null)
  1073. {
  1074. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1075. cash = new CeErpReturnCash();
  1076. cash.tid = entity.tid;
  1077. cash.seller_nick = main.seller_nick;
  1078. cash.payment = trade.payment;
  1079. cash.buyer_nick = main.buyer_nick;
  1080. cash.cashstate = 0;
  1081. cash.rtype = "微信返现";
  1082. cash.returnprice = 0;
  1083. cash.created = DateTime.Now;
  1084. cash.con = "订单标记微信单";
  1085. cash.img = "";
  1086. cash.applyuserid = CurrentUser.UserID;
  1087. cash.Create();
  1088. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1089. }
  1090. else
  1091. {
  1092. cash.cashstate = 0;
  1093. cash.Update();
  1094. }
  1095. CeErpSukuraData.createInfo(entity.ctid, 9);
  1096. }
  1097. else if (tag == 2)
  1098. {
  1099. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1100. if (cash == null)
  1101. {
  1102. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1103. cash = new CeErpReturnCash();
  1104. cash.tid = entity.tid;
  1105. cash.seller_nick = main.seller_nick;
  1106. cash.payment = trade.payment;
  1107. cash.buyer_nick = main.buyer_nick;
  1108. cash.cashstate = 0;
  1109. cash.rtype = "推购返现";
  1110. cash.returnprice = 5;
  1111. cash.created = DateTime.Now;
  1112. cash.con = "订单标记推购单";
  1113. cash.img = "";
  1114. cash.applyuserid = CurrentUser.UserID;
  1115. cash.Create();
  1116. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1117. }
  1118. else
  1119. {
  1120. cash.cashstate = 0;
  1121. cash.Update();
  1122. }
  1123. CeErpSukuraData.createInfo(entity.ctid, 9);
  1124. }
  1125. else if (tag == 3)
  1126. {
  1127. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1128. if (pers == null)
  1129. {
  1130. pers = new CeErpPersuade();
  1131. pers.ctid = entity.ctid;
  1132. pers.pstate = 0;
  1133. pers.created = DateTime.Now;
  1134. pers.applyuserid = CurrentUser.UserID;
  1135. pers.Create();
  1136. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1137. }
  1138. else
  1139. {
  1140. pers.pstate = 0;
  1141. pers.Update();
  1142. }
  1143. }
  1144. else if (tag == 4 || tag == 5)
  1145. {
  1146. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1147. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1148. if (pers == null)
  1149. {
  1150. pers = CeErpStayGoods.GetByTid(entity.tid);
  1151. }
  1152. if (pers == null)
  1153. {
  1154. pers = new CeErpStayGoods();
  1155. pers.t_id = entity.tid;
  1156. pers.ctid = entity.ctid;
  1157. pers.status = "待审核";
  1158. pers.audit_type = 0;
  1159. if (tag == 4)
  1160. {
  1161. pers.stay_type = "微信推购";
  1162. }
  1163. else
  1164. {
  1165. pers.stay_type = "旺旺推购";
  1166. }
  1167. if (entity.IsXianHuo == 0)
  1168. {
  1169. pers.product_id = entity.ProductId;
  1170. }
  1171. pers.wangwang = main.buyer_nick;
  1172. pers.shop_name = main.seller_nick;
  1173. pers.creata_time = DateTime.Now;
  1174. pers.create_u_id = CurrentUser.UserID;
  1175. pers.create_u_name = CurrentUser.UserName;
  1176. pers.Create();
  1177. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1178. }
  1179. else
  1180. {
  1181. pers.ctid = entity.ctid;
  1182. pers.audit_type = 0;
  1183. pers.Update();
  1184. }
  1185. CeErpSukuraData.createInfo(entity.ctid, 10);
  1186. }
  1187. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1188. returnSuccessMsg("标记成功!");
  1189. return;
  1190. }
  1191. returnErrorMsg("找不到记录");
  1192. }
  1193. }
  1194. public void upd_erp_ordertag_cancel()
  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. entity.wechatTag = 0;
  1204. entity.Update();
  1205. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1206. if (pers != null)
  1207. {
  1208. pers.status = "取消推购";
  1209. pers.audit_type = 3;
  1210. pers.Update();
  1211. }
  1212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1213. returnSuccessMsg("标记成功!");
  1214. return;
  1215. }
  1216. returnErrorMsg("找不到记录");
  1217. }
  1218. }
  1219. public void upd_erp_addweichattag()
  1220. {
  1221. if (UrlPostParmsCheck("ctid"))
  1222. {
  1223. ;
  1224. string eid = GetPostString("ctid");
  1225. CeErpTradeCell entity = null;
  1226. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1227. if (entity != null)
  1228. {
  1229. if (entity.IsAddWechat > 0)
  1230. {
  1231. returnErrorMsg("此单已经标记过了");
  1232. return;
  1233. }
  1234. 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);
  1235. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1236. if (dt.Rows.Count > 0)
  1237. {
  1238. entity.IsAddWechat = 2;
  1239. }
  1240. else
  1241. {
  1242. entity.IsAddWechat = 1;
  1243. }
  1244. entity.Update();
  1245. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1246. returnSuccessMsg("标记成功!");
  1247. return;
  1248. }
  1249. returnErrorMsg("找不到记录");
  1250. }
  1251. }
  1252. public void upd_erp_getmyorder()
  1253. {
  1254. if (UrlPostParmsCheck("ctid"))
  1255. {
  1256. ;
  1257. string eid = GetPostString("ctid");
  1258. CeErpTradeCell entity = null;
  1259. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1260. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1261. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1262. {
  1263. returnErrorMsg("台湾客户需填写身份证号!");
  1264. return;
  1265. }
  1266. if (entity != null)
  1267. {
  1268. if (entity.ctid.IndexOf("C") != -1)
  1269. {
  1270. StringBuilder sql = new StringBuilder();
  1271. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1272. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1273. if (dt.Rows.Count > 0)
  1274. {
  1275. decimal total = 0;
  1276. foreach (DataRow dr in dt.Rows)
  1277. {
  1278. total += Convert.ToDecimal(dr["payment"]);
  1279. }
  1280. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1281. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1282. {
  1283. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1284. return;
  1285. }
  1286. }
  1287. }
  1288. if (entity.OrderState == -1)
  1289. {
  1290. returnErrorMsg("待审核订单无法领取!");
  1291. return;
  1292. }
  1293. entity.CustomerUserId = CurrentUser.UserID;
  1294. if (entity.OrderState < 2)
  1295. {
  1296. entity.OrderState = 2;
  1297. if (entity.ShopId != 0)
  1298. {
  1299. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1300. }
  1301. }
  1302. entity.UpdateTime = DateTime.Now;
  1303. entity.Update();
  1304. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1305. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1306. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1307. {
  1308. dataHelper.api_orderBack(entity.ctid, "0", "");
  1309. }
  1310. returnSuccessMsg("领单成功!");
  1311. return;
  1312. }
  1313. returnErrorMsg("找不到记录");
  1314. }
  1315. }
  1316. public void getmyorder_from_init()
  1317. {
  1318. if (UrlPostParmsCheck("ctid"))
  1319. {
  1320. string eid = GetPostString("ctid");
  1321. CeErpTradeCell entity = null;
  1322. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1323. if (entity != null)
  1324. {
  1325. string sellerMemo = GetPostString("sellerMemo");
  1326. if (sellerMemo.Length > 0)
  1327. {
  1328. entity.seller_memo = sellerMemo;
  1329. }
  1330. string oterhMemo = GetPostString("otherMemo");
  1331. if (oterhMemo.Length > 0)
  1332. {
  1333. entity.OtherMemo = oterhMemo;
  1334. }
  1335. int urg = GetPostInt("urgency");
  1336. entity.IsUrgency = (urg == 1 ? true : false);
  1337. int wechat = GetPostInt("wechat");
  1338. int command = GetPostInt("command");
  1339. if (wechat == 1)
  1340. {
  1341. entity.wechatTag = 1;
  1342. }
  1343. if (command == 1)
  1344. {
  1345. entity.wechatTag = 2;
  1346. }
  1347. string pPro = GetPostString("pprofession");
  1348. if (pPro.Length > 0)
  1349. {
  1350. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1351. string spro = GetPostString("profession");
  1352. if (spro.Length > 0)
  1353. {
  1354. entity.ProfessionId = Convert.ToInt32(spro);
  1355. }
  1356. }
  1357. string proId = GetPostString("productId");
  1358. if (proId.Length > 0)
  1359. {
  1360. entity.ProductId = Convert.ToInt32(proId);
  1361. }
  1362. entity.Material = GetPostString("material");
  1363. entity.Craft = GetPostString("craft");
  1364. entity.CustomerUserId = CurrentUser.UserID;
  1365. if (entity.OrderState < 2)
  1366. {
  1367. entity.OrderState = 2;
  1368. if (entity.ShopId != 0)
  1369. {
  1370. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1371. }
  1372. }
  1373. entity.Update();
  1374. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1375. returnSuccessMsg("领单成功!");
  1376. return;
  1377. }
  1378. returnErrorMsg("找不到记录");
  1379. }
  1380. }
  1381. public void upd_erp_setrelationorder()
  1382. {
  1383. if (UrlPostParmsCheck("ctid"))
  1384. {
  1385. ;
  1386. string eid = GetPostString("ctid");
  1387. string ftid = GetPostString("ftid");
  1388. CeErpTradeCell entity = null;
  1389. CeErpTradeCell fentity = null;
  1390. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1391. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1392. if (fentity == null)
  1393. {
  1394. returnErrorMsg("找不到关联的主订单");
  1395. return;
  1396. }
  1397. if (entity != null)
  1398. {
  1399. if (entity.OrderState >= 5)
  1400. {
  1401. returnErrorMsg("本单已经设计完成无法关联");
  1402. return;
  1403. }
  1404. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1405. {
  1406. returnErrorMsg("线下单续审核后才能关联!");
  1407. return;
  1408. }
  1409. entity.ptid = ftid;
  1410. entity.OrderState = fentity.OrderState;
  1411. //entity.status = fentity.status;
  1412. entity.CustomerUserId = fentity.CustomerUserId;
  1413. entity.DesignUserId = fentity.DesignUserId;
  1414. entity.seller_memo = "补差价单:" + ftid;
  1415. entity.IsSample = 2;
  1416. entity.Update();
  1417. ApiVo apiVo = new ApiVo();
  1418. apiVo.orderNumber = ftid;
  1419. apiVo.payment = entity.payment;
  1420. apiVo.actionName = "repairDesign";
  1421. designHelper.API_WorkCore(apiVo);//repairDesign
  1422. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1423. returnSuccessMsg("关联成功!");
  1424. return;
  1425. }
  1426. else
  1427. returnErrorMsg("找不到记录");
  1428. }
  1429. }
  1430. public void download_erp_neworder()
  1431. {
  1432. string seller = GetPostString("seller_nick");
  1433. string tid = GetPostString("tid");
  1434. if (seller.Length <= 0 || tid.Length <= 0)
  1435. {
  1436. returnErrorMsg("数据错误");
  1437. }
  1438. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1439. //{
  1440. // returnErrorMsg("找不到店铺Sessionkey");
  1441. //}
  1442. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1443. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1444. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1445. if (res.IndexOf("refOid") == -1)
  1446. {
  1447. returnErrorMsg("下载订单数据失败");
  1448. return;
  1449. }
  1450. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1451. returnSuccessMsg("下载完成");
  1452. //tmcHelper.createNewOrder(res);
  1453. //CeErpTrade entr = null;
  1454. //entr = CeErpTrade.Get(tid);
  1455. //if (entr != null)
  1456. //{
  1457. // returnSuccess("下载成功");
  1458. // //下载成功之后,Cell表生成对应的订单;
  1459. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1460. //}
  1461. //else
  1462. //{
  1463. // returnErrorMsg("下载失败或者创建订单失败");
  1464. //}
  1465. }
  1466. public void set_erp_atersale()
  1467. {
  1468. if (UrlPostParmsCheck("ctid"))
  1469. {
  1470. string eid = GetPostString("ctid");
  1471. string reason = GetPostString("AfterSaleReason");
  1472. CeErpTradeCell entity = null;
  1473. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1474. if (entity != null)
  1475. {
  1476. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1477. {
  1478. returnErrorMsg("此订单已经在售后");
  1479. return;
  1480. }
  1481. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1482. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1483. entity.AfterSaleTime = DateTime.Now;
  1484. entity.Update();
  1485. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1486. returnSuccessMsg("转售后成功!");
  1487. return;
  1488. }
  1489. returnErrorMsg("找不到记录");
  1490. }
  1491. }
  1492. public void set_erp_withdraw()
  1493. {
  1494. if (UrlPostParmsCheck("ctid"))
  1495. {
  1496. try
  1497. {
  1498. string eid = GetPostString("ctid");//商品id
  1499. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1500. CeWithdraw ceWithdrawSelect = null;
  1501. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1502. if (ceWithdrawSelect != null)
  1503. {
  1504. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1505. {
  1506. ceWithdrawSelect.status = -1;
  1507. ceWithdrawSelect.Update();
  1508. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1509. returnSuccessMsg("重新发起审核成功");
  1510. return;
  1511. }
  1512. else
  1513. {
  1514. returnSuccessMsg("请勿重复申请!");
  1515. return;
  1516. }
  1517. }
  1518. else
  1519. {
  1520. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1521. if (string.IsNullOrEmpty(CustomerUserId))
  1522. {
  1523. CustomerUserId = "-1";
  1524. }
  1525. int Userid = CurrentUser.UserID;//用户id
  1526. CeWithdraw ceWithdraw = new CeWithdraw();
  1527. ceWithdraw.tid = eid;
  1528. ceWithdraw.userid = Userid;
  1529. ceWithdraw.providerid = CustomerUserId;
  1530. ceWithdraw.status = 3;
  1531. ceWithdraw.creationtime = DateTime.Now;
  1532. ceWithdraw.Create();
  1533. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1534. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1535. return;
  1536. }
  1537. }
  1538. catch
  1539. {
  1540. returnErrorMsg("申请撤回订单失败");
  1541. return;
  1542. }
  1543. }
  1544. }
  1545. public void ins_erp_billinfo()
  1546. {
  1547. if (UrlPostParmsCheck("ctid"))
  1548. {
  1549. string eid = GetPostString("ctid");
  1550. CeErpTradeCell entity = null;
  1551. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1552. if (entity != null)
  1553. {
  1554. CeErpBill bill = CeErpBill.GetByTid(eid);
  1555. bool isHave = false;
  1556. if (bill != null)
  1557. {
  1558. isHave = true;
  1559. if (bill.state != 4)
  1560. {
  1561. returnErrorMsg("此单已经申请过发票了");
  1562. return;
  1563. }
  1564. }
  1565. if (entity.IsNeedBill == 0)
  1566. {
  1567. entity.IsNeedBill = 1;
  1568. }
  1569. entity.Update();
  1570. string errjson = "";
  1571. try
  1572. {
  1573. CeErpBill bill_entity = new CeErpBill();
  1574. bill_entity.tid = entity.tid;
  1575. bill_entity.title = GetPostString("title");
  1576. string taxstr = GetPostString("tax");
  1577. taxstr = taxstr.Replace(" ", "");
  1578. bill_entity.tax = taxstr;
  1579. bill_entity.bank = GetPostString("bank");
  1580. string bankacstr = GetPostString("bankac");
  1581. bankacstr = bankacstr.Replace(" ", "");
  1582. bill_entity.bankac = bankacstr;
  1583. bill_entity.address = GetPostString("address");
  1584. bill_entity.phone = GetPostString("phone");
  1585. bill_entity.price = GetPostString("price");
  1586. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1587. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1588. {
  1589. billCount += 1;
  1590. }
  1591. string prebill = "ltb";
  1592. for (int idx = 1; idx <= billCount; idx++)
  1593. {
  1594. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1595. string billoid = prebill + idx + dtstr;
  1596. bill_entity.billOrderId += billoid;
  1597. if (idx < billCount)
  1598. {
  1599. bill_entity.billOrderId += ",";
  1600. }
  1601. }
  1602. bill_entity.productId = GetPostInt("ProductName");
  1603. bill_entity.num = GetPostInt("num");
  1604. bill_entity.unit = GetPostString("unit");
  1605. bill_entity.type = GetPostString("type");
  1606. bill_entity.sendType = GetPostString("SendType");
  1607. bill_entity.email = GetPostString("email");
  1608. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1609. bill_entity.shopName = GetPostString("ShopName");
  1610. bill_entity.applymemo = GetPostString("applyMemo");
  1611. bill_entity.createTime = DateTime.Now;
  1612. bill_entity.state = 0;
  1613. bill_entity.userId = CurrentUser.UserID;
  1614. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1615. bill_entity.Create();
  1616. }
  1617. catch (Exception ex)
  1618. {
  1619. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1620. returnErrorMsg("创建发票出错!");
  1621. return;
  1622. }
  1623. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1624. returnSuccessMsg("发票申请成功!");
  1625. return;
  1626. }
  1627. returnErrorMsg("找不到记录");
  1628. }
  1629. }
  1630. public void ins_erp_neworder()
  1631. {
  1632. if (UrlPostParmsCheck("receiver_name"))
  1633. {
  1634. CeErpTrade entity = new CeErpTrade();
  1635. string plat_form = GetPostString("platform");
  1636. string preStr = "N_";
  1637. if (plat_form == "拼多多")
  1638. {
  1639. preStr = "P_";
  1640. }
  1641. else if (plat_form == "阿里巴巴")
  1642. {
  1643. preStr = "A_";
  1644. }
  1645. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1646. entity.seller_nick = GetPostString("seller_nick");
  1647. entity.buyer_nick = GetPostString("buyer_nick");
  1648. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1649. entity.total_fee = entity.payment;
  1650. entity.pay_time = DateTime.Now;
  1651. entity.status = "NOT_SHIPPED";
  1652. entity.receiver_name = GetPostString("receiver_name");
  1653. entity.receiver_mobile = GetPostString("receiver_mobile");
  1654. entity.receiver_state = GetPostString("receiver_state");
  1655. entity.receiver_city = GetPostString("receiver_city");
  1656. entity.receiver_district = GetPostString("receiver_district");
  1657. entity.receiver_address = GetPostString("receiver_address");
  1658. if (entity.receiver_state == "" || entity.receiver_city == "")
  1659. {
  1660. returnErrorMsg("收件地址不能为空");
  1661. return;
  1662. }
  1663. int shopId = 0;
  1664. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1665. if (nShop != null)
  1666. {
  1667. shopId = nShop.ID;
  1668. }
  1669. if (shopId != 34 && entity.payment == 0)
  1670. {
  1671. returnErrorMsg("公司自用的单金额才能为0");
  1672. return;
  1673. }
  1674. entity.Create();
  1675. CeErpTradeCell entitycell = new CeErpTradeCell();
  1676. entitycell.ctid = entity.tid;
  1677. entitycell.tid = entity.tid;
  1678. entitycell.ShopId = shopId;
  1679. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1680. entitycell.OrderState = 0;
  1681. entitycell.pay_time = entity.pay_time;
  1682. entitycell.IsOffLineOrder = 1;
  1683. entitycell.Create();
  1684. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1685. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1686. return;
  1687. }
  1688. }
  1689. public void ins_erp_neworder2()
  1690. {
  1691. if (UrlPostParmsCheck("receiver_name"))
  1692. {
  1693. //string plat_form = GetPostString("platform");
  1694. string preStr = "X_";
  1695. string memo = GetPostString("memo");
  1696. string productId = GetPostString("productId");
  1697. string primg = GetPostString("proofimg");
  1698. string sellerNick = GetPostString("seller_nick");
  1699. string addFrom = GetPostString("addfrom");
  1700. if (addFrom == "1")
  1701. {
  1702. preStr = "N_";
  1703. }
  1704. int shopId = 0;
  1705. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1706. if (nShop != null)
  1707. {
  1708. shopId = nShop.ID;
  1709. }
  1710. else
  1711. {
  1712. returnErrorMsg("找不到对应店铺");
  1713. return;
  1714. }
  1715. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1716. {
  1717. returnErrorMsg("必须上传付款凭证");
  1718. return;
  1719. }
  1720. CeErpTrade entity = new CeErpTrade();
  1721. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1722. entity.seller_nick = sellerNick;
  1723. entity.buyer_nick = GetPostString("buyer_nick");
  1724. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1725. entity.total_fee = entity.payment;
  1726. entity.pay_time = DateTime.Now;
  1727. entity.status = "NOT_SHIPPED";
  1728. entity.receiver_name = GetPostString("receiver_name");
  1729. entity.receiver_mobile = GetPostString("receiver_mobile");
  1730. entity.receiver_state = GetPostString("receiver_state");
  1731. entity.receiver_city = GetPostString("receiver_city");
  1732. entity.receiver_district = GetPostString("receiver_district");
  1733. entity.receiver_address = GetPostString("receiver_address");
  1734. entity.seller_memo = memo;
  1735. entity.orderFrom = 20;
  1736. entity.orderType = 15;
  1737. if (entity.receiver_state == "" || entity.receiver_city == "")
  1738. {
  1739. returnErrorMsg("收件地址不能为空");
  1740. return;
  1741. }
  1742. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1743. {
  1744. returnErrorMsg("公司自用的单金额才能为0");
  1745. return;
  1746. }
  1747. entity.Create();
  1748. string toWhere = GetPostString("towhere");
  1749. CeErpTradeCell entitycell = new CeErpTradeCell();
  1750. entitycell.ctid = entity.tid;
  1751. //唯一标识
  1752. entitycell.OrderSn = entity.tid;
  1753. string orderSn = dataHelper.getSaleOrderSn();
  1754. if (orderSn != "")
  1755. {
  1756. entitycell.OrderSn = orderSn;
  1757. }
  1758. entitycell.tid = entity.tid;
  1759. //if (preStr == "X_")
  1760. //{
  1761. entitycell.IsOffLineOrder = 1;
  1762. //}
  1763. entitycell.CustomerUserId = CurrentUser.UserID;
  1764. entitycell.PayProofImg = primg;
  1765. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1766. entitycell.ProductId = Convert.ToInt32(productId);
  1767. entitycell.ShopId = shopId;
  1768. entitycell.UpdateTime = DateTime.Now;
  1769. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1770. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1771. {
  1772. entitycell.IsXianHuo = 1;
  1773. }
  1774. entitycell.pay_time = entity.pay_time;
  1775. if (toWhere == "1")
  1776. {
  1777. entitycell.OrderState = 2;
  1778. }
  1779. else
  1780. {
  1781. entitycell.OrderState = 6;
  1782. entitycell.FinishPlaceTime = entitycell.pay_time;
  1783. }
  1784. if (shopId == 94)
  1785. {
  1786. entitycell.OrderState = 4;
  1787. entitycell.WaitDesignTime = entitycell.pay_time;
  1788. entitycell.StartDesignTime = entitycell.pay_time;
  1789. entitycell.DesignUserId = 218;
  1790. }
  1791. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1792. {
  1793. entitycell.OrderState = -1;//修改12-5
  1794. CeWithdraw ceWithdraw = new CeWithdraw();
  1795. ceWithdraw.tid = entity.tid;
  1796. ceWithdraw.providerid = "-1";
  1797. ceWithdraw.status = -1;
  1798. ceWithdraw.creationtime = DateTime.Now;
  1799. ceWithdraw.userid = 1337;
  1800. ceWithdraw.Create();
  1801. }
  1802. entitycell.Create();
  1803. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1804. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1805. {
  1806. addPlaceRegist(entitycell, CurrentUser.UserID);
  1807. }
  1808. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1809. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1810. return;
  1811. }
  1812. }
  1813. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1814. {
  1815. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1816. entity.PlactTime = tradecell.pay_time;
  1817. entity.AddUserId = userid;
  1818. entity.FileName = tradecell.seller_memo;
  1819. entity.Supplier = 24;
  1820. entity.CreateTime = DateTime.Now;
  1821. entity.Did = tradecell.ctid;
  1822. entity.tid = tradecell.tid;
  1823. entity.splitTag = tradecell.SplitTag;
  1824. entity.CurState = "未完成";
  1825. entity.Create();
  1826. }
  1827. public void get_erp_offlinelist()
  1828. {
  1829. DataStruct dStruct = GetPostStruct();
  1830. List<string> lw = new List<string>();
  1831. string tid = GetPostString("ctid");
  1832. string date1 = GetPostString("date1");
  1833. string date2 = GetPostString("date2");
  1834. if (tid.Length > 0 || date1.Length > 0)
  1835. {
  1836. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1837. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1838. if (dw.Length > 0) lw.Add(dw);
  1839. }
  1840. else
  1841. {
  1842. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1843. }
  1844. string shopname = GetPostString("shopname");
  1845. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1846. string buyernick = GetPostString("buyer_nick");
  1847. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1848. string customer = GetPostString("customer");
  1849. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1850. string design = GetPostString("design");
  1851. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1852. string orderState = GetPostString("orderState");
  1853. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1854. string address = GetPostString("address");
  1855. 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));
  1856. string sellermemo = GetPostString("seller_memo");
  1857. if (sellermemo.Length > 0)
  1858. {
  1859. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1860. }
  1861. string price1 = GetPostString("price1");
  1862. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1863. string price2 = GetPostString("price2");
  1864. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1865. //if (PKey != "admin")
  1866. //{
  1867. // string usershop = CurrentUser.User.pemShop;
  1868. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1869. //}
  1870. //if (ex_psize > 0)
  1871. //{
  1872. dStruct.Order = "pay_time desc";
  1873. //}
  1874. //else
  1875. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1876. lw.Add(string.Format("IsOffLineOrder=1"));
  1877. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1878. DataTable dt = null;
  1879. dt = WebCache.GetData("view_erptradecell", dStruct);
  1880. writeGridDataTableJson(dStruct.TotalCount, dt);
  1881. }
  1882. public void get_erp_returncashrecord()
  1883. {
  1884. DataStruct dStruct = GetPostStruct();
  1885. List<string> lw = new List<string>();
  1886. string tid = GetPostString("ctid");
  1887. if (tid.Length > 0)
  1888. {
  1889. lw.Add(string.Format("tid like '%{0}%'", tid));
  1890. dStruct.Order = "id desc";
  1891. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1892. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1893. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1894. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1895. return;
  1896. }
  1897. returnErrorMsg("id数据错误!");
  1898. }
  1899. public void ins_erp_returncashrecord()
  1900. {
  1901. if (UrlPostParmsCheck("tid"))
  1902. {
  1903. string tid = GetPostString("tid");
  1904. string retype = GetPostString("type");
  1905. StringBuilder sql = new StringBuilder();
  1906. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1907. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1908. if (dt.Rows.Count > 0)
  1909. {
  1910. returnErrorMsg("相同返现类型记录已存在");
  1911. return;
  1912. }
  1913. CeErpReturnCash entity = new CeErpReturnCash();
  1914. entity.tid = tid;
  1915. entity.seller_nick = GetPostString("seller_nick");
  1916. string pment = GetPostString("payment");
  1917. if (pment.Length > 0)
  1918. {
  1919. entity.payment = Convert.ToDouble(pment);
  1920. }
  1921. entity.buyer_nick = GetPostString("buyer_nick");
  1922. entity.cashstate = 0;
  1923. entity.rtype = retype;
  1924. string rPrice = GetPostString("returnprice");
  1925. if (rPrice.Length > 0)
  1926. {
  1927. entity.returnprice = Convert.ToDouble(rPrice);
  1928. }
  1929. entity.created = DateTime.Now;
  1930. entity.con = GetPostString("con");
  1931. entity.img = GetPostString("img");
  1932. entity.applyuserid = CurrentUser.UserID;
  1933. entity.Create();
  1934. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1935. returnSuccessMsg("操作成功!");
  1936. return;
  1937. }
  1938. }
  1939. public void set_erp_predelivery()
  1940. {
  1941. if (UrlPostParmsCheck("ctid"))
  1942. {
  1943. string eid = GetPostString("ctid");
  1944. CeErpTradeCell entity = null;
  1945. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1946. if (entity != null)
  1947. {
  1948. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1949. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1950. //{
  1951. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1952. // return;
  1953. //}
  1954. entity.IsPreDelivery = 1;
  1955. entity.Update();
  1956. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1957. returnSuccessMsg("预发货成功!");
  1958. return;
  1959. //string shop = GetPostString("seller_nick");
  1960. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1961. //string comName = GetPostString("comName");
  1962. //string comCode = GetPostString("comCode");
  1963. //string outSid = GetPostString("outSid");//运单号
  1964. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1965. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1966. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1967. //string apires = "";
  1968. //if (deliveryType == "虚拟发货")
  1969. //{
  1970. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1971. //}
  1972. //else
  1973. //{
  1974. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1975. //}
  1976. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1977. ////{
  1978. //if (apires.IndexOf("发货成功") != -1)
  1979. //{
  1980. // if (deliveryType != "虚拟发货")
  1981. // {
  1982. // //还要插入快递信息到 快递信息表
  1983. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1984. // exinfo.tid = eid;
  1985. // exinfo.out_sid = outSid;
  1986. // exinfo.company_code = comCode;
  1987. // exinfo.company_name = comName;
  1988. // exinfo.delivery_memo = deliveryMemo;
  1989. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1990. // exinfo.deliveryType = deliveryType;
  1991. // exinfo.Create();
  1992. // }
  1993. // returnSuccessMsg("发货成功!");
  1994. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1995. //}
  1996. //else
  1997. //{
  1998. // returnErrorMsg("淘宝发货失败!!");
  1999. //}
  2000. //return;
  2001. }
  2002. returnErrorMsg("找不到订单记录");
  2003. }
  2004. }
  2005. public void get_erp_unusuallist()
  2006. {
  2007. DataStruct dStruct = GetPostStruct();
  2008. List<string> lw = new List<string>();
  2009. string tid = GetPostString("ctid");
  2010. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2011. string shopname = GetPostString("shopname");
  2012. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2013. string buyernick = GetPostString("buyer_nick");
  2014. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2015. string ResponsibleMan = GetPostString("responsible");
  2016. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2017. string date1 = GetPostString("date1");
  2018. string date2 = GetPostString("date2");
  2019. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2020. if (dw.Length > 0) lw.Add(dw);
  2021. string price1 = GetPostString("price1");
  2022. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2023. string price2 = GetPostString("price2");
  2024. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2025. string orderState = GetPostString("orderState");
  2026. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2027. string sellermemo = GetPostString("seller_memo");
  2028. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2029. lw.Add(string.Format("UnusualTag > 0"));
  2030. lw.Add(string.Format("IsRefund<={0}", 1));
  2031. dStruct.Order = "pay_time desc";
  2032. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2033. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2034. writeGridDataTableJson(dStruct.TotalCount, dt);
  2035. }
  2036. public void set_erp_unusualtonomal()
  2037. {
  2038. if (UrlPostParmsCheck("ctid"))
  2039. {
  2040. string eid = GetPostString("ctid");
  2041. CeErpTradeCell entity = null;
  2042. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2043. if (entity != null)
  2044. {
  2045. entity.UnusualTag = -1;
  2046. entity.Update();
  2047. returnSuccessMsg("忽略成功!");
  2048. return;
  2049. }
  2050. returnErrorMsg("找不到记录");
  2051. }
  2052. }
  2053. public void ins_erp_unusualreason()
  2054. {
  2055. if (UrlPostParmsCheck("ctid"))
  2056. {
  2057. string eid = GetPostString("ctid");
  2058. CeErpTradeCell entity = null;
  2059. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2060. if (entity != null)
  2061. {
  2062. entity.MemoOpt = 4;
  2063. entity.UnusualCon = GetPostString("con");
  2064. entity.Update();
  2065. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2066. if (trade != null)
  2067. {
  2068. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2069. }
  2070. //查货是否超时
  2071. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2072. if (ceErpTradeCellExtend == null)
  2073. {
  2074. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2075. ceErpTradeCellExtend.ctid = entity.ctid;
  2076. }
  2077. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2078. {
  2079. ceErpTradeCellExtend.CheckOut += 1;
  2080. }
  2081. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2082. if (ceErpTradeCellExtend.ID > 0)
  2083. {
  2084. ceErpTradeCellExtend.Update();
  2085. }
  2086. else
  2087. {
  2088. ceErpTradeCellExtend.Create();
  2089. }
  2090. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2091. returnSuccessMsg("操作成功!");
  2092. return;
  2093. }
  2094. returnErrorMsg("找不到记录");
  2095. }
  2096. }
  2097. public void upd_erp_sampleorder()
  2098. {
  2099. if (UrlPostParmsCheck("ctid"))
  2100. {
  2101. string eid = GetPostString("ctid");
  2102. string[] eArr = eid.Split(',');
  2103. if (eArr.Length > 1)
  2104. {
  2105. List<string> eLst = new List<string>();
  2106. for (int i = 0; i < eArr.Length; i++)
  2107. {
  2108. eLst.Add("'" + eArr[i] + "'");
  2109. }
  2110. eid = string.Join(",", eLst.ToArray());
  2111. }
  2112. else
  2113. {
  2114. eid = "'" + eid + "'";
  2115. }
  2116. StringBuilder sql = new StringBuilder();
  2117. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2118. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2119. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2120. if (dt.Rows.Count > 0)
  2121. {
  2122. string errmsg = "";
  2123. foreach (DataRow dr in dt.Rows)
  2124. {
  2125. StringBuilder sqlsb = new StringBuilder();
  2126. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2127. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2128. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2129. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2130. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2131. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2132. {
  2133. continue;
  2134. }
  2135. else
  2136. {
  2137. string emsg = commonHelper.KeepChinese(apires);
  2138. errmsg += emsg;
  2139. }
  2140. }
  2141. if (errmsg.Length > 0)
  2142. {
  2143. returnErrorMsg(errmsg);
  2144. return;
  2145. }
  2146. returnSuccessMsg("操作成功");
  2147. return;
  2148. }
  2149. returnErrorMsg("找不到记录");
  2150. }
  2151. }
  2152. public void upd_erp_transcustomer()
  2153. {
  2154. if (UrlPostParmsCheck("ctid"))
  2155. {
  2156. string eid = GetPostString("ctid");
  2157. int userid = GetPostInt("CustomerUserId");
  2158. CeErpTradeCell entity = null;
  2159. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2160. if (entity != null)
  2161. {
  2162. //string[] mlist = entity.seller_memo.Split('-');
  2163. //string sql = "select * from view_erpuser where id=" + userid;
  2164. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2165. //if (dt != null && dt.Rows.Count > 0)
  2166. //{
  2167. // string nmemo = "";
  2168. // for(int i = 0; i < mlist.Length - 1; i++)
  2169. // {
  2170. // nmemo += mlist[i];
  2171. // nmemo += "-";
  2172. // }
  2173. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2174. // entity.seller_memo = nmemo;
  2175. //}
  2176. entity.CustomerUserId = userid;
  2177. entity.Update();
  2178. returnSuccessMsg("操作成功!");
  2179. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2180. return;
  2181. }
  2182. returnErrorMsg("找不到记录");
  2183. }
  2184. }
  2185. public void upd_erp_transdesigner()
  2186. {
  2187. if (UrlPostParmsCheck("ctid"))
  2188. {
  2189. string eids = GetPostString("ctid");
  2190. string[] ctidList = eids.Split(',');
  2191. int userid = GetPostInt("DesignUserId");
  2192. foreach (string ctid in ctidList)
  2193. {
  2194. CeErpTradeCell entity = null;
  2195. CeErpDesignerBill entitys = null;
  2196. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2197. entitys = CeErpDesignerBill.GetByTid(ctid);
  2198. if (entity != null)
  2199. {
  2200. if (entity.OrderState > 4)
  2201. {
  2202. continue;
  2203. }
  2204. //存在退款不能流转
  2205. if (entity.IsRefund > 0)
  2206. {
  2207. continue;
  2208. }
  2209. entity.DesignUserId = userid;
  2210. entity.WaitDesignTime = DateTime.Now;
  2211. entity.Update();
  2212. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2213. }
  2214. }
  2215. returnSuccessMsg("操作成功!");
  2216. }
  2217. }
  2218. public void upd_erp_distributedesigner()
  2219. {
  2220. if (UrlPostParmsCheck("ctid"))
  2221. {
  2222. string eid = GetPostString("ctid");
  2223. int userid = GetPostInt("DesignUserId");
  2224. string[] idlist = eid.Split(',');
  2225. if (idlist.Length <= 0)
  2226. {
  2227. returnErrorMsg("订单不能为空");
  2228. return;
  2229. }
  2230. foreach (string ctid in idlist)
  2231. {
  2232. CeErpTradeCell entity = null;
  2233. CeErpDesignerBill entitys = null;
  2234. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2235. else continue;
  2236. if (entity != null)
  2237. {
  2238. if (userid == 2125 || userid == 3542)
  2239. { }
  2240. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2241. {
  2242. returnErrorMsg("金额错误的订单无法指派");
  2243. return;
  2244. }
  2245. if (entity.OrderState >= 5)
  2246. {
  2247. returnErrorMsg("已经设计完成无法指派");
  2248. return;
  2249. }
  2250. if (entity.OrderState == -1)
  2251. {
  2252. returnErrorMsg("审核中的订单无法指派");
  2253. return;
  2254. }
  2255. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2256. {
  2257. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2258. return;
  2259. }
  2260. //157赖橙帆 159林晨 73 静之颖
  2261. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479 && CurrentUser.UserID != 73)
  2262. {
  2263. returnErrorMsg("指派设计共创无法再次指派!");
  2264. return;
  2265. }
  2266. entity.OrderState = 3;
  2267. if (entity.SupplierId == 0)
  2268. {
  2269. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2270. entity.SupplierId = suid;
  2271. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2272. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2273. }
  2274. if (userid == 2125 && entity.seller_memo != "")
  2275. {
  2276. apiDesign.API_GetPrintData_CreateOrder(entity);
  2277. }
  2278. if (userid == 3542 && entity.seller_memo != "")
  2279. {
  2280. string userPost = CurrentUser.UserPost.Post.Code;
  2281. if (CurrentUser.UserID == 73)
  2282. {
  2283. userPost = "SysAdmin";
  2284. }
  2285. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2286. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2287. if (response.msg != "设计共创:成功")
  2288. {
  2289. returnErrorMsg(response.msg);
  2290. return;
  2291. }
  2292. entity.DispatchSort = 2;
  2293. }
  2294. else
  2295. {
  2296. if (entity.DispatchSort == 2)
  2297. {
  2298. ApiVo apiVo = new ApiVo();
  2299. apiVo.actionName = "closeDesign";
  2300. apiVo.orderNumber = entity.ctid;
  2301. designHelper.API_WorkCore(apiVo);//closeDesign
  2302. }
  2303. entity.DispatchSort = 0;
  2304. }
  2305. entity.DesignUserId = userid;
  2306. entity.WaitDesignTime = DateTime.Now;
  2307. entity.UpdateTime = DateTime.Now;
  2308. entity.Update();
  2309. string name = commonHelper.getUserNameById(userid);
  2310. commonHelper.UpdateRelationOrder(entity.ctid);
  2311. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2312. }
  2313. }
  2314. returnSuccessMsg("操作成功!");
  2315. return;
  2316. }
  2317. }
  2318. public string getTidByCtid(string ctid)
  2319. {
  2320. string tid = "";
  2321. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2322. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2323. if (dataTable != null && dataTable.Rows.Count > 0)
  2324. {
  2325. tid = dataTable.Rows[0]["tid"].ToString();
  2326. }
  2327. return tid;
  2328. }
  2329. public List<string> getTidByCtidMore(string ctid)
  2330. {
  2331. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2332. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2333. List<string> list = new List<string>();
  2334. if (dataTable != null && dataTable.Rows.Count > 0)
  2335. {
  2336. foreach (DataRow item in dataTable.Rows)
  2337. {
  2338. list.Add("'" + item["tid"].ToString() + "'");
  2339. }
  2340. }
  2341. return list;
  2342. }
  2343. public List<string> getTidByCtidLike(string ctid)
  2344. {
  2345. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2346. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2347. List<string> list = new List<string>();
  2348. if (dataTable != null && dataTable.Rows.Count > 0)
  2349. {
  2350. foreach (DataRow item in dataTable.Rows)
  2351. {
  2352. list.Add("'" + item["tid"].ToString() + "'");
  2353. }
  2354. }
  2355. return list;
  2356. }
  2357. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2358. {
  2359. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2360. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2361. List<string> list = new List<string>();
  2362. if (dataTable != null && dataTable.Rows.Count > 0)
  2363. {
  2364. foreach (DataRow item in dataTable.Rows)
  2365. {
  2366. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2367. {
  2368. continue;
  2369. }
  2370. list.Add("'" + item["receiverId"].ToString() + "'");
  2371. }
  2372. }
  2373. return list;
  2374. }
  2375. public void get_erp_myorderlist()
  2376. {
  2377. DataStruct dStruct = GetPostStruct();
  2378. List<string> lw = new List<string>();
  2379. string tid = GetPostString("ctid");
  2380. if (tid.Length > 0)
  2381. {
  2382. string select_tid = getTidByCtid(tid);
  2383. lw.Add(string.Format("tid='{0}'", select_tid));
  2384. }
  2385. else
  2386. {
  2387. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2388. }
  2389. //12-1 修改
  2390. string urgent = GetPostString("urgent");
  2391. string back = GetPostString("back");
  2392. string offlineSearch = GetPostString("offlineSearch");
  2393. if (!string.IsNullOrWhiteSpace(urgent))
  2394. {
  2395. if (urgent.Equals("true"))
  2396. {
  2397. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2398. }
  2399. }
  2400. if (!string.IsNullOrWhiteSpace(back))
  2401. {
  2402. if (back.Equals("true"))
  2403. {
  2404. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2405. }
  2406. }
  2407. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2408. {
  2409. if (offlineSearch.Equals("true"))
  2410. {
  2411. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2412. }
  2413. }
  2414. //end
  2415. string shopname = GetPostString("shopname");
  2416. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2417. string buyernick = GetPostString("buyer_nick");
  2418. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2419. string design = GetPostString("design");
  2420. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2421. string orderState = GetPostString("orderState");
  2422. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2423. string sellermemo = GetPostString("seller_memo");
  2424. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2425. string date1 = GetPostString("date1");
  2426. string date2 = GetPostString("date2");
  2427. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2428. if (dw.Length > 0) lw.Add(dw);
  2429. string price1 = GetPostString("price1");
  2430. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2431. string price2 = GetPostString("price2");
  2432. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2433. string urgency = GetPostString("urgency");
  2434. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2435. string after = GetPostString("after");
  2436. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2437. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2438. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2439. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2440. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2441. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2442. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2443. if (dt != null && dt.Rows.Count > 0)
  2444. {
  2445. foreach (DataRow dr in dt.Rows)
  2446. {
  2447. try
  2448. {
  2449. // 对象操作
  2450. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2451. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2452. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2453. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2454. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2455. if (dStruct.PageSize != 100000)
  2456. {
  2457. if (dr["DispatchSort"].ToString() == "2")
  2458. {
  2459. dr["gongchuang"] = 200;
  2460. }
  2461. else if ("外协".Equals(dr["ToType"].ToString()))
  2462. {
  2463. dr["gongchuang"] = 200;
  2464. }
  2465. else if ("内部".Equals(dr["ToType"].ToString()))
  2466. {
  2467. dr["gongchuang"] = -1;
  2468. }
  2469. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2470. {
  2471. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2472. dr["gongchuang"] = response.code;
  2473. }
  2474. }
  2475. }
  2476. catch (NullReferenceException ex)
  2477. {
  2478. }
  2479. }
  2480. }
  2481. writeGridDataTableJson(dStruct.TotalCount, dt);
  2482. }
  2483. public void get_erp_myreturnorderlist()
  2484. {
  2485. DataStruct dStruct = GetPostStruct();
  2486. List<string> lw = new List<string>();
  2487. string tid = GetPostString("ctid");
  2488. if (tid.Length > 0)
  2489. {
  2490. string select_tid = getTidByCtid(tid);
  2491. lw.Add(string.Format("tid='{0}'", select_tid));
  2492. }
  2493. else
  2494. {
  2495. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2496. }
  2497. string shopname = GetPostString("shopname");
  2498. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2499. string buyernick = GetPostString("buyer_nick");
  2500. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2501. string design = GetPostString("design");
  2502. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2503. string orderState = GetPostString("orderState");
  2504. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2505. string sellermemo = GetPostString("seller_memo");
  2506. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2507. string date1 = GetPostString("date1");
  2508. string date2 = GetPostString("date2");
  2509. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2510. if (dw.Length > 0) lw.Add(dw);
  2511. string price1 = GetPostString("price1");
  2512. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2513. string price2 = GetPostString("price2");
  2514. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2515. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2516. {
  2517. lw.Add(string.Format("CusOrgID = 94"));
  2518. }
  2519. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2520. {
  2521. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2522. }
  2523. else
  2524. {
  2525. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2526. }
  2527. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2528. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2529. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2530. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2531. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2532. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2533. if (dt != null && dt.Rows.Count > 0)
  2534. {
  2535. foreach (DataRow dr in dt.Rows)
  2536. {
  2537. try
  2538. {
  2539. // 对象操作
  2540. if (dStruct.PageSize != 100000)
  2541. {
  2542. if (dr["DispatchSort"].ToString() == "2")
  2543. {
  2544. dr["gongchuang"] = 200;
  2545. }
  2546. else if ("外协".Equals(dr["ToType"].ToString()))
  2547. {
  2548. dr["gongchuang"] = 200;
  2549. }
  2550. else if ("内部".Equals(dr["ToType"].ToString()))
  2551. {
  2552. dr["gongchuang"] = -1;
  2553. }
  2554. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2555. {
  2556. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2557. dr["gongchuang"] = response.code;
  2558. }
  2559. }
  2560. }
  2561. catch (NullReferenceException ex)
  2562. {
  2563. // 处理空引用异常
  2564. }
  2565. }
  2566. }
  2567. writeGridDataTableJson(dStruct.TotalCount, dt);
  2568. }
  2569. public void get_erp_myorderlist_pregather()
  2570. {
  2571. string date1 = GetPostString("date1");
  2572. string date2 = GetPostString("date2");
  2573. int userId = CurrentUser.UserID; //客服id
  2574. string orderWhere = "";
  2575. List<string> lw = new List<string>();
  2576. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2577. if (dw.Length > 0) lw.Add(dw);
  2578. lw.Add(string.Format("CustomerUserId={0}", userId));
  2579. lw.Add(string.Format("OrderState<9"));
  2580. orderWhere = string.Join(" and ", lw.ToArray());
  2581. string orderWhere2 = "";
  2582. List<string> lw2 = new List<string>();
  2583. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2584. if (dw2.Length > 0) lw2.Add(dw2);
  2585. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2586. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2587. string sql = string.Format("select *" +
  2588. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2589. "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 " +
  2590. "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 " +
  2591. "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");
  2592. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2593. //writeGridDataTableJson(dt.Rows.Count, dt);
  2594. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2595. }
  2596. public void upd_erp_publishorder()
  2597. {
  2598. if (UrlPostParmsCheck("ctid"))
  2599. {
  2600. string eid = GetPostString("ctid");
  2601. CeErpTradeCell entity = null;
  2602. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2603. if (entity != null)
  2604. {
  2605. entity.OrderState = 0; //发布后,变为待抢单
  2606. entity.Update();
  2607. commonHelper.UpdateRelationOrder(entity.ctid);
  2608. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2609. returnSuccessMsg("发布成功!");
  2610. return;
  2611. }
  2612. returnErrorMsg("找不到记录");
  2613. }
  2614. }
  2615. public void get_erp_my_tiporder()
  2616. {
  2617. StringBuilder sql = new StringBuilder();
  2618. int userId = 0;
  2619. if (CurrentUser != null) userId = CurrentUser.UserID;
  2620. string posCode = CurrentUser.UserPost.Post.Code;
  2621. string isTipedAfterSaleVerify = GetPostString("af");
  2622. DataTable dt = new DataTable();
  2623. if (posCode != "Supplier")
  2624. {
  2625. if (posCode == "CustomerService" || posCode == "Director")
  2626. {
  2627. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2628. }
  2629. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2630. {
  2631. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2632. }
  2633. else
  2634. {
  2635. string teamIds = CurrentUser.User.TeamIds;
  2636. if (teamIds == "")
  2637. {
  2638. teamIds = "0";
  2639. }
  2640. 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);
  2641. }
  2642. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2643. }
  2644. if (dt.Rows.Count <= 0)
  2645. {
  2646. string key = "aftersale_order_" + userId;
  2647. if (RedisHelper.HasKey(key))
  2648. {
  2649. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2650. dt.Columns.Add("ctid", typeof(string));
  2651. dt.Columns.Add("IsReadTag", typeof(int));
  2652. foreach (var i in list)
  2653. {
  2654. DataRow data = dt.NewRow();
  2655. data["ctid"] = i;
  2656. data["IsReadTag"] = 4;
  2657. dt.Rows.Add(data);
  2658. }
  2659. RedisHelper.StringDelete(key);
  2660. }
  2661. }
  2662. if (dt.Rows.Count <= 0)
  2663. {
  2664. sql = new StringBuilder();
  2665. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2666. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2667. }
  2668. if (posCode == "Supplier")
  2669. {
  2670. string ids = CurrentUser.User.pemVend;
  2671. if (ids != null && ids.Length > 0)
  2672. {
  2673. string[] ids_list = ids.Split(',');
  2674. foreach (var item in ids_list)
  2675. {
  2676. string key = "return_order_" + item;
  2677. if (RedisHelper.HasKey(key))
  2678. {
  2679. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2680. dt.Columns.Add("ctid", typeof(string));
  2681. dt.Columns.Add("IsReadTag", typeof(int));
  2682. foreach (var i in list)
  2683. {
  2684. DataRow data = dt.NewRow();
  2685. data["ctid"] = i;
  2686. data["IsReadTag"] = 1;
  2687. dt.Rows.Add(data);
  2688. }
  2689. RedisHelper.StringDelete(key);
  2690. }
  2691. }
  2692. }
  2693. if (dt.Rows.Count <= 0)
  2694. {
  2695. sql = new StringBuilder();
  2696. 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);
  2697. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2698. }
  2699. }
  2700. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2701. }
  2702. public void reset_erp_tiporder()
  2703. {
  2704. string ids = GetPostString("ids");
  2705. string[] ctidList = ids.Split(',');
  2706. foreach (string ctid in ctidList)
  2707. {
  2708. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2709. if (enty != null)
  2710. {
  2711. enty.IsReadTag = 0;
  2712. enty.Update();
  2713. }
  2714. }
  2715. returnSuccessMsg("成功!");
  2716. return;
  2717. }
  2718. public void get_erp_designlist()
  2719. {
  2720. DataStruct dStruct = GetPostStruct();
  2721. List<string> lw = new List<string>();
  2722. string tid = GetPostString("ctid");
  2723. if (tid.Length > 0)
  2724. {
  2725. string select_tid = getTidByCtid(tid);
  2726. lw.Add(string.Format("tid='{0}'", select_tid));
  2727. }
  2728. string shopname = GetPostString("shopname");
  2729. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2730. string buyernick = GetPostString("buyer_nick");
  2731. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2732. string customer = GetPostString("customer");
  2733. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2734. string design = GetPostString("design");
  2735. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2736. string orderState = GetPostString("orderState");
  2737. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2738. lw.Add(string.Format("OrderState<6"));
  2739. string address = GetPostString("address");
  2740. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2741. string sellermemo = GetPostString("seller_memo");
  2742. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2743. string date1 = GetPostString("date1");
  2744. string date2 = GetPostString("date2");
  2745. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2746. if (dw.Length > 0) lw.Add(dw);
  2747. string apdate1 = GetPostString("apdate1");
  2748. string apdate2 = GetPostString("apdate2");
  2749. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2750. if (dwap.Length > 0) lw.Add(dwap);
  2751. string price1 = GetPostString("price1");
  2752. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2753. string price2 = GetPostString("price2");
  2754. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2755. string designTime = GetPostString("designtime");
  2756. if (designTime.Length > 0)
  2757. {
  2758. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2759. }
  2760. string usershop = CurrentUser.User.pemShop;
  2761. if (usershop.Length > 0)
  2762. {
  2763. lw.Add(string.Format("shopId in ({0})", usershop));
  2764. }
  2765. int myOrgid = CurrentUser.UserPost.OrgID;
  2766. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2767. if (myOrgCode.IndexOf("Designer") != -1)
  2768. {
  2769. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2770. {
  2771. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2772. }
  2773. else
  2774. {
  2775. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2776. }
  2777. }
  2778. else
  2779. {
  2780. string orgId = GetPostString("designerhd");
  2781. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2782. }
  2783. if (tid.Length > 0 || buyernick.Length > 0)
  2784. {
  2785. lw.Add(string.Format("OrderState >= 3"));
  2786. }
  2787. else
  2788. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2789. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2790. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2791. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2792. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2793. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2794. if (dt != null && dt.Rows.Count > 0)
  2795. {
  2796. foreach (DataRow dr in dt.Rows)
  2797. {
  2798. try
  2799. {
  2800. // 对象操作
  2801. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2802. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2803. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2804. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2805. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2806. if (dStruct.PageSize != 100000)
  2807. {
  2808. if (dr["DispatchSort"].ToString() == "2")
  2809. {
  2810. dr["gongchuang"] = 200;
  2811. }
  2812. else if ("外协".Equals(dr["ToType"].ToString()))
  2813. {
  2814. dr["gongchuang"] = 200;
  2815. }
  2816. else if ("内部".Equals(dr["ToType"].ToString()))
  2817. {
  2818. dr["gongchuang"] = -1;
  2819. }
  2820. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2821. {
  2822. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2823. dr["gongchuang"] = response.code;
  2824. }
  2825. }
  2826. }
  2827. catch (NullReferenceException ex)
  2828. {
  2829. }
  2830. }
  2831. }
  2832. writeGridDataTableJson(dStruct.TotalCount, dt);
  2833. }
  2834. public void get_erp_mydesignlist()
  2835. {
  2836. DataStruct dStruct = GetPostStruct();
  2837. List<string> lw = new List<string>();
  2838. string tid = GetPostString("ctid");
  2839. if (tid.Length > 0)
  2840. {
  2841. string select_tid = getTidByCtid(tid);
  2842. lw.Add(string.Format("tid='{0}'", select_tid));
  2843. }
  2844. string shopname = GetPostString("shopname");
  2845. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2846. string buyernick = GetPostString("buyer_nick");
  2847. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2848. string customer = GetPostString("customer");
  2849. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2850. string orderState = GetPostString("orderState");
  2851. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2852. //lw.Add(string.Format("OrderState<6"));
  2853. string date1 = GetPostString("date1");
  2854. string date2 = GetPostString("date2");
  2855. string dw = GetDateWhere("pay_time", date1, date2);
  2856. if (dw.Length > 0) lw.Add(dw);
  2857. string apdate1 = GetPostString("apdate1");
  2858. string apdate2 = GetPostString("apdate2");
  2859. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2860. if (dwap.Length > 0) lw.Add(dwap);
  2861. string price1 = GetPostString("price1");
  2862. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2863. string price2 = GetPostString("price2");
  2864. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2865. string olddownload = GetPostString("olddown");
  2866. if (olddownload == "1")
  2867. {
  2868. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2869. }
  2870. else if (olddownload == "2")
  2871. {
  2872. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2873. }
  2874. string sellermemo = GetPostString("seller_memo");
  2875. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2876. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2877. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2878. {
  2879. if (CurrentUser.User.TeamIds.Length > 0)
  2880. {
  2881. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2882. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2883. else
  2884. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2885. }
  2886. else
  2887. {
  2888. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2889. }
  2890. }
  2891. if (tid.Length <= 0)
  2892. {
  2893. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2894. }
  2895. lw.Add(string.Format("IsReturn!=3"));
  2896. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2897. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2898. string teamids = CurrentUser.User.TeamIds.ToString();
  2899. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2900. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2901. if (dt != null && dt.Rows.Count > 0)
  2902. {
  2903. foreach (DataRow dr in dt.Rows)
  2904. {
  2905. try
  2906. {
  2907. // 对象操作
  2908. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2909. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2910. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2911. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2912. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2913. if (dStruct.PageSize != 100000)
  2914. {
  2915. if (dr["DispatchSort"].ToString() == "2")
  2916. {
  2917. dr["gongchuang"] = 200;
  2918. }
  2919. else if ("外协".Equals(dr["ToType"].ToString()))
  2920. {
  2921. dr["gongchuang"] = 200;
  2922. }
  2923. else if ("内部".Equals(dr["ToType"].ToString()))
  2924. {
  2925. dr["gongchuang"] = -1;
  2926. }
  2927. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2928. {
  2929. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2930. dr["gongchuang"] = response.code;
  2931. }
  2932. }
  2933. }
  2934. catch (NullReferenceException ex)
  2935. {
  2936. }
  2937. }
  2938. }
  2939. writeGridDataTableJson(dStruct.TotalCount, dt);
  2940. }
  2941. public void set_erp_startdesign()
  2942. {
  2943. if (UrlPostParmsCheck("ctid"))
  2944. {
  2945. string eid = GetPostString("ctid");
  2946. CeErpTradeCell entity = null;
  2947. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2948. if (entity != null)
  2949. {
  2950. if (entity.OrderState != 3)
  2951. {
  2952. returnErrorMsg("请刷新,订单已经设计了");
  2953. return;
  2954. }
  2955. entity.StartDesignTime = DateTime.Now;
  2956. entity.OrderState = 4;
  2957. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2958. {
  2959. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2960. entity.SupplierId = suid;
  2961. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2962. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2963. }
  2964. entity.UpdateTime = DateTime.Now;
  2965. //entity.MakeSupplier = suname;
  2966. entity.Update();
  2967. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2968. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2969. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2970. commonHelper.getCytPrice(entity);
  2971. returnSuccessMsg("操作成功!");
  2972. return;
  2973. }
  2974. returnErrorMsg("找不到记录");
  2975. }
  2976. }
  2977. public void ins_erp_designselfmemo()
  2978. {
  2979. if (UrlPostParmsCheck("ctid"))
  2980. {
  2981. string eid = GetPostString("ctid");
  2982. string con = GetPostString("con");
  2983. CeErpTradeCell entity = null;
  2984. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2985. if (entity != null)
  2986. {
  2987. entity.DesignSelfMemo = con;
  2988. entity.Update();
  2989. returnSuccessMsg("操作成功!");
  2990. return;
  2991. }
  2992. returnErrorMsg("找不到记录");
  2993. }
  2994. }
  2995. public void ins_erp_designprice()
  2996. {
  2997. if (UrlPostParmsCheck("ctid"))
  2998. {
  2999. string eid = GetPostString("ctid");
  3000. int uid = CurrentUser.UserID;
  3001. string userName = CurrentUser.UserName;
  3002. CeErpTradeCell entity = null;
  3003. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3004. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3005. if (entitys == null)
  3006. {
  3007. entitys = new CeErpDesignerBill();
  3008. }
  3009. if (entity != null)
  3010. {
  3011. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3012. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3013. entity.StartDesignTime = DateTime.Now;
  3014. entity.OrderState = 4;
  3015. string suname = "";
  3016. if (entity.SupplierId == 0)
  3017. {
  3018. int sid = commonHelper.autoDistributeToSupplier(entity);
  3019. entity.SupplierId = sid;
  3020. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3021. }
  3022. entity.Update();
  3023. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3024. if (ceErpUserPost != null)
  3025. {
  3026. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3027. if (ceErpPost != null)
  3028. {
  3029. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3030. {
  3031. entitys.tid = entity.ctid;
  3032. entitys.oid = entity.tid;
  3033. entitys.uid = uid;
  3034. entitys.userName = userName;
  3035. entitys.designerType = 1;
  3036. entitys.designerTypeText = "内部设计师";
  3037. entitys.price = Convert.ToDouble(GetPostString("price"));
  3038. entitys.designNum = GetPostInt("designNum");
  3039. entitys.modifyNum = GetPostInt("modifyNum");
  3040. entitys.designSize = GetPostString("designSize");
  3041. entitys.modifySize = GetPostString("modifySize");
  3042. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3043. {
  3044. entitys.create_time = DateTime.Now;
  3045. entitys.create_u_id = uid;
  3046. entitys.create_u_name = userName;
  3047. entitys.Save();
  3048. }
  3049. else
  3050. {
  3051. entitys.update_time = DateTime.Now;
  3052. entitys.update_u_id = uid;
  3053. entitys.update_u_name = userName;
  3054. entitys.Update();
  3055. }
  3056. }
  3057. }
  3058. }
  3059. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3060. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3061. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3062. if (suname != "")
  3063. {
  3064. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3065. }
  3066. commonHelper.getCytPrice(entity);
  3067. returnSuccessMsg("操作成功!");
  3068. return;
  3069. }
  3070. returnErrorMsg("找不到记录");
  3071. }
  3072. }
  3073. public void upload_erp_filecomplete()
  3074. {
  3075. if (UrlPostParmsCheck("ctid"))
  3076. {
  3077. string eid = GetPostString("ctid");
  3078. CeErpTradeCell entity = null;
  3079. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3080. if (entity != null)
  3081. {
  3082. entity.OrderState = 5; //设计完成
  3083. entity.Update();
  3084. returnSuccessMsg(eid + "上传成功,设计完成!");
  3085. return;
  3086. }
  3087. returnErrorMsg("找不到订单记录");
  3088. }
  3089. }
  3090. public void get_erp_designovertimelist()
  3091. {
  3092. DataStruct dStruct = GetPostStruct();
  3093. List<string> lw = new List<string>();
  3094. string tid = GetPostString("ctid");
  3095. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3096. string shopname = GetPostString("shopname");
  3097. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3098. string buyernick = GetPostString("buyer_nick");
  3099. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3100. string ResponsibleMan = GetPostString("responsible");
  3101. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3102. string date1 = GetPostString("date1");
  3103. string date2 = GetPostString("date2");
  3104. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3105. if (dw.Length > 0) lw.Add(dw);
  3106. string price1 = GetPostString("price1");
  3107. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3108. string price2 = GetPostString("price2");
  3109. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3110. string orderState = GetPostString("orderState");
  3111. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3112. string sellermemo = GetPostString("seller_memo");
  3113. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3114. lw.Add(string.Format("UnusualTag=3"));
  3115. lw.Add(string.Format("IsRefund<={0}", 1));
  3116. dStruct.Order = "WaitDesignTime desc";
  3117. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3118. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3119. writeGridDataTableJson(dStruct.TotalCount, dt);
  3120. }
  3121. //设计管理 获取抢单大厅列表
  3122. public void get_erp_grabinglist()
  3123. {
  3124. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3125. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3126. bool oldOrder = false;
  3127. if (org != null)
  3128. {
  3129. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3130. }
  3131. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3132. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3133. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3134. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3135. //先处理订单数据
  3136. if (dt.Rows.Count > 0)
  3137. {
  3138. Dictionary<string, int> design = null;
  3139. int count = 0;
  3140. foreach (DataRow row in dt.Rows)
  3141. {
  3142. if (map.ContainsKey(row["ShopId"].ToString()))
  3143. {
  3144. map.TryGetValue(row["ShopId"].ToString(), out design);
  3145. }
  3146. else
  3147. {
  3148. design = new Dictionary<string, int>();
  3149. }
  3150. if (design.ContainsKey(row["ProductId"].ToString()))
  3151. {
  3152. design.TryGetValue(row["ProductId"].ToString(), out count);
  3153. }
  3154. count++;
  3155. design[row["ProductId"].ToString()] = count;
  3156. map[row["ShopId"].ToString()] = design;
  3157. }
  3158. }
  3159. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3160. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3161. //把店铺排序和技能排序分类
  3162. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3163. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3164. if (design_dt.Rows.Count > 0)
  3165. {
  3166. Dictionary<string, string> design = null;
  3167. List<string> shopIds = null;
  3168. foreach (DataRow row in design_dt.Rows)
  3169. {
  3170. if ("0".Equals(row["designId"].ToString()))
  3171. {
  3172. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3173. {
  3174. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3175. }
  3176. else
  3177. {
  3178. shopIds = new List<string>();
  3179. }
  3180. shopIds.Add(row["shopId"].ToString());
  3181. shop_orders[row["orders"].ToString()] = shopIds;
  3182. }
  3183. else
  3184. {
  3185. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3186. {
  3187. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3188. }
  3189. else
  3190. {
  3191. design = new Dictionary<string, string>();
  3192. }
  3193. design[row["orders"].ToString()] = row["designId"].ToString();
  3194. design_orders[row["shopId"].ToString()] = design;
  3195. }
  3196. }
  3197. //处理成key value后根据key排序
  3198. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3199. foreach (List<string> val in shop_orders.Values)
  3200. {
  3201. if (val != null)
  3202. {
  3203. foreach (string key in val)
  3204. {
  3205. if (design_orders.ContainsKey(key.ToString()))
  3206. {
  3207. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3208. }
  3209. }
  3210. }
  3211. }
  3212. }
  3213. //校验哪个优先级有订单
  3214. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3215. foreach (string key in shop_orders.Keys)
  3216. {
  3217. List<string> ids = null;
  3218. shop_orders.TryGetValue(key, out ids);
  3219. //id为shopid
  3220. foreach (string id in ids)
  3221. {
  3222. Dictionary<string, int> list = null;
  3223. Dictionary<string, string> desing = null;
  3224. map.TryGetValue(id, out list);
  3225. design_orders.TryGetValue(id, out desing);
  3226. if (list != null && desing != null)
  3227. {
  3228. foreach (var item in desing)
  3229. {
  3230. int count = 0;
  3231. if (list.ContainsKey(item.Value))
  3232. {
  3233. list.TryGetValue(item.Value, out count);
  3234. if (count > 0)
  3235. {
  3236. designIds[id] = item.Value;
  3237. break;
  3238. }
  3239. }
  3240. }
  3241. }
  3242. }
  3243. if (designIds.Count > 0)
  3244. {
  3245. break;
  3246. }
  3247. }
  3248. DataTable table = new DataTable();
  3249. table.Columns.Add("tid", typeof(string));
  3250. table.Columns.Add("ctid", typeof(string));
  3251. table.Columns.Add("seller_nick", typeof(string));
  3252. table.Columns.Add("productName", typeof(string));
  3253. table.Columns.Add("pay_time", typeof(string));
  3254. table.Columns.Add("seller_memo", typeof(string));
  3255. if (designIds.Count > 0)
  3256. {
  3257. string shopId = "";
  3258. string productId = "";
  3259. foreach (var designInfo in designIds)
  3260. {
  3261. shopId = designInfo.Key;
  3262. productId = designInfo.Value;
  3263. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3264. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3265. if (dt.Rows.Count > 0)
  3266. {
  3267. foreach (DataRow row in dt.Rows)
  3268. {
  3269. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3270. {
  3271. DataRow data = table.NewRow();
  3272. data["ctid"] = row["ctid"].ToString();
  3273. data["tid"] = row["tid"].ToString();
  3274. data["seller_nick"] = ceErpShop.ShopName;
  3275. data["pay_time"] = row["pay_time"].ToString();
  3276. data["seller_memo"] = row["seller_memo"].ToString();
  3277. data["productName"] = ceErpProduct.PType;
  3278. table.Rows.Add(data);
  3279. }
  3280. }
  3281. }
  3282. }
  3283. }
  3284. writeGridDataTableJson(table.Rows.Count, table);
  3285. }
  3286. private object rushLockObject = new object();
  3287. public void set_erp_grabingorder()
  3288. {
  3289. if (UrlPostParmsCheck("ctid"))
  3290. {
  3291. int total = CurrentUser.User.Person.Total;
  3292. int userId = CurrentUser.User.ID;
  3293. int noFinish = CurrentUser.User.Person.NoFinish;
  3294. int finalization = CurrentUser.User.Person.Finalization;
  3295. string eids = GetPostString("ctid");
  3296. string key = "RushKey_" + userId;
  3297. int count = 0;
  3298. if (erpRedis.RedisHelper.KeyExists(key))
  3299. {
  3300. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3301. if (redisCount != null)
  3302. {
  3303. count = Convert.ToInt32(redisCount);
  3304. }
  3305. }
  3306. if (count >= total)
  3307. {
  3308. returnErrorMsg("半小时内已经抢" + total + "单");
  3309. return;
  3310. }
  3311. string[] ctidlist = eids.Split(',');
  3312. if (count + ctidlist.Length > total)
  3313. {
  3314. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3315. return;
  3316. }
  3317. int itag = 0;
  3318. lock (rushLockObject)
  3319. {
  3320. if (ctidlist.Length > 0)
  3321. {
  3322. string[] dtList = new string[ctidlist.Length];
  3323. for (int i = 0; i < ctidlist.Length; i++)
  3324. {
  3325. dtList[i] = "'" + ctidlist[i] + "'";
  3326. }
  3327. 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"));
  3328. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3329. if (dt_user.Rows.Count > 0)
  3330. {
  3331. int doing = 0;//未定稿
  3332. int finish = 0;//已完成
  3333. foreach (DataRow dr in dt_user.Rows)
  3334. {
  3335. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3336. {
  3337. doing++;
  3338. }
  3339. else
  3340. {
  3341. finish++;
  3342. }
  3343. }
  3344. if (doing >= noFinish)
  3345. {
  3346. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3347. return;
  3348. }
  3349. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3350. {
  3351. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3352. return;
  3353. }
  3354. }
  3355. //校验选择单子状态
  3356. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3357. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3358. if (dt.Rows.Count > 0)
  3359. {
  3360. List<string> list = new List<string>();
  3361. foreach (DataRow dr in dt.Rows)
  3362. {
  3363. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3364. {
  3365. list.Add(dr["ctid"].ToString());
  3366. }
  3367. }
  3368. if (list.Count > 0)
  3369. {
  3370. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3371. return;
  3372. }
  3373. }
  3374. foreach (string ctid in ctidlist)
  3375. {
  3376. CeErpTradeCell entity = null;
  3377. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3378. if (entity != null)
  3379. {
  3380. entity.OrderState = 3;
  3381. entity.DesignUserId = CurrentUser.UserID;
  3382. entity.WaitDesignTime = DateTime.Now;
  3383. entity.StartDesignTime = DateTime.Now;
  3384. entity.Update();
  3385. commonHelper.UpdateRelationOrder(entity.ctid);
  3386. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3387. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3388. itag++;
  3389. }
  3390. }
  3391. }
  3392. }
  3393. count += ctidlist.Length;
  3394. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3395. if (itag == 0)
  3396. returnErrorMsg("没有找到相关订单");
  3397. else
  3398. returnSuccessMsg("抢单成功!");
  3399. return;
  3400. }
  3401. }
  3402. public void get_erp_waitorderlist()
  3403. {
  3404. DataStruct dStruct = GetPostStruct();
  3405. List<string> lw = new List<string>();
  3406. string tid = GetPostString("ctid");
  3407. if (tid.Length > 0)
  3408. {
  3409. string select_tid = getTidByCtid(tid);
  3410. lw.Add(string.Format("tid='{0}'", select_tid));
  3411. }
  3412. string shopname = GetPostString("shopname");
  3413. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3414. string buyernick = GetPostString("buyer_nick");
  3415. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3416. string customer = GetPostString("customer");
  3417. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3418. string design = GetPostString("design");
  3419. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3420. string orderState = GetPostString("orderState");
  3421. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3422. string supplier = GetPostString("supplier");
  3423. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3424. string sellermemo = GetPostString("seller_memo");
  3425. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3426. string otherMemo = GetPostString("otherMemo");
  3427. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3428. string address = GetPostString("address");
  3429. 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));
  3430. string date1 = GetPostString("date1");
  3431. string date2 = GetPostString("date2");
  3432. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3433. if (dw.Length > 0) lw.Add(dw);
  3434. string price1 = GetPostString("price1");
  3435. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3436. string price2 = GetPostString("price2");
  3437. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3438. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3439. lw.Add(string.Format("IsSample != 2 "));
  3440. lw.Add(string.Format("OrderState = 5 "));
  3441. lw.Add(string.Format("IsRefund<={0}", 1));
  3442. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3443. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3444. string pagesize = GetPostString("pagesize");
  3445. if (pagesize != null)
  3446. {
  3447. dStruct.PageSize = 200;
  3448. }
  3449. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3450. List<string> tids = new List<string>();
  3451. if (dt != null)
  3452. {
  3453. dt.Columns.Add("compenPrice", typeof(double));
  3454. foreach (DataRow dr in dt.Rows)
  3455. {
  3456. if (Convert.IsDBNull(dr["compenPrice"]))
  3457. {
  3458. dr["compenPrice"] = 0;
  3459. }
  3460. tids.Add("'" + dr["tid"].ToString() + "'");
  3461. 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();
  3462. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3463. {
  3464. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3465. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3466. entity.SupplierId = suid;
  3467. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3468. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3469. entity.Update();
  3470. }
  3471. }
  3472. }
  3473. if (tids.Count > 0)
  3474. {
  3475. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3476. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3477. if (dt_price != null && dt_price.Rows.Count > 0)
  3478. {
  3479. foreach (DataRow dr in dt_price.Rows)
  3480. {
  3481. foreach (DataRow row in dt.Rows)
  3482. {
  3483. if (row["tid"].Equals(dr["ptid"]))
  3484. {
  3485. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3486. break;
  3487. }
  3488. }
  3489. }
  3490. }
  3491. }
  3492. writeGridDataTableJson(dStruct.TotalCount, dt);
  3493. }
  3494. public void get_erp_supplierwaitorderlist()
  3495. {
  3496. DataStruct dStruct = GetPostStruct();
  3497. List<string> lw = new List<string>();
  3498. string tid = GetPostString("ctid");
  3499. if (tid.Length > 0)
  3500. {
  3501. string select_tid = getTidByCtid(tid);
  3502. lw.Add(string.Format("tid='{0}'", select_tid));
  3503. }
  3504. string shopname = GetPostString("shopname");
  3505. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3506. string sellermemo = GetPostString("seller_memo");
  3507. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3508. string date1 = GetPostString("date1");
  3509. string date2 = GetPostString("date2");
  3510. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3511. if (dw.Length > 0) lw.Add(dw);
  3512. lw.Add(string.Format("OrderState = 5 "));
  3513. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3514. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3515. {
  3516. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3517. }
  3518. string supplier = GetPostString("supplier");
  3519. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3520. {
  3521. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3522. }
  3523. lw.Add(string.Format("IsRefund<={0}", 1));
  3524. dStruct.Order = "FinishDesignTime desc";
  3525. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3526. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3527. if (dt != null)
  3528. {
  3529. foreach (DataRow dr in dt.Rows)
  3530. {
  3531. 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();
  3532. }
  3533. }
  3534. writeGridDataTableJson(dStruct.TotalCount, dt);
  3535. }
  3536. public void upd_erp_verifytosupplier()
  3537. {
  3538. if (UrlPostParmsCheck("ctid"))
  3539. {
  3540. string eids = GetPostString("ctid");
  3541. CeErpTradeCell entity = null;
  3542. string[] eidsList = eids.Split(',');
  3543. if (eidsList.Length <= 0)
  3544. {
  3545. returnErrorMsg("订单号不能空");
  3546. return;
  3547. }
  3548. List<string> tLst = new List<string>();
  3549. foreach (string ctidstr in eidsList)
  3550. {
  3551. tLst.Add("'" + ctidstr + "'");
  3552. CeErpDataSendOrderInfo.createObject(ctidstr);
  3553. }
  3554. string needtids = string.Join(",", tLst.ToArray());
  3555. StringBuilder sql = new StringBuilder();
  3556. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3557. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3558. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3559. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3560. returnSuccessMsg("操作成功!");
  3561. return;
  3562. /**foreach (string ctidstr in eidsList)
  3563. {
  3564. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3565. if (entity != null)
  3566. {
  3567. if (entity.SupplierId == 0)
  3568. {
  3569. continue;
  3570. }
  3571. entity.IsVerifyToSupplier = true;
  3572. if (entity.IsReturn == 1) //1是供应商打回
  3573. {
  3574. entity.IsReturn = 0;
  3575. }
  3576. entity.FinishPlaceTime = DateTime.Now;
  3577. entity.PlaceUserId = CurrentUser.UserID;
  3578. entity.Update();
  3579. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3580. }
  3581. }
  3582. returnSuccessMsg("操作成功!");
  3583. return;**/
  3584. }
  3585. }
  3586. public void upd_erp_supplierback()
  3587. {
  3588. if (UrlPostParmsCheck("ctid"))
  3589. {
  3590. string eid = GetPostString("ctid");
  3591. string reason = GetPostString("returnreason");
  3592. CeErpTradeCell entity = null;
  3593. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3594. if (entity != null)
  3595. {
  3596. string message = "操作成功!";
  3597. string isDown = "";
  3598. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3599. {
  3600. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3601. isDown = "被点击下载";
  3602. }
  3603. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3604. {
  3605. string key = "return_order_" + entity.SupplierId;
  3606. List<string> list = new List<string>();
  3607. if (RedisHelper.HasKey(key))
  3608. {
  3609. object data = RedisHelper.StringGet(key);
  3610. list = Convert.ToString(data).Split(',').ToList();
  3611. }
  3612. list.Add(eid);
  3613. RedisHelper.StringSet(key, string.Join(",", list));
  3614. }
  3615. entity.IsVerifyToSupplier = false;
  3616. entity.IsReturn = 1;
  3617. entity.IsHaveNewOrder = 0;
  3618. entity.ReturnTime = DateTime.Now;
  3619. entity.ReturnReason = reason;
  3620. if (entity.OrderState == 6)
  3621. {
  3622. entity.OrderState = 5;
  3623. }
  3624. entity.Update();
  3625. CeErpSukuraData.createInfo(entity.ctid, 5);
  3626. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3627. returnSuccessMsg(message);
  3628. return;
  3629. }
  3630. returnErrorMsg("找不到订单记录");
  3631. }
  3632. }
  3633. public void upd_erp_toaftersaleorder()
  3634. {
  3635. if (UrlPostParmsCheck("ctid"))
  3636. {
  3637. string eid = GetPostString("ctid");
  3638. string reason = GetPostString("returnreason");
  3639. CeErpTradeCell entity = null;
  3640. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3641. if (entity != null)
  3642. {
  3643. if (entity.isAfterSaleOrder != 1)
  3644. {
  3645. returnErrorMsg("带S的售后单才能打回给售后");
  3646. return;
  3647. }
  3648. if (entity.OrderState >= 5)
  3649. {
  3650. returnErrorMsg("已经设计完成了不能打回给售后");
  3651. return;
  3652. }
  3653. entity.OrderState = 0;
  3654. entity.IsReturn = 3;
  3655. entity.ReturnTime = DateTime.Now;
  3656. entity.UpdateTime = DateTime.Now;
  3657. entity.ReturnReason = reason;
  3658. entity.Update();
  3659. CeErpSukuraData.createInfo(entity.ctid, 5);
  3660. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3661. returnSuccessMsg("操作成功!");
  3662. return;
  3663. }
  3664. returnErrorMsg("找不到订单记录");
  3665. }
  3666. }
  3667. public void upd_erp_aftersaletodesign()
  3668. {
  3669. if (UrlPostParmsCheck("ctid"))
  3670. {
  3671. string eid = GetPostString("ctid");
  3672. CeErpTradeCell entity = null;
  3673. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3674. if (entity != null)
  3675. {
  3676. entity.OrderState = 3;
  3677. entity.IsReturn = 0;
  3678. entity.UpdateTime = DateTime.Now;
  3679. entity.Update();
  3680. CeErpSukuraData.createInfo(entity.ctid, 5);
  3681. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3682. returnSuccessMsg("操作成功!");
  3683. return;
  3684. }
  3685. returnErrorMsg("找不到订单记录");
  3686. }
  3687. }
  3688. public void assign_erp_supplier()
  3689. {
  3690. if (UrlPostParmsCheck("ctid"))
  3691. {
  3692. string eids = GetPostString("ctid");
  3693. int sid = GetPostInt("SupplierName");
  3694. string fromTag = GetPostString("tag");
  3695. string[] eidList = eids.Split(',');
  3696. if (eidList.Length <= 0)
  3697. {
  3698. returnErrorMsg("指派不能为空");
  3699. return;
  3700. }
  3701. string errMsg = "";
  3702. string suname = commonHelper.getSupplierNameById(sid);
  3703. foreach (string ctid in eidList)
  3704. {
  3705. CeErpTradeCell entity = null;
  3706. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3707. if (entity != null)
  3708. {
  3709. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3710. {
  3711. errMsg += (ctid + "指派失败!!!");
  3712. continue;
  3713. }
  3714. entity.SupplierId = sid;
  3715. entity.Update();
  3716. commonHelper.UpdateRelationOrder(entity.ctid);
  3717. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3718. if (entity.OrderState >= 6)
  3719. {
  3720. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3721. //{
  3722. // string msl = entity.MakeSupplier;
  3723. // string[] mslist = msl.Split(',');
  3724. // 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);
  3725. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3726. //}
  3727. //else
  3728. //{
  3729. StringBuilder sql = new StringBuilder();
  3730. 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);
  3731. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3732. //}
  3733. }
  3734. }
  3735. else
  3736. {
  3737. continue;
  3738. }
  3739. }
  3740. if (errMsg.Length > 0)
  3741. {
  3742. returnErrorMsg(errMsg);
  3743. return;
  3744. }
  3745. returnSuccessMsg("操作成功!");
  3746. return;
  3747. }
  3748. }
  3749. public void assign_erp_makesupplier()
  3750. {
  3751. if (UrlPostParmsCheck("ctid"))
  3752. {
  3753. string eids = GetPostString("ctid");
  3754. string sname = GetPostString("SupplierName");
  3755. string[] eidList = eids.Split(',');
  3756. if (eidList.Length <= 0)
  3757. {
  3758. returnErrorMsg("指派不能为空");
  3759. return;
  3760. }
  3761. List<string> tLst = new List<string>();
  3762. foreach (string ctid in eidList)
  3763. {
  3764. CeErpTradeCell entity = null;
  3765. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3766. if (entity != null)
  3767. {
  3768. entity.MakeSupplier = sname;
  3769. entity.Update();
  3770. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3771. tLst.Add("'" + ctid + "'");
  3772. }
  3773. else
  3774. {
  3775. continue;
  3776. }
  3777. }
  3778. string ctids = string.Join(",", tLst.ToArray());
  3779. StringBuilder sql2 = new StringBuilder();
  3780. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3781. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3782. returnSuccessMsg("操作成功!");
  3783. return;
  3784. }
  3785. }
  3786. public void ins_erp_returnreason()
  3787. {
  3788. if (UrlPostParmsCheck("ctid"))
  3789. {
  3790. string eid = GetPostString("ctid");
  3791. CeErpTradeCell entity = null;
  3792. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3793. string userpost = CurrentUser.UserPost.Post.Code;
  3794. if (entity != null)
  3795. {
  3796. bool isPlace = false;
  3797. if (entity.OrderState > 6)
  3798. {
  3799. returnErrorMsg("已发货无法打回!");
  3800. return;
  3801. }
  3802. if (entity.OrderState == 6)
  3803. {
  3804. isPlace = true;
  3805. }
  3806. bool isNeedUpdateCell2 = false;
  3807. if (entity.OrderState >= 6)
  3808. {
  3809. isNeedUpdateCell2 = true;
  3810. }
  3811. int returnTag = 2;
  3812. if (userpost == "Supplier")
  3813. {
  3814. returnTag = 1;
  3815. }
  3816. int toType = GetPostInt("totype");
  3817. string fromType = "3";
  3818. if (entity.OrderState < 5)
  3819. {
  3820. fromType = "3";
  3821. }
  3822. else
  3823. {
  3824. fromType = "4";
  3825. }
  3826. if (entity.IsXianHuo == 0)
  3827. {
  3828. if (returnTag == 2)
  3829. {
  3830. if (toType == 1)
  3831. {
  3832. entity.OrderState = 0;
  3833. entity.ReturnUserType = 1;
  3834. string clearman = GetPostString("clearman");
  3835. if (!string.IsNullOrEmpty(clearman))
  3836. {
  3837. entity.DesignUserId = 0;
  3838. }
  3839. }
  3840. else
  3841. {
  3842. entity.OrderState = 3;
  3843. entity.ReturnUserType = 2;
  3844. }
  3845. entity.IsReadTag = 1;
  3846. }
  3847. else if (returnTag == 1)
  3848. {
  3849. entity.OrderState = 5;
  3850. }
  3851. entity.IsVerifyToSupplier = false;
  3852. }
  3853. if (entity.IsXianHuo == 1)
  3854. {
  3855. entity.OrderState = 5;
  3856. }
  3857. entity.UnusualTag = 0;
  3858. entity.UnusualTime = null;
  3859. entity.UnusualCon = "";
  3860. entity.IsReturn = returnTag;
  3861. entity.ReturnTime = DateTime.Now;
  3862. entity.UpdateTime = DateTime.Now;
  3863. entity.ReturnReason = GetPostString("returnreason");
  3864. entity.Update();
  3865. if (entity.OrderState == 3)
  3866. {
  3867. ApiVo apiVo = new ApiVo();
  3868. apiVo.orderNumber = entity.ctid;
  3869. apiVo.actionName = "rebutDesign";
  3870. apiVo.orderRemarks = entity.ReturnReason;
  3871. designHelper.API_WorkCore(apiVo);//rebutDesign
  3872. }
  3873. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3874. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3875. {
  3876. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3877. }
  3878. CeErpSukuraData.createInfo(entity.ctid, 5);
  3879. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3880. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3881. if (isPlace)
  3882. {
  3883. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3884. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3885. if (dth != null && dth.Rows.Count > 0)
  3886. {
  3887. dataSendOrderBean dataSendOrderBean = null;
  3888. foreach (DataRow item in dth.Rows)
  3889. {
  3890. try
  3891. {
  3892. dataSendOrderBean = new dataSendOrderBean();
  3893. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3894. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3895. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3896. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3897. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3898. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3899. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3900. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3901. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3902. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3903. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3904. dataSendOrderBean.Radio1723534706288 = "打回";
  3905. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3906. if (result != null)
  3907. {
  3908. if ("0".Equals(result.errcode))
  3909. {
  3910. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3911. }
  3912. else
  3913. {
  3914. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3915. }
  3916. }
  3917. }
  3918. catch (Exception ex)
  3919. {
  3920. }
  3921. }
  3922. }
  3923. }
  3924. if (isNeedUpdateCell2)
  3925. {
  3926. if (entity.MakeSupplier.IndexOf(",") != -1)
  3927. {
  3928. StringBuilder sql2 = new StringBuilder();
  3929. 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);
  3930. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3931. }
  3932. else
  3933. {
  3934. StringBuilder sql2 = new StringBuilder();
  3935. 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);
  3936. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3937. }
  3938. }
  3939. returnSuccessMsg("操作成功!");
  3940. return;
  3941. }
  3942. returnErrorMsg("找不到订单记录");
  3943. }
  3944. }
  3945. public void cyt_erp_returnreason()
  3946. {
  3947. if (UrlPostParmsCheck("ctid"))
  3948. {
  3949. string eid = GetPostString("ctid");
  3950. CeErpTradeCell entity = null;
  3951. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3952. string userpost = CurrentUser.UserPost.Post.Code;
  3953. if (entity != null)
  3954. {
  3955. if (entity.OrderState > 6)
  3956. {
  3957. returnErrorMsg("已发货无法打回!");
  3958. return;
  3959. }
  3960. JObject jsonObject = new JObject
  3961. {
  3962. { "Userid", "77886" },
  3963. { "Pwd", "lt666888" },
  3964. { "LTOrderId",eid }
  3965. };
  3966. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3967. JObject jsonObjects = JObject.Parse(response);
  3968. string msg = (string)jsonObjects["msg"];
  3969. if (msg != "取消成功")
  3970. {
  3971. returnErrorMsg(msg);
  3972. return;
  3973. }
  3974. bool isNeedUpdateCell2 = false;
  3975. if (entity.OrderState >= 6)
  3976. {
  3977. isNeedUpdateCell2 = true;
  3978. }
  3979. int returnTag = 2;
  3980. if (userpost == "Supplier")
  3981. {
  3982. returnTag = 1;
  3983. }
  3984. if (entity.IsXianHuo == 0)
  3985. {
  3986. if (returnTag == 2)
  3987. {
  3988. int toType = GetPostInt("totype");
  3989. if (toType == 1)
  3990. {
  3991. entity.OrderState = 0;
  3992. entity.ReturnUserType = 1;
  3993. }
  3994. else
  3995. {
  3996. entity.OrderState = 4;
  3997. entity.ReturnUserType = 2;
  3998. }
  3999. entity.IsReadTag = 1;
  4000. }
  4001. else if (returnTag == 1)
  4002. {
  4003. entity.OrderState = 5;
  4004. }
  4005. entity.IsVerifyToSupplier = false;
  4006. }
  4007. entity.UnusualTag = 0;
  4008. entity.UnusualTime = null;
  4009. entity.UnusualCon = "";
  4010. entity.IsReturn = returnTag;
  4011. entity.ReturnTime = DateTime.Now;
  4012. entity.ReturnReason = GetPostString("returnreason");
  4013. entity.Update();
  4014. if (entity.OrderState == 4)
  4015. {
  4016. ApiVo apiVo = new ApiVo();
  4017. apiVo.orderNumber = entity.ctid;
  4018. apiVo.actionName = "rebutDesign";
  4019. apiVo.orderRemarks = entity.ReturnReason;
  4020. designHelper.API_WorkCore(apiVo);//rebutDesign
  4021. }
  4022. CeErpSukuraData.createInfo(entity.ctid, 5);
  4023. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4024. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4025. if (isNeedUpdateCell2)
  4026. {
  4027. if (entity.MakeSupplier.IndexOf(",") != -1)
  4028. {
  4029. StringBuilder sql2 = new StringBuilder();
  4030. 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);
  4031. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4032. }
  4033. else
  4034. {
  4035. StringBuilder sql2 = new StringBuilder();
  4036. 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);
  4037. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4038. }
  4039. }
  4040. returnSuccessMsg("操作成功!");
  4041. return;
  4042. }
  4043. returnErrorMsg("找不到订单记录");
  4044. }
  4045. }
  4046. public void upd_erp_xianhuoreturntag()
  4047. {
  4048. if (UrlPostParmsCheck("ctid"))
  4049. {
  4050. string eids = GetPostString("ctid");
  4051. string[] ctids = eids.Split(',');
  4052. foreach (string ctid in ctids)
  4053. {
  4054. CeErpTradeCell entity = null;
  4055. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4056. if (entity != null)
  4057. {
  4058. entity.IsReturn = 0;
  4059. entity.Update();
  4060. CeErpSukuraData.createInfo(entity.ctid, 5);
  4061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4062. }
  4063. }
  4064. returnSuccessMsg("操作成功!");
  4065. return;
  4066. }
  4067. }
  4068. public void get_erp_waitdeliverylist()
  4069. {
  4070. DataStruct dStruct = GetPostStruct();
  4071. List<string> lw = new List<string>();
  4072. string tid = GetPostString("ctid");
  4073. if (tid.Length > 0)
  4074. {
  4075. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4076. if (tid.Length > 5)
  4077. {
  4078. List<string> tids = getTidByCtidLike(tid);
  4079. if (tids.Count > 0 && tids.Count < 10)
  4080. {
  4081. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4082. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4083. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4084. {
  4085. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4086. }*/
  4087. }
  4088. }
  4089. lw.Add(tid_sql);
  4090. }
  4091. string shopname = GetPostString("shopname");
  4092. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4093. string buyernick = GetPostString("buyer_nick");
  4094. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4095. //if (tid.Length == 0 && buyernick.Length == 0)
  4096. //{
  4097. // lw.Add(string.Format("IsRefund<={0}", 1));
  4098. //}
  4099. string customer = GetPostString("customer");
  4100. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4101. string design = GetPostString("design");
  4102. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4103. string orderState = GetPostString("orderState");
  4104. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4105. string address = GetPostString("address");
  4106. 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));
  4107. string sellermemo = GetPostString("seller_memo");
  4108. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4109. string supplier = GetPostString("supplier");
  4110. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4111. string OrderArea = GetPostString("order_area");
  4112. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4113. string placedate1 = GetPostString("placedate1");
  4114. string placedate2 = GetPostString("placedate2");
  4115. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4116. if (fdw.Length > 0) lw.Add(fdw);
  4117. string price1 = GetPostString("price1");
  4118. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4119. string price2 = GetPostString("price2");
  4120. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4121. string unusualCon = GetPostString("unusualcon");
  4122. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4123. string otherMemo = GetPostString("otherMemo");
  4124. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4125. string posTag = CurrentUser.UserPost.Post.Code;
  4126. if (posTag == "Supplier")
  4127. {
  4128. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4129. }
  4130. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4131. lw.Add(string.Format("type != 'PDD' "));
  4132. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4133. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4134. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4135. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4136. writeGridDataTableJson(dStruct.TotalCount, dt);
  4137. }
  4138. public void get_erp_changedeliverylist()
  4139. {
  4140. DataStruct dStruct = GetPostStruct();
  4141. List<string> lw = new List<string>();
  4142. string tid = GetPostString("ctid");
  4143. if (tid.Length > 0)
  4144. {
  4145. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4146. if (tid.Length > 5)
  4147. {
  4148. List<string> tids = getTidByCtidLike(tid);
  4149. if (tids.Count > 0 && tids.Count < 10)
  4150. {
  4151. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4152. }
  4153. }
  4154. lw.Add(tid_sql);
  4155. }
  4156. string shopname = GetPostString("shopname");
  4157. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4158. string buyernick = GetPostString("buyer_nick");
  4159. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4160. //if (tid.Length == 0 && buyernick.Length == 0)
  4161. //{
  4162. // lw.Add(string.Format("IsRefund<={0}", 1));
  4163. //}
  4164. string customer = GetPostString("customer");
  4165. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4166. string design = GetPostString("design");
  4167. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4168. string orderState = GetPostString("orderState");
  4169. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4170. string address = GetPostString("address");
  4171. 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));
  4172. string sellermemo = GetPostString("seller_memo");
  4173. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4174. string supplier = GetPostString("supplier");
  4175. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4176. string OrderArea = GetPostString("order_area");
  4177. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4178. string placedate1 = GetPostString("placedate1");
  4179. string placedate2 = GetPostString("placedate2");
  4180. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4181. if (fdw.Length > 0) lw.Add(fdw);
  4182. string price1 = GetPostString("price1");
  4183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4184. string price2 = GetPostString("price2");
  4185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4186. string unusualCon = GetPostString("unusualcon");
  4187. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4188. string otherMemo = GetPostString("otherMemo");
  4189. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4190. string posTag = CurrentUser.UserPost.Post.Code;
  4191. if (posTag == "Supplier")
  4192. {
  4193. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4194. }
  4195. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4196. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4197. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4198. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4199. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4200. /*if (tid.Length > 0)
  4201. {
  4202. List<string> tids = new List<string>();
  4203. if (dt != null && dt.Rows.Count > 0)
  4204. {
  4205. foreach (DataRow item in dt.Rows)
  4206. {
  4207. tids.Add("'" + item["tid"] + "'");
  4208. }
  4209. }
  4210. if (tids.Count > 0)
  4211. {
  4212. lw.RemoveAt(0);
  4213. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4214. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4215. dt = WebCache.GetData("view_erptradecell", dStruct);
  4216. }
  4217. }*/
  4218. writeGridDataTableJson(dStruct.TotalCount, dt);
  4219. }
  4220. public void get_erp_pddderiving()
  4221. {
  4222. DataStruct dStruct = GetPostStruct();
  4223. List<string> lw = new List<string>();
  4224. string tid = GetPostString("ctid");
  4225. if (tid.Length > 0)
  4226. {
  4227. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4228. if (tid.Length > 5)
  4229. {
  4230. List<string> tids = getTidByCtidLike(tid);
  4231. if (tids.Count > 0 && tids.Count < 10)
  4232. {
  4233. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4234. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4235. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4236. {
  4237. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4238. }*/
  4239. }
  4240. }
  4241. lw.Add(tid_sql);
  4242. }
  4243. string shopname = GetPostString("shopname");
  4244. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4245. string buyernick = GetPostString("buyer_nick");
  4246. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4247. //if (tid.Length == 0 && buyernick.Length == 0)
  4248. //{
  4249. // lw.Add(string.Format("IsRefund<={0}", 1));
  4250. //}
  4251. string customer = GetPostString("customer");
  4252. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4253. string design = GetPostString("design");
  4254. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4255. string orderState = GetPostString("orderState");
  4256. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4257. string address = GetPostString("address");
  4258. 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));
  4259. string sellermemo = GetPostString("seller_memo");
  4260. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4261. string supplier = GetPostString("supplier");
  4262. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4263. string OrderArea = GetPostString("order_area");
  4264. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4265. string placedate1 = GetPostString("placedate1");
  4266. string placedate2 = GetPostString("placedate2");
  4267. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4268. if (fdw.Length > 0) lw.Add(fdw);
  4269. string price1 = GetPostString("price1");
  4270. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4271. string price2 = GetPostString("price2");
  4272. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4273. string unusualCon = GetPostString("unusualcon");
  4274. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4275. string posTag = CurrentUser.UserPost.Post.Code;
  4276. if (posTag == "Supplier")
  4277. {
  4278. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4279. }
  4280. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4281. lw.Add(string.Format("type = 'PDD' "));
  4282. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4283. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4284. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4285. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4286. /*if (tid.Length > 0)
  4287. {
  4288. List<string> tids = new List<string>();
  4289. if (dt != null && dt.Rows.Count > 0)
  4290. {
  4291. foreach (DataRow item in dt.Rows)
  4292. {
  4293. tids.Add("'" + item["tid"] + "'");
  4294. }
  4295. }
  4296. if (tids.Count > 0)
  4297. {
  4298. lw.RemoveAt(0);
  4299. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4300. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4301. dt = WebCache.GetData("view_erptradecell", dStruct);
  4302. }
  4303. }*/
  4304. writeGridDataTableJson(dStruct.TotalCount, dt);
  4305. }
  4306. public void get_erp_jdderiving()
  4307. {
  4308. DataStruct dStruct = GetPostStruct();
  4309. List<string> lw = new List<string>();
  4310. string tid = GetPostString("ctid");
  4311. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4312. string shopname = GetPostString("shopname");
  4313. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4314. string buyernick = GetPostString("buyer_nick");
  4315. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4316. //if (tid.Length == 0 && buyernick.Length == 0)
  4317. //{
  4318. // lw.Add(string.Format("IsRefund<={0}", 1));
  4319. //}
  4320. string customer = GetPostString("customer");
  4321. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4322. string design = GetPostString("design");
  4323. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4324. string orderState = GetPostString("orderState");
  4325. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4326. string address = GetPostString("address");
  4327. 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));
  4328. string sellermemo = GetPostString("seller_memo");
  4329. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4330. string supplier = GetPostString("supplier");
  4331. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4332. string OrderArea = GetPostString("order_area");
  4333. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4334. string placedate1 = GetPostString("placedate1");
  4335. string placedate2 = GetPostString("placedate2");
  4336. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4337. if (fdw.Length > 0) lw.Add(fdw);
  4338. string price1 = GetPostString("price1");
  4339. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4340. string price2 = GetPostString("price2");
  4341. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4342. string unusualCon = GetPostString("unusualcon");
  4343. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4344. string posTag = CurrentUser.UserPost.Post.Code;
  4345. if (posTag == "Supplier")
  4346. {
  4347. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4348. }
  4349. lw.Add(string.Format("OrderState = 6 "));
  4350. lw.Add(string.Format("type = 'JD' "));
  4351. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4352. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4353. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4354. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4355. writeGridDataTableJson(dStruct.TotalCount, dt);
  4356. }
  4357. public void get_erp_demoorderlist()
  4358. {
  4359. DataStruct dStruct = GetPostStruct();
  4360. List<string> lw = new List<string>();
  4361. string tid = GetPostString("ctid");
  4362. if (tid.Length > 0)
  4363. {
  4364. string select_tid = getTidByCtid(tid);
  4365. lw.Add(string.Format("tid='{0}'", select_tid));
  4366. }
  4367. string shopname = GetPostString("shopname");
  4368. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4369. string buyernick = GetPostString("buyer_nick");
  4370. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4371. string customer = GetPostString("customer");
  4372. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4373. string design = GetPostString("design");
  4374. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4375. string orderState = GetPostString("orderState");
  4376. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4377. string address = GetPostString("address");
  4378. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4379. string sellermemo = GetPostString("seller_memo");
  4380. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4381. string supplier = GetPostString("supplier");
  4382. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4383. string OrderArea = GetPostString("order_area");
  4384. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4385. string date1 = GetPostString("date1");
  4386. string date2 = GetPostString("date2");
  4387. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4388. if (dw.Length > 0) lw.Add(dw);
  4389. string price1 = GetPostString("price1");
  4390. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4391. string price2 = GetPostString("price2");
  4392. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4393. string posTag = CurrentUser.UserPost.Post.Code;
  4394. if (posTag == "Supplier")
  4395. {
  4396. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4397. }
  4398. //lw.Add(string.Format("OrderState = 6 "));
  4399. lw.Add(string.Format("IsSample={0}", 3));
  4400. lw.Add(string.Format("IsRefund<={0}", 1));
  4401. dStruct.Order = "pay_time desc";
  4402. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4403. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4404. writeGridDataTableJson(dStruct.TotalCount, dt);
  4405. }
  4406. public void save_erp_checkmemo()
  4407. {
  4408. if (UrlPostParmsCheck("ctid"))
  4409. {
  4410. string ctid = GetPostString("ctid");
  4411. CeErpTradeCell entity = null;
  4412. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4413. if (entity != null)
  4414. {
  4415. entity.CheckMemo = GetPostString("CheckMemo");
  4416. entity.Update();
  4417. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4418. if (trade != null)
  4419. {
  4420. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4421. }
  4422. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4423. returnSuccessMsg("保存成功!");
  4424. return;
  4425. }
  4426. returnErrorMsg("找不到记录");
  4427. }
  4428. }
  4429. public void get_erp_returnlist()
  4430. {
  4431. DataStruct dStruct = GetPostStruct();
  4432. List<string> lw = new List<string>();
  4433. string tid = GetPostString("ctid");
  4434. if (tid.Length > 0)
  4435. {
  4436. string select_tid = getTidByCtid(tid);
  4437. lw.Add(string.Format("tid='{0}'", select_tid));
  4438. }
  4439. string shopname = GetPostString("shopname");
  4440. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4441. string buyernick = GetPostString("buyer_nick");
  4442. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4443. string customer = GetPostString("customer");
  4444. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4445. string design = GetPostString("design");
  4446. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4447. string orderState = GetPostString("orderState");
  4448. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4449. string address = GetPostString("address");
  4450. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4451. string sellermemo = GetPostString("seller_memo");
  4452. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4453. string supplier = GetPostString("supplier");
  4454. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4455. string date1 = GetPostString("date1");
  4456. string date2 = GetPostString("date2");
  4457. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4458. if (dw.Length > 0) lw.Add(dw);
  4459. string bdate1 = GetPostString("backdate1");
  4460. string bdate2 = GetPostString("backdate2");
  4461. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4462. if (dw_back.Length > 0) lw.Add(dw_back);
  4463. string price1 = GetPostString("price1");
  4464. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4465. string price2 = GetPostString("price2");
  4466. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4467. lw.Add(string.Format("IsReturn>0"));
  4468. lw.Add(string.Format("IsXianHuo=0"));
  4469. lw.Add(string.Format("IsReturn!=3"));
  4470. string backtype = GetPostString("backtype");
  4471. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4472. dStruct.Order = "FinishDesignTime desc";
  4473. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4474. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4475. writeGridDataTableJson(dStruct.TotalCount, dt);
  4476. }
  4477. public void get_erp_today_sumreturn()
  4478. {
  4479. DataStruct dStruct = GetPostStruct();
  4480. List<string> lw = new List<string>();
  4481. string bdate1 = GetPostString("returnTimeS");
  4482. string bdate2 = GetPostString("returnTimeE");
  4483. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4484. if (dw_back.Length > 0) lw.Add(dw_back);
  4485. lw.Add(string.Format("IsReturn=0"));
  4486. lw.Add(string.Format("IsXianHuo=0"));
  4487. string mainWhere = string.Join(" and ", lw.ToArray());
  4488. string sql = "";
  4489. if (dw_back.Length > 0)
  4490. {
  4491. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4492. }
  4493. else
  4494. {
  4495. 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 + "'";
  4496. }
  4497. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4498. decimal total = 0, today_finish = 0;
  4499. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4500. {
  4501. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4502. }
  4503. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4504. {
  4505. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4506. }
  4507. var res = new
  4508. {
  4509. data = total,
  4510. data1 = today_finish,
  4511. };
  4512. string ro_jsond = JsonConvert.SerializeObject(res);
  4513. returnSuccess(ro_jsond);
  4514. return;
  4515. }
  4516. public void get_erp_allreturnlist()
  4517. {
  4518. DataStruct dStruct = GetPostStruct();
  4519. List<string> lw = new List<string>();
  4520. string tid = GetPostString("ctid");
  4521. if (tid.Length > 0)
  4522. {
  4523. string select_tid = getTidByCtid(tid);
  4524. lw.Add(string.Format("tid='{0}'", select_tid));
  4525. }
  4526. string shopname = GetPostString("shopname");
  4527. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4528. string buyernick = GetPostString("buyer_nick");
  4529. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4530. string customer = GetPostString("customer");
  4531. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4532. string design = GetPostString("design");
  4533. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4534. string orderState = GetPostString("orderState");
  4535. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4536. string address = GetPostString("address");
  4537. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4538. string sellermemo = GetPostString("seller_memo");
  4539. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4540. string supplier = GetPostString("supplier");
  4541. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4542. string date1 = GetPostString("date1");
  4543. string date2 = GetPostString("date2");
  4544. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4545. if (dw.Length > 0) lw.Add(dw);
  4546. string bdate1 = GetPostString("backdate1");
  4547. string bdate2 = GetPostString("backdate2");
  4548. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4549. if (dw_back.Length > 0) lw.Add(dw_back);
  4550. string price1 = GetPostString("price1");
  4551. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4552. string price2 = GetPostString("price2");
  4553. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4554. string backreason = GetPostString("backreason");
  4555. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4556. lw.Add(string.Format("IsXianHuo=0"));
  4557. lw.Add(string.Format("ReturnTime != ''"));
  4558. string backtype = GetPostString("backtype");
  4559. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4560. dStruct.Order = "FinishDesignTime desc";
  4561. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4562. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4563. writeGridDataTableJson(dStruct.TotalCount, dt);
  4564. }
  4565. public void get_erp_aftersalereturnlist()
  4566. {
  4567. DataStruct dStruct = GetPostStruct();
  4568. List<string> lw = new List<string>();
  4569. string tid = GetPostString("ctid");
  4570. if (tid.Length > 0)
  4571. {
  4572. string select_tid = getTidByCtid(tid);
  4573. lw.Add(string.Format("tid='{0}'", select_tid));
  4574. }
  4575. string shopname = GetPostString("shopname");
  4576. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4577. string buyernick = GetPostString("buyer_nick");
  4578. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4579. string customer = GetPostString("customer");
  4580. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4581. string design = GetPostString("design");
  4582. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4583. string orderState = GetPostString("orderState");
  4584. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4585. string address = GetPostString("address");
  4586. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4587. string sellermemo = GetPostString("seller_memo");
  4588. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4589. string supplier = GetPostString("supplier");
  4590. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4591. string date1 = GetPostString("date1");
  4592. string date2 = GetPostString("date2");
  4593. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4594. if (dw.Length > 0) lw.Add(dw);
  4595. string bdate1 = GetPostString("backdate1");
  4596. string bdate2 = GetPostString("backdate2");
  4597. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4598. if (dw_back.Length > 0) lw.Add(dw_back);
  4599. string price1 = GetPostString("price1");
  4600. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4601. string price2 = GetPostString("price2");
  4602. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4603. lw.Add(string.Format("IsReturn=3"));
  4604. string backtype = GetPostString("backtype");
  4605. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4606. string backreason = GetPostString("backreason");
  4607. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4608. dStruct.Order = "ReturnTime desc";
  4609. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4610. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4611. writeGridDataTableJson(dStruct.TotalCount, dt);
  4612. }
  4613. public void get_erp_xianhuoreturnlist()
  4614. {
  4615. DataStruct dStruct = GetPostStruct();
  4616. List<string> lw = new List<string>();
  4617. string tid = GetPostString("ctid");
  4618. if (tid.Length > 0)
  4619. {
  4620. string select_tid = getTidByCtid(tid);
  4621. lw.Add(string.Format("tid='{0}'", select_tid));
  4622. }
  4623. string shopname = GetPostString("shopname");
  4624. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4625. string buyernick = GetPostString("buyer_nick");
  4626. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4627. string customer = GetPostString("customer");
  4628. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4629. string design = GetPostString("design");
  4630. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4631. string orderState = GetPostString("orderState");
  4632. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4633. string address = GetPostString("address");
  4634. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4635. string sellermemo = GetPostString("seller_memo");
  4636. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4637. string supplier = GetPostString("supplier");
  4638. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4639. string OrderArea = GetPostString("order_area");
  4640. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4641. string date1 = GetPostString("date1");
  4642. string date2 = GetPostString("date2");
  4643. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4644. if (dw.Length > 0) lw.Add(dw);
  4645. string price1 = GetPostString("price1");
  4646. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4647. string price2 = GetPostString("price2");
  4648. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4649. string posTag = CurrentUser.UserPost.Post.Code;
  4650. if (posTag == "Supplier")
  4651. {
  4652. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4653. }
  4654. lw.Add(string.Format("OrderState=6 "));
  4655. lw.Add(string.Format("IsXianHuo=1 "));
  4656. lw.Add(string.Format("IsReturn>0 "));
  4657. lw.Add(string.Format("IsReturn!=3"));
  4658. lw.Add(string.Format("IsRefund<={0}", 1));
  4659. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4661. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4662. writeGridDataTableJson(dStruct.TotalCount, dt);
  4663. }
  4664. public void set_erp_orderdelivery()
  4665. {
  4666. if (UrlPostParmsCheck("ctid"))
  4667. {
  4668. string eid = GetPostString("ctid");
  4669. CeErpTradeCell entity = null;
  4670. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4671. if (entity != null)
  4672. {
  4673. if (entity.OrderState >= 7)
  4674. {
  4675. returnErrorMsg("此单已发货,无需重复发货");
  4676. return;
  4677. }
  4678. if (entity.OrderState != 6)
  4679. {
  4680. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4681. return;
  4682. }
  4683. string shop = GetPostString("seller_nick");
  4684. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4685. string comName = GetPostString("comName");
  4686. string comCode = GetPostString("comCode");
  4687. string outSid = GetPostString("outSid");
  4688. string deliveryType = GetPostString("deliveryType");
  4689. string deliveryMemo = GetPostString("deliveryMemo");
  4690. outSid = outSid.Trim();
  4691. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4692. if (mainEn == null)
  4693. {
  4694. returnErrorMsg("找不到原始订单记录");
  4695. return;
  4696. }
  4697. bool isInitOrderDeliv = false;
  4698. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4699. {
  4700. isInitOrderDeliv = true;
  4701. }
  4702. string apires = "";
  4703. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4704. 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)
  4705. {
  4706. apires = "发货成功true";
  4707. }
  4708. else
  4709. {
  4710. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4711. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4712. }
  4713. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4714. {
  4715. entity.OrderState = 7;//发货后订单已发货
  4716. entity.OutSid = outSid;
  4717. entity.MemoOpt = 0;
  4718. entity.UpdateTime = DateTime.Now;
  4719. entity.FinishDeliveryTime = DateTime.Now;
  4720. entity.Update();
  4721. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4722. commonHelper.UpdateRelationOrder(entity.ctid);
  4723. //还要插入快递信息到 快递信息表
  4724. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4725. exinfo.tid = eid;
  4726. exinfo.out_sid = outSid;
  4727. exinfo.company_code = comCode;
  4728. exinfo.company_name = comName;
  4729. exinfo.delivery_memo = deliveryMemo;
  4730. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4731. exinfo.deliveryType = deliveryType;
  4732. exinfo.Create();
  4733. returnSuccessMsg("发货操作成功!");
  4734. commonHelper.UpdateRelationOrder(entity.ctid);
  4735. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4736. CeErpSukuraData.createInfo(entity.ctid, 4);
  4737. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  4738. {
  4739. commonHelper.sendCytExpress(exinfo);
  4740. }
  4741. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4742. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4743. }
  4744. else
  4745. {
  4746. string errmsg = commonHelper.KeepChinese(apires);
  4747. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4748. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4749. }
  4750. return;
  4751. }
  4752. returnErrorMsg("找不到订单记录");
  4753. }
  4754. }
  4755. public void set_erp_multidelivery()
  4756. {
  4757. string eids = GetPostString("tids");
  4758. string[] eidList = eids.Split(',');
  4759. if (eidList.Length <= 0)
  4760. {
  4761. returnErrorMsg("发货不能为空");
  4762. return;
  4763. }
  4764. foreach (string ctid in eidList)
  4765. {
  4766. if (ctid.Length <= 0) continue;
  4767. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4768. if (expInfo != null)
  4769. {
  4770. StringBuilder sql = new StringBuilder();
  4771. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4772. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4773. if (dt.Rows.Count > 0)
  4774. {
  4775. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4776. {
  4777. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4778. expInfo.state = "异常";
  4779. expInfo.isMultiDelivery = 1;
  4780. expInfo.Update();
  4781. continue;
  4782. }
  4783. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4784. {
  4785. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4786. expInfo.state = "异常";
  4787. expInfo.Update();
  4788. continue;
  4789. }
  4790. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4791. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4792. bool isInitOrderDeliv = false;
  4793. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4794. {
  4795. isInitOrderDeliv = true;
  4796. expInfo.isMultiDelivery = 1;
  4797. }
  4798. if (ctid.IndexOf("N") != -1)
  4799. {
  4800. StringBuilder sqlbucha = new StringBuilder();
  4801. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4802. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4803. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4804. commonHelper.UpdateRelationOrder(ctid);
  4805. expInfo.delivery_memo = "发货成功";
  4806. expInfo.state = "发货成功";
  4807. expInfo.isMultiDelivery = 1;
  4808. expInfo.Update();
  4809. }
  4810. else
  4811. {
  4812. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4813. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4814. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4815. {
  4816. expInfo.delivery_memo = "发货成功";
  4817. expInfo.state = "发货成功";
  4818. expInfo.isMultiDelivery = 1;
  4819. expInfo.Update();
  4820. commonHelper.UpdateRelationOrder(ctid);
  4821. CeErpSukuraData.createInfo(ctid, 4);
  4822. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4823. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4824. }
  4825. else
  4826. {
  4827. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4828. expInfo.state = "异常";
  4829. expInfo.Update();
  4830. }
  4831. }
  4832. }
  4833. }
  4834. }
  4835. returnSuccessMsg("操作完成");
  4836. }
  4837. public void reset_erp_memoopt()
  4838. {
  4839. if (UrlPostParmsCheck("ctid"))
  4840. {
  4841. string eid = GetPostString("ctid");
  4842. CeErpTradeCell entity = null;
  4843. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4844. if (entity != null)
  4845. {
  4846. string stropt = "";
  4847. if (entity.MemoOpt == 1)
  4848. {
  4849. stropt = "“改稿”";
  4850. }
  4851. else if (entity.MemoOpt == 2)
  4852. {
  4853. stropt = "“定稿”";
  4854. }
  4855. else if (entity.MemoOpt == 3)
  4856. {
  4857. stropt = "“完成查货”";
  4858. CeErpSukuraData.createInfo(entity.ctid, 6);
  4859. }
  4860. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4861. entity.UpdateTime = DateTime.Now;
  4862. entity.MemoOpt = 0;
  4863. entity.Update();
  4864. returnSuccessMsg("操作成功!");
  4865. return;
  4866. }
  4867. returnErrorMsg("找不到记录");
  4868. }
  4869. }
  4870. public void get_erp_deliveryunusual()
  4871. {
  4872. DataStruct dStruct = GetPostStruct();
  4873. List<string> lw = new List<string>();
  4874. string tid = GetPostString("ctid");
  4875. if (tid.Length > 0)
  4876. {
  4877. string select_tid = getTidByCtid(tid);
  4878. lw.Add(string.Format("tid='{0}'", select_tid));
  4879. }
  4880. string shopname = GetPostString("shopname");
  4881. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4882. string buyernick = GetPostString("buyer_nick");
  4883. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4884. string customer = GetPostString("customer");
  4885. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4886. string design = GetPostString("design");
  4887. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4888. string sellermemo = GetPostString("seller_memo");
  4889. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4890. string supplier = GetPostString("supplier");
  4891. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4892. string date1 = GetPostString("date1");
  4893. string date2 = GetPostString("date2");
  4894. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4895. if (dw.Length > 0) lw.Add(dw);
  4896. string placedate1 = GetPostString("placedate1");
  4897. string placedate2 = GetPostString("placedate2");
  4898. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4899. if (dw_place.Length > 0) lw.Add(dw_place);
  4900. string price1 = GetPostString("price1");
  4901. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4902. string price2 = GetPostString("price2");
  4903. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4904. string unusualCon = GetPostString("unusualcon");
  4905. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4906. string posTag = CurrentUser.UserPost.Post.Code;
  4907. if (posTag == "Supplier")
  4908. {
  4909. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4910. }
  4911. lw.Add(string.Format("OrderState = 6"));
  4912. lw.Add(string.Format("UnusualTag = 5"));
  4913. lw.Add(string.Format("IsRefund<={0}", 1));
  4914. dStruct.Order = "FinishPlaceTime desc";
  4915. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4916. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4917. writeGridDataTableJson(dStruct.TotalCount, dt);
  4918. }
  4919. public void get_erp_deliveryedlist()
  4920. {
  4921. DataStruct dStruct = GetPostStruct();
  4922. List<string> lw = new List<string>();
  4923. string tid = GetPostString("ctid");
  4924. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4925. string shopname = GetPostString("shopname");
  4926. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4927. string buyernick = GetPostString("buyer_nick");
  4928. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4929. string customer = GetPostString("customer");
  4930. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4931. string design = GetPostString("design");
  4932. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4933. string sellermemo = GetPostString("seller_memo");
  4934. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4935. string logistics = GetPostString("logistics");
  4936. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4937. string date1 = GetPostString("date1");
  4938. string date2 = GetPostString("date2");
  4939. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4940. //if (dw.Length > 0) lw.Add(dw);
  4941. string placedate1 = GetPostString("placedate1");
  4942. string placedate2 = GetPostString("placedate2");
  4943. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4944. if (fdw.Length > 0) lw.Add(fdw);
  4945. string devdate1 = GetPostString("deliverydate1");
  4946. string devdate2 = GetPostString("deliverydate2");
  4947. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4948. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4949. string price1 = GetPostString("price1");
  4950. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4951. string price2 = GetPostString("price2");
  4952. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4953. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4954. {
  4955. if (tid.Length > 0)
  4956. {
  4957. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4958. if (tid.Length > 5)
  4959. {
  4960. List<string> tids = getTidByCtidLike(tid);
  4961. if (tids.Count > 0 && tids.Count < 10)
  4962. {
  4963. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4964. }
  4965. }
  4966. lw.Add(tid_sql);
  4967. }
  4968. if (buyernick.Length > 0)
  4969. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4970. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4971. if (dw.Length > 0) lw.Add(dw);
  4972. }
  4973. else
  4974. {
  4975. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  4976. }
  4977. string posTag = CurrentUser.UserPost.Post.Code;
  4978. if (posTag == "Supplier")
  4979. {
  4980. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4981. }
  4982. else
  4983. {
  4984. string supplier = GetPostString("supplier");
  4985. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4986. }
  4987. lw.Add(string.Format(" OrderState IN (7, 8)"));
  4988. lw.Add(string.Format("type != 'PDD' "));
  4989. lw.Add(string.Format("IsRefund!={0}", 2));
  4990. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4991. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4992. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4993. /*if (tid.Length > 0)
  4994. {
  4995. List<string> tids = new List<string>();
  4996. if (dt != null && dt.Rows.Count > 0)
  4997. {
  4998. foreach (DataRow item in dt.Rows)
  4999. {
  5000. tids.Add("'" + item["tid"] + "'");
  5001. }
  5002. }
  5003. if (tids.Count > 0)
  5004. {
  5005. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5006. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5007. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5008. dt = WebCache.GetData("view_erptradecell", dStruct);
  5009. }
  5010. }*/
  5011. if (dt != null)
  5012. {
  5013. foreach (DataRow dr in dt.Rows)
  5014. {
  5015. 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();
  5016. }
  5017. }
  5018. writeGridDataTableJson(dStruct.TotalCount, dt);
  5019. }
  5020. public void get_erp_pdddeliveryed()
  5021. {
  5022. DataStruct dStruct = GetPostStruct();
  5023. List<string> lw = new List<string>();
  5024. string tid = GetPostString("ctid");
  5025. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5026. string shopname = GetPostString("shopname");
  5027. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5028. string buyernick = GetPostString("buyer_nick");
  5029. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5030. string customer = GetPostString("customer");
  5031. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5032. string design = GetPostString("design");
  5033. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5034. string sellermemo = GetPostString("seller_memo");
  5035. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5036. string logistics = GetPostString("logistics");
  5037. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5038. string date1 = GetPostString("date1");
  5039. string date2 = GetPostString("date2");
  5040. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5041. //if (dw.Length > 0) lw.Add(dw);
  5042. string placedate1 = GetPostString("placedate1");
  5043. string placedate2 = GetPostString("placedate2");
  5044. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5045. if (fdw.Length > 0) lw.Add(fdw);
  5046. string devdate1 = GetPostString("deliverydate1");
  5047. string devdate2 = GetPostString("deliverydate2");
  5048. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5049. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5050. string price1 = GetPostString("price1");
  5051. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5052. string price2 = GetPostString("price2");
  5053. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5054. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5055. {
  5056. if (tid.Length > 0)
  5057. {
  5058. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5059. if (tid.Length > 5)
  5060. {
  5061. List<string> tids = getTidByCtidLike(tid);
  5062. if (tids.Count > 0 && tids.Count < 10)
  5063. {
  5064. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5065. }
  5066. }
  5067. lw.Add(tid_sql);
  5068. }
  5069. if (buyernick.Length > 0)
  5070. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5071. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5072. if (dw.Length > 0) lw.Add(dw);
  5073. }
  5074. else
  5075. {
  5076. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5077. }
  5078. string posTag = CurrentUser.UserPost.Post.Code;
  5079. if (posTag == "Supplier")
  5080. {
  5081. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5082. }
  5083. else
  5084. {
  5085. string supplier = GetPostString("supplier");
  5086. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5087. }
  5088. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5089. lw.Add(string.Format("type = 'PDD' "));
  5090. lw.Add(string.Format("IsRefund!={0}", 2));
  5091. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5092. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5093. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5094. /* if (tid.Length > 0)
  5095. {
  5096. List<string> tids = new List<string>();
  5097. if (dt != null && dt.Rows.Count > 0)
  5098. {
  5099. foreach (DataRow item in dt.Rows)
  5100. {
  5101. tids.Add("'" + item["tid"] + "'");
  5102. }
  5103. }
  5104. if (tids.Count > 0)
  5105. {
  5106. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5107. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5108. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5109. dt = WebCache.GetData("view_erptradecell", dStruct);
  5110. }
  5111. }*/
  5112. foreach (DataRow dr in dt.Rows)
  5113. {
  5114. 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();
  5115. }
  5116. writeGridDataTableJson(dStruct.TotalCount, dt);
  5117. }
  5118. public void get_erp_jddeliveryed()
  5119. {
  5120. DataStruct dStruct = GetPostStruct();
  5121. List<string> lw = new List<string>();
  5122. string tid = GetPostString("ctid");
  5123. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5124. string shopname = GetPostString("shopname");
  5125. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5126. string buyernick = GetPostString("buyer_nick");
  5127. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5128. string customer = GetPostString("customer");
  5129. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5130. string design = GetPostString("design");
  5131. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5132. string sellermemo = GetPostString("seller_memo");
  5133. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5134. string date1 = GetPostString("date1");
  5135. string date2 = GetPostString("date2");
  5136. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5137. //if (dw.Length > 0) lw.Add(dw);
  5138. string placedate1 = GetPostString("placedate1");
  5139. string placedate2 = GetPostString("placedate2");
  5140. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5141. if (fdw.Length > 0) lw.Add(fdw);
  5142. string devdate1 = GetPostString("deliverydate1");
  5143. string devdate2 = GetPostString("deliverydate2");
  5144. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5145. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5146. string price1 = GetPostString("price1");
  5147. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5148. string price2 = GetPostString("price2");
  5149. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5150. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5151. {
  5152. if (tid.Length > 0)
  5153. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5154. if (buyernick.Length > 0)
  5155. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5156. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5157. if (dw.Length > 0) lw.Add(dw);
  5158. }
  5159. else
  5160. {
  5161. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5162. }
  5163. string posTag = CurrentUser.UserPost.Post.Code;
  5164. if (posTag == "Supplier")
  5165. {
  5166. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5167. }
  5168. else
  5169. {
  5170. string supplier = GetPostString("supplier");
  5171. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5172. }
  5173. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5174. lw.Add(string.Format("type = 'JD' "));
  5175. lw.Add(string.Format("IsRefund!={0}", 2));
  5176. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5177. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5178. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5179. foreach (DataRow dr in dt.Rows)
  5180. {
  5181. 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();
  5182. }
  5183. writeGridDataTableJson(dStruct.TotalCount, dt);
  5184. }
  5185. public void get_erp_allplacelist()
  5186. {
  5187. DataStruct dStruct = GetPostStruct();
  5188. List<string> lw = new List<string>();
  5189. string tid = GetPostString("ctid");
  5190. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5191. string shopname = GetPostString("shopname");
  5192. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5193. string buyernick = GetPostString("buyer_nick");
  5194. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5195. string customer = GetPostString("customer");
  5196. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5197. string design = GetPostString("design");
  5198. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5199. string sellermemo = GetPostString("seller_memo");
  5200. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5201. string supplier = GetPostString("supplier");
  5202. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5203. string date1 = GetPostString("date1");
  5204. string date2 = GetPostString("date2");
  5205. string pldate1 = GetPostString("placedate1");
  5206. string pldate2 = GetPostString("placedate2");
  5207. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5208. //if (dw.Length > 0) lw.Add(dw);
  5209. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5210. {
  5211. if (tid.Length > 0)
  5212. {
  5213. string select_tid = getTidByCtid(tid);
  5214. lw.Add(string.Format("tid='{0}'", select_tid));
  5215. }
  5216. if (buyernick.Length > 0)
  5217. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5218. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5219. if (dw.Length > 0) lw.Add(dw);
  5220. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5221. if (dw_place.Length > 0) lw.Add(dw_place);
  5222. }
  5223. else
  5224. {
  5225. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5226. {
  5227. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5228. }
  5229. }
  5230. string price1 = GetPostString("price1");
  5231. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5232. string price2 = GetPostString("price2");
  5233. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5234. string posTag = CurrentUser.UserPost.Post.Code;
  5235. if (posTag == "Supplier")
  5236. {
  5237. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5238. }
  5239. lw.Add(string.Format("OrderState >= 6"));
  5240. lw.Add(string.Format("IsSample != 2 "));
  5241. //lw.Add(string.Format("isDianziOrder = 0 "));
  5242. lw.Add(string.Format("SupplierId > 0 "));
  5243. //lw.Add(string.Format("IsRefund<={0}", 1));
  5244. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5246. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5247. foreach (DataRow dr in dt.Rows)
  5248. {
  5249. 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();
  5250. }
  5251. writeGridDataTableJson(dStruct.TotalCount, dt);
  5252. }
  5253. public void get_erp_financeallplacelist()
  5254. {
  5255. DataStruct dStruct = GetPostStruct();
  5256. List<string> lw = new List<string>();
  5257. string tid = GetPostString("ctid");
  5258. string shopname = GetPostString("shopname");
  5259. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5260. string buyernick = GetPostString("buyer_nick");
  5261. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5262. string customer = GetPostString("customer");
  5263. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5264. string design = GetPostString("design");
  5265. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5266. string sellermemo = GetPostString("seller_memo");
  5267. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5268. string supplier = GetPostString("supplier");
  5269. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5270. string date1 = GetPostString("date1");
  5271. string date2 = GetPostString("date2");
  5272. string pldate1 = GetPostString("placedate1");
  5273. string pldate2 = GetPostString("placedate2");
  5274. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5275. {
  5276. if (tid.Length > 0)
  5277. {
  5278. string select_tid = getTidByCtid(tid);
  5279. lw.Add(string.Format("tid='{0}'", select_tid));
  5280. }
  5281. if (buyernick.Length > 0)
  5282. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5283. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5284. if (dw.Length > 0) lw.Add(dw);
  5285. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5286. if (dw_place.Length > 0) lw.Add(dw_place);
  5287. }
  5288. else
  5289. {
  5290. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5291. {
  5292. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5293. }
  5294. }
  5295. string price1 = GetPostString("price1");
  5296. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5297. string price2 = GetPostString("price2");
  5298. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5299. string posTag = CurrentUser.UserPost.Post.Code;
  5300. if (posTag == "Supplier")
  5301. {
  5302. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5303. }
  5304. //lw.Add(string.Format("OrderState >= 6"));
  5305. lw.Add(string.Format("IsSample != 2 "));
  5306. lw.Add(string.Format("isDianziOrder = 0 "));
  5307. //lw.Add(string.Format("IsRefund<={0}", 1));
  5308. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5309. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5310. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5311. foreach (DataRow dr in dt.Rows)
  5312. {
  5313. 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();
  5314. }
  5315. writeGridDataTableJson(dStruct.TotalCount, dt);
  5316. }
  5317. public void get_erp_expresslist()
  5318. {
  5319. int listtype = GetInt("ltype");
  5320. DataStruct dStruct = GetPostStruct();
  5321. List<string> lw = new List<string>();
  5322. string tid = GetPostString("tid");
  5323. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5324. string outsid = GetPostString("out_sid");
  5325. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5326. string importer = GetPostString("ImportUserName");
  5327. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5328. string file = GetPostString("import_file");
  5329. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5330. string printman = GetPostString("printman");
  5331. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5332. string date1 = GetPostString("date1");
  5333. string date2 = GetPostString("date2");
  5334. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5335. if (dw.Length > 0) lw.Add(dw);
  5336. string fdate1 = GetPostString("finishdate1");
  5337. string fdate2 = GetPostString("finishdate2");
  5338. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5339. if (fdw.Length > 0) lw.Add(fdw);
  5340. string supplierId = GetPostString("supplierId");
  5341. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5342. if (listtype == 1)
  5343. {
  5344. lw.Add(string.Format("importUserId !=0"));
  5345. }
  5346. string posTag = CurrentUser.UserPost.Post.Code;
  5347. if (posTag == "Supplier")
  5348. {
  5349. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5350. }
  5351. if (dStruct.PageSize != 100000)
  5352. {
  5353. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5354. }
  5355. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5356. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5357. writeGridDataTableJson(dStruct.TotalCount, dt);
  5358. }
  5359. public void set_erp_buchaorderdelivery()
  5360. {
  5361. if (UrlPostParmsCheck("ctid"))
  5362. {
  5363. string eid = GetPostString("ctid");
  5364. CeErpTradeCell entity = null;
  5365. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5366. if (entity != null)
  5367. {
  5368. if (entity.IsSample != 2)
  5369. {
  5370. returnErrorMsg("补差价单才能标记为已发货");
  5371. return;
  5372. }
  5373. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5374. entity.OrderState = 7;
  5375. entity.Update();
  5376. returnSuccessMsg("操作成功!");
  5377. return;
  5378. }
  5379. returnErrorMsg("找不到记录");
  5380. }
  5381. }
  5382. public void get_stdtemplates()
  5383. {
  5384. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5385. //string res = taobaoHelper.test();
  5386. string res = apiHelper.API_PrintTemplate();
  5387. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5388. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5389. {
  5390. int sidx = res.IndexOf("error_code");
  5391. int eidx = res.IndexOf("success");
  5392. string msg = res.Substring(sidx, eidx - sidx);
  5393. returnErrorMsg(msg);
  5394. return;
  5395. }
  5396. if (res.Length <= 0)
  5397. {
  5398. returnErrorMsg("模板数据为空!");
  5399. return;
  5400. }
  5401. ReturnSuccess(res);
  5402. }
  5403. public void cancel_print_order()
  5404. {
  5405. if (UrlPostParmsCheck("ctid"))
  5406. {
  5407. string ctid = GetPostString("ctid");
  5408. CeErpTradeCell entity = null;
  5409. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5410. if (entity != null)
  5411. {
  5412. string res = "";
  5413. string code = entity.LastBillWaybillCode;
  5414. if (code == "")
  5415. {
  5416. code = entity.OutSid;
  5417. }
  5418. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5419. XLog.SaveLog(0, "取消面单" + res);
  5420. }
  5421. }
  5422. }
  5423. public void set_erp_printwaybill()
  5424. {
  5425. if (UrlPostParmsCheck("ctid"))
  5426. {
  5427. string ctid = GetPostString("ctid");
  5428. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5429. string cpName = GetPostString("cpname");
  5430. string isTogether = GetPostString("together");
  5431. string printType = GetPostString("printType");
  5432. //var res_obj = new
  5433. //{
  5434. // restype = 1,
  5435. // 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\"}"
  5436. //};
  5437. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5438. //ReturnSuccess(ro_json);
  5439. //return;
  5440. bool isUseLastWayBillCode = false;
  5441. CeErpTradeCell entity = null;
  5442. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5443. if (entity != null)
  5444. {
  5445. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5446. {
  5447. isUseLastWayBillCode = true;
  5448. }
  5449. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5450. {
  5451. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5452. return;
  5453. }
  5454. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5455. {
  5456. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5457. return;
  5458. }
  5459. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5460. {
  5461. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5462. return;
  5463. }
  5464. }
  5465. string res = "";
  5466. Api_waybill_code_response_Obj fullObj = null;
  5467. string pData_str = "";
  5468. string curUseWayBillCode = "";
  5469. if (isUseLastWayBillCode == false)
  5470. {
  5471. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5472. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5473. if (res.IndexOf("failure") != -1)
  5474. {
  5475. //int idx = res.IndexOf("sub_message");
  5476. //int idx2 = res.IndexOf("flag");
  5477. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5478. string errMsgNeed = commonHelper.KeepChinese(res);
  5479. var res_objd = new
  5480. {
  5481. restype = 0,
  5482. data = "获取面单失败" + errMsgNeed
  5483. };
  5484. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5485. returnSuccess(ro_jsond);
  5486. if (res.IndexOf("停发") != -1)
  5487. {
  5488. entity.UnusualCon = "物流停发";
  5489. entity.Update();
  5490. }
  5491. //returnErrorMsg("获取面单失败,"+emsg);
  5492. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5493. return;
  5494. }
  5495. else if (res.IndexOf("errorMsg") != -1)
  5496. {
  5497. //int idx = res.IndexOf("errorMsg");
  5498. //int idx2 = res.IndexOf("}]}");
  5499. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5500. string errMsgNeed = commonHelper.KeepChinese(res);
  5501. var res_objf = new
  5502. {
  5503. restype = 0,
  5504. data = "获取面单失败2" + errMsgNeed
  5505. };
  5506. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5507. if (res.IndexOf("停发") != -1)
  5508. {
  5509. entity.UnusualCon = "物流停发";
  5510. entity.Update();
  5511. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5512. if (trade != null)
  5513. {
  5514. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5515. }
  5516. }
  5517. returnSuccess(ro_jsonf);
  5518. //returnErrorMsg("获取面单失败," + emsg);
  5519. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5520. return;
  5521. }
  5522. try
  5523. {
  5524. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5525. //res = res.Replace(" ", "");
  5526. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5527. }
  5528. catch (Exception ex)
  5529. {
  5530. XLog.SaveLog(0, "生成fullObj" + res);
  5531. var res_objf = new
  5532. {
  5533. restype = 0,
  5534. data = "生成fullObj发生错误" + ex.Message
  5535. };
  5536. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5537. returnSuccess(ro_jsonf);
  5538. return;
  5539. }
  5540. if (fullObj.response.data.content.Count > 0)
  5541. {
  5542. ContentItem codeObj = fullObj.response.data.content[0];
  5543. if (cpCode.IndexOf("SFFQ-") != -1)
  5544. {
  5545. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5546. }
  5547. else
  5548. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5549. curUseWayBillCode = codeObj.waybillCode;
  5550. }
  5551. else
  5552. {
  5553. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5554. var res_objf = new
  5555. {
  5556. restype = 0,
  5557. data = "生成fullObj找不到快递单号waybillCode"
  5558. };
  5559. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5560. returnSuccess(ro_jsonf);
  5561. return;
  5562. }
  5563. }
  5564. else
  5565. {
  5566. //使用上次打印的快递单号
  5567. if (cpCode == "SFFQ-LY")
  5568. {
  5569. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5570. }
  5571. else
  5572. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5573. curUseWayBillCode = entity.LastBillWaybillCode;
  5574. }
  5575. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5576. {
  5577. var res_obje = new
  5578. {
  5579. restype = 0,
  5580. data = "获取加密打印数据失败"
  5581. };
  5582. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5583. returnSuccess(ro_jsone);
  5584. entity.LastBillCpCode = cpCode;
  5585. entity.LastBillWaybillCode = curUseWayBillCode;
  5586. entity.Update();
  5587. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5588. //returnErrorMsg("获取加密打印数据失败");
  5589. return;
  5590. }
  5591. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5592. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5593. string btnType = "";
  5594. string errorMsg = "";
  5595. if (entity != null)
  5596. {
  5597. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5598. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5599. //cpcode是 YTO-CAINIAO
  5600. //string comCode = cpCode.Split('-')[0].ToString();
  5601. string apires = "";
  5602. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5603. //isTogether=2是新的合包弹窗
  5604. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5605. {
  5606. if (ctid.IndexOf("N") != -1)
  5607. {
  5608. apires = "发货成功";
  5609. }
  5610. else
  5611. {
  5612. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5613. }
  5614. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5615. //打单后发货
  5616. StringBuilder sql = new StringBuilder();
  5617. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5618. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5619. {
  5620. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5621. }
  5622. else
  5623. {
  5624. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5625. }
  5626. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5627. foreach (DataRow row in dt.Rows)
  5628. {
  5629. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5630. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5631. {
  5632. try
  5633. {
  5634. btnType = "待发货";
  5635. entity.OutSid = curUseWayBillCode;
  5636. entity.OrderState = 7;
  5637. entity.IsUrgency = false;
  5638. entity.LastBillCpCode = "";
  5639. entity.LastBillWaybillCode = "";
  5640. entity.FinishDeliveryTime = DateTime.Now;
  5641. entity.IsReturn = 0;
  5642. entity.MemoOpt = 0;
  5643. entity.UpdateTime = DateTime.Now;
  5644. entity.Update();
  5645. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5646. //还要插入快递信息到 快递信息表
  5647. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5648. exinfo.tid = entity.ctid;
  5649. exinfo.out_sid = curUseWayBillCode;
  5650. exinfo.company_code = cpCode;
  5651. exinfo.company_name = cpName;
  5652. exinfo.supplierUserName = supplierName;
  5653. exinfo.deliveryType = "发货成功";
  5654. exinfo.print_time = DateTime.Now;
  5655. exinfo.printUser = CurrentUser.UserName;
  5656. exinfo.postData = pData_str;
  5657. exinfo.Create();
  5658. commonHelper.UpdateRelationOrder(entity.ctid);
  5659. CeErpSukuraData.createInfo(ctid, 4);
  5660. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5661. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5662. {
  5663. commonHelper.sendCytExpress(exinfo);
  5664. }
  5665. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5666. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5667. }
  5668. catch (Exception ex)
  5669. {
  5670. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5671. }
  5672. }
  5673. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5674. {
  5675. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5676. if (entity.OrderState == 6)
  5677. {
  5678. entity.OrderState = 7;
  5679. }
  5680. entity.UpdateTime = DateTime.Now;
  5681. entity.FinishDeliveryTime = DateTime.Now;
  5682. btnType = "已发货";
  5683. entity.Update();
  5684. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5685. exinfo.tid = entity.ctid;
  5686. exinfo.out_sid = curUseWayBillCode;
  5687. exinfo.company_code = cpCode;
  5688. exinfo.company_name = cpName;
  5689. exinfo.supplierUserName = supplierName;
  5690. exinfo.deliveryType = "发货成功";
  5691. exinfo.print_time = DateTime.Now;
  5692. exinfo.printUser = CurrentUser.UserName;
  5693. exinfo.postData = pData_str;
  5694. exinfo.Create();
  5695. commonHelper.UpdateRelationOrder(entity.ctid);
  5696. CeErpSukuraData.createInfo(entity.ctid, 4);
  5697. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5698. {
  5699. commonHelper.sendCytExpress(exinfo);
  5700. }
  5701. //不处理
  5702. }
  5703. else
  5704. {
  5705. entity.UpdateTime = DateTime.Now;
  5706. entity.LastBillCpCode = cpCode;
  5707. entity.LastBillWaybillCode = curUseWayBillCode;
  5708. entity.Update();
  5709. string errmsg = commonHelper.KeepChinese(apires);
  5710. var res_objz = new
  5711. {
  5712. restype = 0,
  5713. data = "打单后发货失败"
  5714. };
  5715. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5716. returnSuccess(ro_jsonz);
  5717. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5718. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5719. return;
  5720. }
  5721. }
  5722. }
  5723. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5724. {
  5725. string ctids = GetPostString("ctids");
  5726. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5727. List<string> list = new List<string>();
  5728. List<string> send_list = new List<string>();
  5729. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5730. CeErpTrade ceErpTrade = new CeErpTrade();
  5731. //可合包的合并一起发货
  5732. if (dt == null && string.IsNullOrEmpty(ctids))
  5733. {
  5734. var res_objz = new
  5735. {
  5736. restype = 0,
  5737. data = "打单后发货失败"
  5738. };
  5739. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5740. returnSuccess(ro_jsonz);
  5741. return;
  5742. }
  5743. if (!string.IsNullOrEmpty(ctids))
  5744. {
  5745. StringBuilder sql = new StringBuilder();
  5746. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5747. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5748. }
  5749. foreach (DataRow row in dt.Rows)
  5750. {
  5751. list.Add("'" + row["ctid"] + "'");
  5752. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5753. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5754. if (ctid.IndexOf("N") != -1)
  5755. {
  5756. apires = "发货成功";
  5757. }
  5758. else
  5759. {
  5760. if (!send_list.Contains(ceErpTrade.tid))
  5761. {
  5762. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5763. }
  5764. else
  5765. {
  5766. apires = "发货成功";
  5767. }
  5768. }
  5769. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5770. {
  5771. send_list.Add(ceErpTrade.tid);
  5772. try
  5773. {
  5774. btnType = "待发货";
  5775. ceErpTradeCell.OutSid = curUseWayBillCode;
  5776. ceErpTradeCell.OrderState = 7;
  5777. ceErpTradeCell.IsUrgency = false;
  5778. ceErpTradeCell.LastBillCpCode = "";
  5779. ceErpTradeCell.LastBillWaybillCode = "";
  5780. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5781. ceErpTradeCell.IsReturn = 0;
  5782. ceErpTradeCell.MemoOpt = 0;
  5783. ceErpTradeCell.UpdateTime = DateTime.Now;
  5784. ceErpTradeCell.Update();
  5785. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5786. //还要插入快递信息到 快递信息表
  5787. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5788. exinfo.tid = ceErpTradeCell.ctid;
  5789. exinfo.out_sid = curUseWayBillCode;
  5790. exinfo.company_code = cpCode;
  5791. exinfo.company_name = cpName;
  5792. exinfo.supplierUserName = supplierName;
  5793. exinfo.deliveryType = "发货成功";
  5794. exinfo.print_time = DateTime.Now;
  5795. exinfo.printUser = CurrentUser.UserName;
  5796. exinfo.postData = pData_str;
  5797. exinfo.Create();
  5798. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5799. CeErpSukuraData.createInfo(ctid, 4);
  5800. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5801. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80)
  5802. {
  5803. commonHelper.sendCytExpress(exinfo);
  5804. }
  5805. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5806. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5807. }
  5808. catch (Exception ex)
  5809. {
  5810. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5811. }
  5812. }
  5813. else
  5814. {
  5815. ceErpTradeCell.UpdateTime = DateTime.Now;
  5816. ceErpTradeCell.LastBillCpCode = cpCode;
  5817. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5818. ceErpTradeCell.Update();
  5819. string errmsg = commonHelper.KeepChinese(apires);
  5820. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5821. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5822. }
  5823. }
  5824. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5825. }
  5826. }
  5827. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5828. var res_obj = new
  5829. {
  5830. restype = 1,
  5831. data = pData_str,
  5832. errorMsg
  5833. };
  5834. string ro_json = JsonConvert.SerializeObject(res_obj);
  5835. ReturnSuccess(ro_json);
  5836. return;
  5837. }
  5838. }
  5839. private string GetUTF8String(byte[] vs)
  5840. {
  5841. throw new NotImplementedException();
  5842. }
  5843. public void set_erp_printwaybill_cn()
  5844. {
  5845. if (UrlPostParmsCheck("ctid"))
  5846. {
  5847. string ctid = GetPostString("ctid");
  5848. string cpCode = GetPostString("cpcode");
  5849. string cpName = GetPostString("cpname");
  5850. string tempUrl = GetPostString("tempurl");
  5851. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5852. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5853. //string res = taobaoHelper.test();
  5854. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5855. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5856. {
  5857. int sidx = res.IndexOf("errorMsg");
  5858. int eidx = res.IndexOf("}");
  5859. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5860. var res_objzxx = new
  5861. {
  5862. restype = 0,
  5863. data = msg
  5864. };
  5865. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5866. returnSuccess(ro_jsonzxx);
  5867. //returnErrorMsg(msg);
  5868. return;
  5869. }
  5870. int idx = res.IndexOf("waybillCode");
  5871. int idx2 = res.IndexOf("printData");
  5872. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5873. string eid = GetPostString("ctid");
  5874. CeErpTradeCell entity = null;
  5875. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5876. if (entity != null)
  5877. {
  5878. string osid = entity.OutSid;
  5879. entity.OutSid = osid + "," + outsid;
  5880. entity.FinishDeliveryTime = DateTime.Now;
  5881. entity.OrderState = 7;
  5882. entity.UpdateTime = DateTime.Now;
  5883. entity.IsReturn = 0;
  5884. entity.Update();
  5885. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5886. exinfo.tid = entity.ctid;
  5887. exinfo.out_sid = outsid;
  5888. exinfo.company_code = cpCode;
  5889. exinfo.company_name = cpName;
  5890. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5891. exinfo.deliveryType = "发货成功";
  5892. exinfo.print_time = DateTime.Now;
  5893. exinfo.printUser = CurrentUser.UserName;
  5894. exinfo.Create();
  5895. if (entity.SupplierId == 64 || entity.SupplierId == 80)
  5896. {
  5897. commonHelper.sendCytExpress(exinfo);
  5898. }
  5899. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5900. }
  5901. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5902. var res_objz = new
  5903. {
  5904. restype = 1,
  5905. data = res
  5906. };
  5907. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5908. returnSuccess(ro_jsonz);
  5909. //ReturnSuccess(res);
  5910. }
  5911. }
  5912. ////打单,打印面单 获取面单号
  5913. //public void set_erp_printwaybill()
  5914. //{
  5915. // if (UrlPostParmsCheck("ctid"))
  5916. // {
  5917. // string ctid = GetPostString("ctid");
  5918. // string cpCode = GetPostString("cpcode");
  5919. // string tempUrl = GetPostString("tempurl");
  5920. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5921. // //string res = taobaoHelper.test();
  5922. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5923. // if (res.IndexOf("error_response") != -1)
  5924. // {
  5925. // int sidx = res.IndexOf("sub_msg");
  5926. // int eidx = res.IndexOf("request_id");
  5927. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5928. // returnErrorMsg(msg);
  5929. // return;
  5930. // }
  5931. // int idx = res.IndexOf("waybill_code");
  5932. // int idx2 = res.IndexOf("}]}");
  5933. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5934. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5935. // ReturnSuccess(res);
  5936. // }
  5937. //}
  5938. public void cancel_erp_aftersale()
  5939. {
  5940. if (UrlPostParmsCheck("ctid"))
  5941. {
  5942. string eid = GetPostString("ctid");
  5943. CeErpTradeCell entity = null;
  5944. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5945. if (entity != null)
  5946. {
  5947. //有过处理的售后,取消也不能删除 售 字,保留
  5948. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5949. {
  5950. entity.AfterSaleState = 4;
  5951. }
  5952. else
  5953. entity.AfterSaleState = 0;
  5954. entity.UpdateTime = DateTime.Now;
  5955. entity.Update();
  5956. returnSuccessMsg("操作成功!");
  5957. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5958. return;
  5959. }
  5960. returnErrorMsg("找不到订单记录");
  5961. }
  5962. }
  5963. public void get_erp_aftersalelist()
  5964. {
  5965. DataStruct dStruct = GetPostStruct();
  5966. List<string> lw = new List<string>();
  5967. int st = GetInt("st");
  5968. string tid = GetPostString("ctid");
  5969. if (st == 3)
  5970. {
  5971. if (tid.Length > 0)
  5972. {
  5973. string select_tid = getTidByCtid(tid);
  5974. lw.Add(string.Format("tid='{0}'", select_tid));
  5975. }
  5976. }
  5977. else
  5978. {
  5979. if (tid.Length > 0)
  5980. {
  5981. string select_tid = getTidByCtid(tid);
  5982. lw.Add(string.Format("tid='{0}'", select_tid));
  5983. }
  5984. }
  5985. string shopname = GetPostString("shopname");
  5986. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5987. string buyernick = GetPostString("buyer_nick");
  5988. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5989. string sellermemo = GetPostString("seller_memo");
  5990. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5991. string orderState = GetPostString("orderState");
  5992. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5993. string afterState = GetPostString("afterstate");
  5994. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5995. string date1 = GetPostString("date1");
  5996. string date2 = GetPostString("date2");
  5997. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5998. if (dw.Length > 0) lw.Add(dw);
  5999. string price1 = GetPostString("price1");
  6000. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6001. string price2 = GetPostString("price2");
  6002. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6003. //lw.Add(string.Format("IsRefund!={0}", 1));
  6004. string reason = GetPostString("reason");
  6005. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6006. string method = GetPostString("method");
  6007. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6008. string handler = GetPostString("handler");
  6009. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6010. string handledate1 = GetPostString("handledate1");
  6011. string handledate2 = GetPostString("handledate2");
  6012. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6013. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6014. string finish1 = GetPostString("finishdate1");
  6015. string finish2 = GetPostString("finishdate2");
  6016. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6017. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6018. string afterdate1 = GetPostString("afterdate1");
  6019. string afterdate2 = GetPostString("afterdate2");
  6020. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6021. if (afterDate.Length > 0) lw.Add(afterDate);
  6022. string supplier = GetPostString("supplier");
  6023. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6024. string responsible = GetPostString("responsibleman");
  6025. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6026. string customer = GetPostString("customer");
  6027. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6028. string design = GetPostString("design");
  6029. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6030. string afterMemoType = GetPostString("aftermemotype");
  6031. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6032. string posCode = CurrentUser.UserPost.Post.Code;
  6033. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6034. //{
  6035. // string vstate = GetPostString("vstate");
  6036. // if (vstate.Length > 0)
  6037. // {
  6038. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6039. // }
  6040. // if (posCode == "Supplier")
  6041. // {
  6042. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6043. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6044. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6045. // }
  6046. // else
  6047. // {
  6048. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6049. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6050. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6051. // {
  6052. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6053. // }
  6054. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6055. // {
  6056. // int orgid = CurrentUser.UserPost.OrgID;
  6057. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6058. // }
  6059. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6060. // {
  6061. // string shopid = CurrentUser.User.pemShop;
  6062. // lw.Add(string.Format("shopId in ({0})", shopid));
  6063. // }
  6064. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6065. // //{
  6066. // // int org_id = CurrentUser.UserPost.OrgID;
  6067. // // lw.Add(string.Format("OrgID={0}", org_id));
  6068. // //}
  6069. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6070. // }
  6071. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6072. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6073. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6074. //}
  6075. if (st == 5)
  6076. {
  6077. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6078. {
  6079. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6080. {
  6081. string shopid = CurrentUser.User.pemShop;
  6082. lw.Add(string.Format("shopId in ({0})", shopid));
  6083. }
  6084. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6085. {
  6086. int mrOrgid = CurrentUser.UserPost.OrgID;
  6087. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6088. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6089. }
  6090. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6091. //{
  6092. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6093. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6094. //}
  6095. else
  6096. {
  6097. string userIdStr = "";
  6098. if (posCode == "CustomerService")
  6099. {
  6100. userIdStr = CurrentUser.UserID + "_k";
  6101. }
  6102. else if (posCode == "Designer" || posCode == "wxDesigner")
  6103. {
  6104. userIdStr = CurrentUser.UserID + "_s";
  6105. }
  6106. else if (posCode == "Place")
  6107. {
  6108. userIdStr = CurrentUser.UserID + "_x";
  6109. }
  6110. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6111. }
  6112. }
  6113. string placedate1 = GetPostString("placedate1");
  6114. string placedate2 = GetPostString("placedate2");
  6115. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6116. if (dwplace.Length > 0) lw.Add(dwplace);
  6117. string supState = GetPostString("supState");
  6118. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6119. string searchType = GetPostString("searchType");
  6120. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6121. {
  6122. lw.Add(string.Format("BackNum>1"));
  6123. }
  6124. lw.Add(string.Format("AfterSaleState>0"));
  6125. if (ex_psize > 0)
  6126. {
  6127. if (CurrentUser.UserPost.Post.Code == "Finance")
  6128. dStruct.Order = "pay_time desc";
  6129. else
  6130. dStruct.Order = "HandleTime desc";
  6131. }
  6132. else
  6133. dStruct.Order = "HandleTime desc";
  6134. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6135. DataTable dt = WebCache.GetData("view_test", dStruct);
  6136. writeGridDataTableJson(dStruct.TotalCount, dt);
  6137. }
  6138. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6139. //{
  6140. // lw.Add(string.Format("AfterSaleState=4"));
  6141. // string code = CurrentUser.UserPost.Post.Code;
  6142. // if (code == "CustomerService")
  6143. // {
  6144. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6145. // }
  6146. // else if (code == "Designer" || code == "DesignerMr")
  6147. // {
  6148. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6149. // }
  6150. // else if (code == "Place" || code == "PlaceMr")
  6151. // {
  6152. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6153. // }
  6154. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6155. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6156. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6157. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6158. //}
  6159. //else //处理中的售后,待处理和处理中合并
  6160. //{
  6161. // if (afterState.Length <= 0)
  6162. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6163. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6164. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6165. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6166. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6167. //}
  6168. }
  6169. public void get_erp_disagreeftersalelist()
  6170. {
  6171. DataStruct dStruct = GetPostStruct();
  6172. List<string> lw = new List<string>();
  6173. int st = 2;
  6174. string tid = GetPostString("ctid");
  6175. if (tid.Length > 0)
  6176. {
  6177. string select_tid = getTidByCtid(tid);
  6178. lw.Add(string.Format("tid='{0}'", select_tid));
  6179. }
  6180. string shopname = GetPostString("shopname");
  6181. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6182. string buyernick = GetPostString("buyer_nick");
  6183. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6184. string sellermemo = GetPostString("seller_memo");
  6185. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6186. string orderState = GetPostString("orderState");
  6187. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6188. string afterState = GetPostString("afterstate");
  6189. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6190. string date1 = GetPostString("date1");
  6191. string date2 = GetPostString("date2");
  6192. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6193. if (dw.Length > 0) lw.Add(dw);
  6194. string price1 = GetPostString("price1");
  6195. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6196. string price2 = GetPostString("price2");
  6197. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6198. //lw.Add(string.Format("IsRefund!={0}", 1));
  6199. string reason = GetPostString("reason");
  6200. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6201. string method = GetPostString("method");
  6202. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6203. string handler = GetPostString("handler");
  6204. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6205. string handledate1 = GetPostString("handledate1");
  6206. string handledate2 = GetPostString("handledate2");
  6207. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6208. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6209. string afterdate1 = GetPostString("afterdate1");
  6210. string afterdate2 = GetPostString("afterdate2");
  6211. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6212. if (afterDate.Length > 0) lw.Add(afterDate);
  6213. string backdate1 = GetPostString("backdate1");
  6214. string backdate2 = GetPostString("backdate2");
  6215. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6216. if (backDate.Length > 0) lw.Add(backDate);
  6217. string supplier = GetPostString("supplier");
  6218. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6219. string responsible = GetPostString("responsibleman");
  6220. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6221. string customer = GetPostString("customer");
  6222. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6223. string design = GetPostString("design");
  6224. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6225. string afterSaleMemo = GetPostString("afterSaleMemo");
  6226. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6227. string afterMemoType = GetPostString("aftermemotype");
  6228. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6229. string aftersakereason = GetPostString("aftersakereason");
  6230. if (aftersakereason.Length > 0)
  6231. {
  6232. if (aftersakereason == "1")
  6233. {
  6234. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6235. }
  6236. if (aftersakereason == "2")
  6237. {
  6238. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6239. }
  6240. }
  6241. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6242. string poscode = CurrentUser.UserPost.Post.Code;
  6243. if (poscode != "SysAdmin")
  6244. {
  6245. string shopid = CurrentUser.User.pemShop;
  6246. lw.Add(string.Format("shopId in ({0})", shopid));
  6247. }
  6248. string searchType = GetPostString("searchType");
  6249. if (searchType == "wait")
  6250. {
  6251. lw.Add(string.Format("HandleTime is null"));
  6252. }
  6253. if (searchType == "handling")
  6254. {
  6255. lw.Add(string.Format("HandleTime is not null "));
  6256. }
  6257. if (searchType == "back" || searchType == "puBack")
  6258. {
  6259. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6260. }
  6261. if (searchType == "reBack")
  6262. {
  6263. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6264. }
  6265. if (searchType == "moreBack")
  6266. {
  6267. lw.Add(string.Format("backNum > 1"));
  6268. }
  6269. lw.Add(string.Format("(AfterSaleState=5)"));
  6270. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6271. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6272. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6273. writeGridDataTableJson(dStruct.TotalCount, dt);
  6274. }
  6275. public void get_erp_handlingaftersalelist()
  6276. {
  6277. DataStruct dStruct = GetPostStruct();
  6278. List<string> lw = new List<string>();
  6279. int st = 2;
  6280. string tid = GetPostString("ctid");
  6281. if (tid.Length > 0)
  6282. {
  6283. string select_tid = getTidByCtid(tid);
  6284. lw.Add(string.Format("tid='{0}'", select_tid));
  6285. }
  6286. string shopname = GetPostString("shopname");
  6287. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6288. string buyernick = GetPostString("buyer_nick");
  6289. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6290. string sellermemo = GetPostString("seller_memo");
  6291. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6292. string orderState = GetPostString("orderState");
  6293. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6294. string afterState = GetPostString("afterstate");
  6295. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6296. string date1 = GetPostString("date1");
  6297. string date2 = GetPostString("date2");
  6298. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6299. if (dw.Length > 0) lw.Add(dw);
  6300. string price1 = GetPostString("price1");
  6301. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6302. string price2 = GetPostString("price2");
  6303. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6304. //lw.Add(string.Format("IsRefund!={0}", 1));
  6305. string reason = GetPostString("reason");
  6306. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6307. string method = GetPostString("method");
  6308. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6309. string handler = GetPostString("handler");
  6310. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6311. string handledate1 = GetPostString("handledate1");
  6312. string handledate2 = GetPostString("handledate2");
  6313. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6314. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6315. string afterdate1 = GetPostString("afterdate1");
  6316. string afterdate2 = GetPostString("afterdate2");
  6317. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6318. if (afterDate.Length > 0) lw.Add(afterDate);
  6319. string supplier = GetPostString("supplier");
  6320. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6321. string responsible = GetPostString("responsibleman");
  6322. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6323. string customer = GetPostString("customer");
  6324. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6325. string design = GetPostString("design");
  6326. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6327. string afterSaleMemo = GetPostString("afterSaleMemo");
  6328. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6329. string afterMemoType = GetPostString("aftermemotype");
  6330. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6331. string afterresult = GetPostString("afterresult");
  6332. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6333. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6334. string poscode = CurrentUser.UserPost.Post.Code;
  6335. if (poscode != "SysAdmin")
  6336. {
  6337. string shopid = CurrentUser.User.pemShop;
  6338. lw.Add(string.Format("shopId in ({0})", shopid));
  6339. }
  6340. string searchType = GetPostString("searchType");
  6341. if (searchType == "wait")
  6342. {
  6343. lw.Add(string.Format("HandleTime is null"));
  6344. }
  6345. if (searchType == "documentary")
  6346. {
  6347. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6348. }
  6349. if (searchType == "handling")
  6350. {
  6351. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6352. }
  6353. if (searchType == "back" || searchType == "puBack")
  6354. {
  6355. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6356. }
  6357. if (searchType == "reBack")
  6358. {
  6359. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6360. }
  6361. if (afterState.Length <= 0)
  6362. {
  6363. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6364. }
  6365. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6367. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6368. writeGridDataTableJson(dStruct.TotalCount, dt);
  6369. }
  6370. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6371. //public void get_erp_back_handlingaftersalelist()
  6372. //{
  6373. // DataStruct dStruct = GetPostStruct();
  6374. // List<string> lw = new List<string>();
  6375. // string tid = GetPostString("ctid");
  6376. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6377. // string shopname = GetPostString("shopname");
  6378. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6379. // string buyernick = GetPostString("buyer_nick");
  6380. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6381. // string sellermemo = GetPostString("seller_memo");
  6382. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6383. // string orderState = GetPostString("orderState");
  6384. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6385. // string afterState = GetPostString("afterstate");
  6386. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6387. // string date1 = GetPostString("date1");
  6388. // string date2 = GetPostString("date2");
  6389. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6390. // if (dw.Length > 0) lw.Add(dw);
  6391. // string price1 = GetPostString("price1");
  6392. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6393. // string price2 = GetPostString("price2");
  6394. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6395. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6396. // string reason = GetPostString("reason");
  6397. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6398. // string method = GetPostString("method");
  6399. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6400. // string handler = GetPostString("handler");
  6401. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6402. // string handledate1 = GetPostString("handledate1");
  6403. // string handledate2 = GetPostString("handledate2");
  6404. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6405. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6406. // string afterdate1 = GetPostString("afterdate1");
  6407. // string afterdate2 = GetPostString("afterdate2");
  6408. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6409. // if (afterDate.Length > 0) lw.Add(afterDate);
  6410. // string supplier = GetPostString("supplier");
  6411. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6412. // string responsible = GetPostString("responsibleman");
  6413. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6414. // string customer = GetPostString("customer");
  6415. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6416. // string design = GetPostString("design");
  6417. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6418. // string afterMemoType = GetPostString("aftermemotype");
  6419. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6420. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6421. // if (afterState.Length <= 0)
  6422. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6423. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6424. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6425. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6426. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6427. //}
  6428. public void get_erp_aftersaleverifylist()
  6429. {
  6430. DataStruct dStruct = GetPostStruct();
  6431. List<string> lw = new List<string>();
  6432. string tid = GetPostString("ctid");
  6433. if (tid.Length > 0)
  6434. {
  6435. string select_tid = getTidByCtid(tid);
  6436. lw.Add(string.Format("otid='{0}'", select_tid));
  6437. }
  6438. string shopname = GetPostString("shopname");
  6439. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6440. string buyernick = GetPostString("buyer_nick");
  6441. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6442. string sellermemo = GetPostString("seller_memo");
  6443. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6444. string orderState = GetPostString("orderState");
  6445. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6446. //lw.Add(string.Format("IsRefund!={0}", 1));
  6447. string reason = GetPostString("reason");
  6448. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6449. string method = GetPostString("method");
  6450. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6451. string handler = GetPostString("handler");
  6452. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6453. string handledate1 = GetPostString("handledate1");
  6454. string handledate2 = GetPostString("handledate2");
  6455. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6456. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6457. string finish1 = GetPostString("finishdate1");
  6458. string finish2 = GetPostString("finishdate2");
  6459. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6460. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6461. string supplier = GetPostString("supplier");
  6462. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6463. string responsible = GetPostString("responsibleman");
  6464. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6465. string posCode = CurrentUser.UserPost.Post.Code;
  6466. string vstate = GetPostString("vstate");
  6467. if (vstate.Length > 0)
  6468. {
  6469. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6470. }
  6471. if (posCode == "Supplier")
  6472. {
  6473. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6474. lw.Add(string.Format("VerifyState = 0"));
  6475. lw.Add("type = 1");
  6476. lw.Add(string.Format("AfterSaleState={0}", 3));
  6477. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6478. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6479. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6480. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6481. writeGridDataTableJson(dStruct.TotalCount, dt);
  6482. }
  6483. else if (posCode == "logistics")
  6484. {
  6485. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6486. lw.Add(string.Format("VerifyState = 0"));
  6487. lw.Add("type = 2");
  6488. lw.Add(string.Format("AfterSaleState={0}", 3));
  6489. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6490. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6491. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6492. writeGridDataTableJson(dStruct.TotalCount, dt);
  6493. }
  6494. else
  6495. {
  6496. lw.Add(string.Format("(AfterSaleState = 3)"));
  6497. string reasonState = GetPostString("reasonState");
  6498. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6499. || posCode == "Summarize" || posCode == "Finance")
  6500. {
  6501. if (reasonState == "2")
  6502. {
  6503. lw.Add("VerifyState = 3");
  6504. }
  6505. else if (reasonState == "1")
  6506. {
  6507. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6508. }
  6509. else
  6510. {
  6511. lw.Add("VerifyState in (0,3)");
  6512. }
  6513. //不加条件,可以看全部
  6514. }
  6515. 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")
  6516. {
  6517. int orgid = CurrentUser.UserPost.OrgID;
  6518. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6519. if (string.IsNullOrEmpty(manageOrgId))
  6520. {
  6521. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6522. }
  6523. else
  6524. {
  6525. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6526. }
  6527. if (reasonState == "1")
  6528. {
  6529. lw.Add("VerifyState = 3");
  6530. }
  6531. else if (reasonState == "2")
  6532. {
  6533. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6534. }
  6535. else
  6536. {
  6537. }
  6538. }
  6539. else
  6540. {
  6541. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6542. }
  6543. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6544. //{
  6545. // int org_id = CurrentUser.UserPost.OrgID;
  6546. // lw.Add(string.Format("OrgID={0}", org_id));
  6547. //}
  6548. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6549. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6550. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6551. writeGridDataTableJson(dStruct.TotalCount, dt);
  6552. }
  6553. }
  6554. public void get_erp_finishaftersalelist()
  6555. {
  6556. DataStruct dStruct = GetPostStruct();
  6557. List<string> lw = new List<string>();
  6558. int st = 4;
  6559. string tid = GetPostString("ctid");
  6560. if (tid.Length > 0)
  6561. {
  6562. string select_tid = getTidByCtid(tid);
  6563. lw.Add(string.Format("otid='{0}'", select_tid));
  6564. }
  6565. string shopname = GetPostString("shopname");
  6566. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6567. //lw.Add(string.Format("IsRefund!={0}", 1));
  6568. string reason = GetPostString("reason");
  6569. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6570. string method = GetPostString("method");
  6571. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6572. string buyernick = GetPostString("buyer_nick");
  6573. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6574. string handler = GetPostString("handler");
  6575. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6576. string handledate1 = GetPostString("handledate1");
  6577. string handledate2 = GetPostString("handledate2");
  6578. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6579. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6580. string finish1 = GetPostString("finishdate1");
  6581. string finish2 = GetPostString("finishdate2");
  6582. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6583. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6584. string supplier = GetPostString("supplier");
  6585. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6586. string responsible = GetPostString("responsibleman");
  6587. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6588. string vstate = GetPostString("vstate");
  6589. if (vstate.Length > 0)
  6590. {
  6591. if ("3".Equals(vstate))
  6592. {
  6593. lw.Add(string.Format("IsTem=1"));
  6594. }
  6595. else
  6596. {
  6597. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6598. }
  6599. }
  6600. lw.Add(string.Format("AfterSaleState=4"));
  6601. string code = CurrentUser.UserPost.Post.Code;
  6602. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6603. {
  6604. //不加条件,可以看全部
  6605. }
  6606. else if (code == "Supplier")
  6607. {
  6608. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6609. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6610. lw.Add("type = 1");
  6611. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6612. }
  6613. else if (code == "logistics")
  6614. {
  6615. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6616. lw.Add("type = 2");
  6617. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6618. }
  6619. 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")
  6620. {
  6621. lw.Add("type = 0");
  6622. int orgid = CurrentUser.UserPost.OrgID;
  6623. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6624. if (string.IsNullOrEmpty(manageOrgIds))
  6625. {
  6626. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6627. }
  6628. else
  6629. {
  6630. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6631. }
  6632. }
  6633. else
  6634. {
  6635. lw.Add("type = 0");
  6636. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6637. }
  6638. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6639. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6640. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6641. writeGridDataTableJson(dStruct.TotalCount, dt);
  6642. }
  6643. public void handle_erp_aftersale()
  6644. {
  6645. if (UrlPostParmsCheck("ctid"))
  6646. {
  6647. string eid = GetPostString("ctid");
  6648. string responStr = GetPostString("AfterSaleResponsible");
  6649. if (responStr.Length <= 0)
  6650. {
  6651. returnErrorMsg("售后责任人不能为空");
  6652. return;
  6653. }
  6654. bool isDesign = false;
  6655. double designFree = 0.00;
  6656. int responsibleId = 0;
  6657. CeErpTradeCell entity = null;
  6658. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6659. if (entity != null)
  6660. {
  6661. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6662. string afterMethod = GetPostString("AfterSaleMethod");
  6663. if (isNeedNewOrder == 1)
  6664. {
  6665. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6666. bool ishav = true;
  6667. if (newentity == null)
  6668. {
  6669. newentity = entity.Clone() as CeErpTradeCell;
  6670. ishav = false;
  6671. newentity.ctid = "S_" + entity.ctid;
  6672. newentity.OrderState = 0;
  6673. //唯一标识
  6674. newentity.OrderSn = newentity.ctid;
  6675. string orderSn = dataHelper.getSaleOrderSn();
  6676. if (orderSn != "")
  6677. {
  6678. newentity.OrderSn = orderSn;
  6679. }
  6680. }
  6681. newentity.UpdateTime = DateTime.Now;
  6682. newentity.AfterSaleState = 0;
  6683. newentity.AfterSaleMethod = afterMethod;
  6684. if (!ishav)
  6685. {
  6686. string memo_str = newentity.seller_memo;
  6687. memo_str = memo_str.Replace("(", "(");
  6688. memo_str = memo_str.Replace(")", ")");
  6689. int sIndex = memo_str.IndexOf("(");
  6690. int eIndex = memo_str.IndexOf(")");
  6691. if (sIndex == -1 || eIndex == -1)
  6692. {
  6693. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6694. return;
  6695. }
  6696. string first = memo_str.Substring(0, sIndex + 1);
  6697. string memoCtid = newentity.OrderSn;
  6698. //if (memoCtid.IndexOf("C") != -1)
  6699. //{
  6700. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6701. //if (CIdx.IndexOf("+") != -1)
  6702. //{
  6703. //CIdx = "C" + CIdx.Split('+')[1];
  6704. //}
  6705. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6706. //}
  6707. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6708. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6709. string newMemo = first + memoCtid + last;
  6710. newentity.seller_memo = newMemo;
  6711. newentity.FinishPlaceTime = null;
  6712. newentity.UnusualTag = 0;
  6713. newentity.UnusualCon = "";
  6714. newentity.UnusualTime = null;
  6715. newentity.AfterSaleMemo = "";
  6716. newentity.AfterSaleMethod = afterMethod;
  6717. newentity.AfterSalePreTime = null;
  6718. newentity.AfterSaleReason = "";
  6719. newentity.AfterSaleResponsible = "";
  6720. newentity.AfterSaleState = 0;
  6721. newentity.AfterSaleTime = null;
  6722. newentity.AfterSaleUserId = 0;
  6723. newentity.AfterSaleSupplierState = 0;
  6724. newentity.LastBillWaybillCode = "";
  6725. newentity.LastBillCpCode = "";
  6726. newentity.FinishAfterSaleTime = null;
  6727. newentity.HandleTime = null;
  6728. newentity.IsSF = 0;
  6729. newentity.IsOldCustomer = 0;
  6730. newentity.UrgencyTime = null;
  6731. newentity.ResponsibleUserId = "";
  6732. newentity.IsVerifyToSupplier = false;
  6733. newentity.payment = 0;
  6734. newentity.CheckMemo = "";
  6735. newentity.OutSid = "";
  6736. newentity.CheckOrderTime = null;
  6737. newentity.MemoOpt = 0;
  6738. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6739. }
  6740. newentity.isAfterSaleOrder = 1;
  6741. newentity.IsRefund = 0;
  6742. string receiveMobile = GetPostString("receiver_mobile");
  6743. if (receiveMobile.Length > 0)
  6744. {
  6745. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6746. if (trade != null)
  6747. {
  6748. trade.receiver_name = GetPostString("receiver_name");
  6749. trade.receiver_mobile = receiveMobile;
  6750. trade.receiver_state = GetPostString("receiver_state");
  6751. trade.receiver_city = GetPostString("receiver_city");
  6752. trade.receiver_district = GetPostString("receiver_district");
  6753. trade.receiver_address = GetPostString("receiver_address");
  6754. newentity.IsOffLineOrder = 1;
  6755. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6756. }
  6757. }
  6758. string st = GetPostString("ToState");
  6759. if (st.Length > 0)
  6760. {
  6761. if (newentity.OrderState <= 3)
  6762. {
  6763. newentity.WaitDesignTime = DateTime.Now;
  6764. newentity.StartDesignTime = null;
  6765. newentity.FinishDesignTime = null;
  6766. newentity.OrderState = 3;
  6767. if (st == "下单员")
  6768. {
  6769. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6770. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6771. {
  6772. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6773. }
  6774. }
  6775. else
  6776. {
  6777. newentity.WaitDesignTime = DateTime.Now;
  6778. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6779. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6780. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6781. {
  6782. DataRow user = dt1.Rows[0];
  6783. //找主管
  6784. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6785. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6786. if (dt != null && dt.Rows.Count > 0)
  6787. {
  6788. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6789. newentity.DesignUserId = designMr;
  6790. string key = "aftersale_order_" + designMr;
  6791. if (RedisHelper.HasKey(key))
  6792. {
  6793. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6794. list.Add(newentity.ctid);
  6795. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6796. }
  6797. }
  6798. //账号正常
  6799. if (user["State"].ToString() == "0")
  6800. {
  6801. newentity.DesignUserId = entity.DesignUserId;
  6802. string key = "aftersale_order_" + entity.DesignUserId;
  6803. if (RedisHelper.HasKey(key))
  6804. {
  6805. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6806. list.Add(newentity.ctid);
  6807. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6808. }
  6809. }
  6810. }
  6811. }
  6812. }
  6813. if (entity.IsXianHuo == 1)
  6814. {
  6815. newentity.OrderState = 6;
  6816. entity.FinishPlaceTime = DateTime.Now;
  6817. }
  6818. }
  6819. if (ishav)
  6820. {
  6821. newentity.Update();
  6822. }
  6823. else
  6824. {
  6825. newentity.Create();
  6826. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6827. newCellExtend.ctid = newentity.ctid;
  6828. newCellExtend.orderFrom = 20;
  6829. newCellExtend.orderType = 30;
  6830. if (st == "下单员")
  6831. {
  6832. }
  6833. else
  6834. {
  6835. newCellExtend.ReprintTime = DateTime.Now;
  6836. }
  6837. newCellExtend.Create();
  6838. }
  6839. if (st != "下单员")
  6840. {
  6841. if (entity.DispatchSort == 2)
  6842. {
  6843. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  6844. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6845. }
  6846. }
  6847. }
  6848. //处理售后扩展
  6849. string resIdStr = GetPostString("ResponsibleUserId");
  6850. string refundFees = GetPostString("refundFrees");
  6851. int IsComplain = GetPostInt("isComplain");
  6852. int IsBad = GetPostInt("isBad");
  6853. string IsOriginal = GetPostString("isOriginal");
  6854. double diffResultPrice = GetPostDouble("diffResultPrice");
  6855. string textResult = GetPostString("textResult");
  6856. string supplierResponsible = GetPostString("supplierResponsible");
  6857. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6858. if (ceErpTradeAfterSaleExtend == null)
  6859. {
  6860. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6861. ceErpTradeAfterSaleExtend.tid = eid;
  6862. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6863. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6864. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6865. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6866. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6867. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6868. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6869. ceErpTradeAfterSaleExtend.Create();
  6870. }
  6871. else
  6872. {
  6873. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6874. {
  6875. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6876. }
  6877. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6878. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6879. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6880. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6881. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6882. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6883. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6884. ceErpTradeAfterSaleExtend.Update();
  6885. }
  6886. int gysid = GetPostInt("ResponsibleSupId");
  6887. if (entity.AfterSaleUserId == 0)
  6888. {
  6889. entity.AfterSaleUserId = CurrentUser.UserID;
  6890. }
  6891. entity.ResponsibleUserId = resIdStr;
  6892. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6893. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6894. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6895. {
  6896. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6897. int backNum = 0;
  6898. if (number != null)
  6899. {
  6900. backNum = number.BackNum;
  6901. }
  6902. char[] separator = { ',' };
  6903. string[] sArray = resIdStr.Split(separator);
  6904. string[] refundFreeList = { };
  6905. if (refundFees.Length > 0)
  6906. {
  6907. refundFreeList = refundFees.Split(separator);
  6908. }
  6909. int index = -1;
  6910. List<int> responsibleIds = new List<int>();
  6911. foreach (string i in sArray)
  6912. {
  6913. index++;
  6914. if (i.Length <= 0) continue;
  6915. char[] separator2 = { '_' };
  6916. string idstr = i.Split(separator2)[0];
  6917. string idtype = i.Split(separator2)[1];
  6918. double refudFree = 0;
  6919. if (refundFreeList.Length > 0)
  6920. {
  6921. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6922. }
  6923. if (idtype == "s")
  6924. {
  6925. isDesign = true;
  6926. designFree = refudFree;
  6927. }
  6928. int userId = Convert.ToInt32(idstr);
  6929. int type = 0;
  6930. if (idtype == "g")
  6931. {
  6932. type = 1;
  6933. }
  6934. if (idtype == "w")
  6935. {
  6936. type = 2;
  6937. }
  6938. if (idtype == "t")
  6939. {
  6940. type = 3;
  6941. }
  6942. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6943. if (ceErpTradeResponsible == null)
  6944. {
  6945. ceErpTradeResponsible = new CeErpTradeResponsible();
  6946. ceErpTradeResponsible.tid = eid;
  6947. ceErpTradeResponsible.UserId = userId;
  6948. ceErpTradeResponsible.createdTime = DateTime.Now;
  6949. ceErpTradeResponsible.type = type;
  6950. if (type == 1)
  6951. {
  6952. ceErpTradeResponsible.IsSup = 1;
  6953. }
  6954. if (type == 2)
  6955. {
  6956. ceErpTradeResponsible.IsFlow = 1;
  6957. }
  6958. }
  6959. int state = 0;
  6960. //已认可的不需要再次认可
  6961. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  6962. {
  6963. state = 1;
  6964. }
  6965. ceErpTradeResponsible.RefundFee = refudFree;
  6966. ceErpTradeResponsible.VerifyState = state;
  6967. if (userId == 2125 || idtype == "w")
  6968. {
  6969. ceErpTradeResponsible.VerifyState = 1;
  6970. }
  6971. if (idtype == "w" && userId == 101)
  6972. {
  6973. ceErpTradeResponsible.VerifyState = state;
  6974. }
  6975. if (ceErpTradeResponsible.ID > 0)
  6976. {
  6977. ceErpTradeResponsible.Update();
  6978. }
  6979. else
  6980. {
  6981. ceErpTradeResponsible.Create();
  6982. }
  6983. if (isDesign)
  6984. {
  6985. responsibleId = ceErpTradeResponsible.ID;
  6986. }
  6987. responsibleIds.Add(ceErpTradeResponsible.ID);
  6988. }
  6989. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  6990. CeErpTradeResponsible.NumByTid(backNum, eid);
  6991. }
  6992. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6993. if (ceErpTradeCellExtend != null)
  6994. {
  6995. ceErpTradeCellExtend.returnVisit = 0;
  6996. ceErpTradeCellExtend.Update();
  6997. }
  6998. if (entity.HandleTime != null)
  6999. {
  7000. if (entity.AfterSaleState == 1)
  7001. {
  7002. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7003. }
  7004. else
  7005. {
  7006. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7007. }
  7008. }
  7009. else
  7010. {
  7011. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7012. entity.HandleTime = DateTime.Now;
  7013. }
  7014. bool isCompale = false;
  7015. if (entity.AfterSaleState == 5)
  7016. {
  7017. isCompale = true;
  7018. entity.AfterSaleState = 3;
  7019. }
  7020. entity.AfterSaleSupplierState = 0;
  7021. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7022. {
  7023. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7024. }
  7025. string sImgs = GetPostString("img");
  7026. entity.AfterSaleSupplierImg = sImgs;
  7027. entity.supRefundType = GetPostString("supRefundType");
  7028. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7029. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7030. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7031. entity.AfterSaleMemoType = GetPostString("MemoType");
  7032. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7033. {
  7034. //entity.AfterSaleSupplierState = 2;
  7035. }
  7036. string df = GetPostString("DeductFee");
  7037. if (df == "")
  7038. {
  7039. df = "0";
  7040. }
  7041. string rf = GetPostString("RefundFee");
  7042. if (rf == "")
  7043. {
  7044. rf = "0";
  7045. }
  7046. string pm = GetPostString("AfterSalePayment");
  7047. if (pm == "")
  7048. {
  7049. pm = "0";
  7050. }
  7051. entity.AfterSalePayment = Convert.ToDouble(pm);
  7052. entity.DeductFee = Convert.ToDouble(df);
  7053. entity.RefundFee = Convert.ToDouble(rf);
  7054. entity.UpdateTime = DateTime.Now;
  7055. entity.Update();
  7056. string toState = GetPostString("ToState");
  7057. string original = GetPostString("isOriginal");
  7058. ApiVo apiVo = new ApiVo();
  7059. apiVo.orderNumber = entity.ctid;
  7060. apiVo.actionName = "afterDesign";
  7061. apiVo.orderRemarks = entity.AfterSaleMethod;
  7062. apiVo.reasonRemarks = entity.AfterSaleReason;
  7063. apiVo.isDesign = isDesign;
  7064. apiVo.designFree = designFree;
  7065. apiVo.responsibleId = responsibleId;
  7066. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7067. if (toState == "设计师")
  7068. {
  7069. apiVo.isOriginal = Convert.ToBoolean(original);
  7070. }
  7071. designHelper.API_WorkCore(apiVo);//afterDesign
  7072. CeErpMethod methodSql = new CeErpMethod();
  7073. methodSql.con = entity.AfterSaleMethod;
  7074. methodSql.addTime = DateTime.Now;
  7075. methodSql.Create();
  7076. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7077. CeErpMethod.ExecuteNonQuery(delsql);
  7078. if (isCompale)
  7079. {
  7080. aftersale_data_change(entity.ctid);
  7081. }
  7082. returnSuccessMsg("操作成功!");
  7083. return;
  7084. }
  7085. returnErrorMsg("找不到订单记录");
  7086. }
  7087. }
  7088. public void ins_erp_toresponsible()
  7089. {
  7090. if (UrlPostParmsCheck("ctid"))
  7091. {
  7092. string eid = GetPostString("ctid");
  7093. CeErpTradeCell entity = null;
  7094. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7095. if (entity != null)
  7096. {
  7097. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7098. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7099. {
  7100. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7101. return;
  7102. }
  7103. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7104. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7105. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7106. if (entity.AfterSalePreTime == null)
  7107. {
  7108. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7109. {
  7110. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7111. }
  7112. }
  7113. entity.AfterSalePreTime = DateTime.Now;
  7114. //预完成给售后主管审核客户问题直接完成
  7115. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7116. {
  7117. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7118. {
  7119. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7120. }
  7121. }
  7122. ceErpTradeAfterSaleExtend.Update();
  7123. entity.AfterSaleState = 2;
  7124. entity.UpdateTime = DateTime.Now;
  7125. entity.Update();
  7126. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7127. aftersale_data_change(entity.ctid);
  7128. returnSuccessMsg("操作成功!");
  7129. return;
  7130. }
  7131. returnErrorMsg("找不到订单记录");
  7132. }
  7133. }
  7134. public void cancel_erp_aftersaleanddelnew()
  7135. {
  7136. if (UrlPostParmsCheck("ctid"))
  7137. {
  7138. string eid = GetPostString("ctid");
  7139. CeErpTradeCell entity = null;
  7140. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7141. if (entity != null)
  7142. {
  7143. entity.AfterSaleState = 0;
  7144. entity.AfterSaleReason = "";
  7145. entity.AfterSaleMethod = "";
  7146. entity.AfterSaleMemo = "";
  7147. entity.AfterSaleResponsible = "";
  7148. entity.ResponsibleUserId = "";
  7149. entity.DeductFee = 0;
  7150. entity.RefundFee = 0;
  7151. entity.IsArbitrate = 0;
  7152. CeErpTradeResponsible.DelByTid(eid, -1);
  7153. entity.Update();
  7154. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7155. if (after != null)
  7156. {
  7157. if (after.OrderState < 5)
  7158. CeErpTradeCell.DelByCtid("S_" + eid);
  7159. }
  7160. returnSuccessMsg("操作成功!");
  7161. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7162. return;
  7163. }
  7164. returnErrorMsg("找不到订单记录");
  7165. }
  7166. }
  7167. public void get_erp_aftersale_pregather()
  7168. {
  7169. List<string> lw = new List<string>();
  7170. int st = GetInt("st");
  7171. string tid = GetPostString("ctid");
  7172. if (tid.Length > 0)
  7173. {
  7174. string select_tid = getTidByCtid(tid);
  7175. lw.Add(string.Format("tid='{0}'", select_tid));
  7176. }
  7177. string shopname = GetPostString("shopname");
  7178. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7179. string buyernick = GetPostString("buyer_nick");
  7180. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7181. string sellermemo = GetPostString("seller_memo");
  7182. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7183. string orderState = GetPostString("orderState");
  7184. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7185. string reason = GetPostString("reason");
  7186. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7187. string method = GetPostString("method");
  7188. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7189. string handler = GetPostString("handler");
  7190. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7191. string handledate1 = GetPostString("handledate1");
  7192. string handledate2 = GetPostString("handledate2");
  7193. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7194. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7195. string supplier = GetPostString("supplier");
  7196. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7197. string responsible = GetPostString("responsibleman");
  7198. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7199. string customer = GetPostString("customer");
  7200. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7201. string design = GetPostString("design");
  7202. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7203. string afterMemoType = GetPostString("aftermemotype");
  7204. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7205. string afterSaleMemo = GetPostString("afterSaleMemo");
  7206. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7207. string afterresult = GetPostString("afterresult");
  7208. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7209. string poscode = CurrentUser.UserPost.Post.Code;
  7210. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7211. {
  7212. string shopid = CurrentUser.User.pemShop;
  7213. lw.Add(string.Format("shopId in ({0})", shopid));
  7214. }
  7215. var mainwhere = string.Join(" and ", lw.ToArray());
  7216. string ro_json = "";
  7217. string type = GetPostString("gather_type");
  7218. int number = 0;
  7219. if (poscode == "AfterSale")
  7220. {
  7221. //处理中
  7222. if (type == "Handling")
  7223. {
  7224. 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) : ""));
  7225. DataTable dt = null;
  7226. try
  7227. {
  7228. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7229. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7230. }
  7231. catch (Exception e)
  7232. {
  7233. dt = new DataTable();
  7234. }
  7235. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7236. return;
  7237. }
  7238. if (type == "Wait")
  7239. {
  7240. //待处理
  7241. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7242. DataTable dt1 = null;
  7243. try
  7244. {
  7245. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7246. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7247. }
  7248. catch (Exception e)
  7249. {
  7250. dt1 = new DataTable();
  7251. }
  7252. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7253. return;
  7254. }
  7255. if (type == "back")
  7256. {
  7257. //打回
  7258. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7259. DataTable dt2 = null;
  7260. try
  7261. {
  7262. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7263. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7264. }
  7265. catch (Exception e)
  7266. {
  7267. dt2 = new DataTable();
  7268. }
  7269. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7270. return;
  7271. }
  7272. if (type == "preCompletion")
  7273. {
  7274. //预完成
  7275. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7276. DataTable dt3 = null;
  7277. try
  7278. {
  7279. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7280. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7281. }
  7282. catch (Exception e)
  7283. {
  7284. dt3 = new DataTable();
  7285. }
  7286. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7287. return;
  7288. }
  7289. if (type == "documentary")
  7290. {
  7291. //跟单中
  7292. 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) : ""));
  7293. DataTable dt4 = null;
  7294. try
  7295. {
  7296. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7297. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7298. }
  7299. catch (Exception e)
  7300. {
  7301. dt4 = new DataTable();
  7302. }
  7303. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7304. return;
  7305. }
  7306. if (type == "reBack")
  7307. {
  7308. //被打回
  7309. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7310. DataTable dt1 = null;
  7311. try
  7312. {
  7313. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7314. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7315. }
  7316. catch (Exception e)
  7317. {
  7318. dt1 = new DataTable();
  7319. }
  7320. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7321. return;
  7322. }
  7323. }
  7324. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7325. {
  7326. if (type == "puBack")
  7327. {
  7328. //退回
  7329. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7330. DataTable dt = null;
  7331. try
  7332. {
  7333. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7334. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7335. }
  7336. catch (Exception e)
  7337. {
  7338. dt = new DataTable();
  7339. }
  7340. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7341. return;
  7342. }
  7343. if (type == "reBack")
  7344. {
  7345. //打回
  7346. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7347. DataTable dt1 = null;
  7348. try
  7349. {
  7350. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7351. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7352. }
  7353. catch (Exception e)
  7354. {
  7355. dt1 = new DataTable();
  7356. }
  7357. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7358. return;
  7359. }
  7360. if (type == "examEd")
  7361. {
  7362. //已审核
  7363. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7364. DataTable dt2 = null;
  7365. try
  7366. {
  7367. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7368. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7369. }
  7370. catch (Exception e)
  7371. {
  7372. dt2 = new DataTable();
  7373. }
  7374. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7375. return;
  7376. }
  7377. if (type == "waitExam")
  7378. {
  7379. //待审核
  7380. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7381. DataTable dt3 = null;
  7382. try
  7383. {
  7384. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7385. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7386. }
  7387. catch (Exception e)
  7388. {
  7389. dt3 = new DataTable();
  7390. }
  7391. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7392. return;
  7393. }
  7394. if (type == "Handling")
  7395. {
  7396. //处理中
  7397. 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) : ""));
  7398. DataTable dt4 = null;
  7399. try
  7400. {
  7401. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7402. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7403. }
  7404. catch (Exception e)
  7405. {
  7406. dt4 = new DataTable();
  7407. }
  7408. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7409. return;
  7410. }
  7411. if (type == "Wait")
  7412. {
  7413. //待处理
  7414. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7415. DataTable dt5 = null;
  7416. try
  7417. {
  7418. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7419. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7420. }
  7421. catch (Exception e)
  7422. {
  7423. dt5 = new DataTable();
  7424. }
  7425. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7426. return;
  7427. }
  7428. if (type == "documentary")
  7429. {
  7430. //跟单中
  7431. 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) : ""));
  7432. DataTable dt6 = null;
  7433. try
  7434. {
  7435. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7436. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7437. }
  7438. catch (Exception e)
  7439. {
  7440. dt6 = new DataTable();
  7441. }
  7442. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7443. return;
  7444. }
  7445. }
  7446. returnSuccess(ro_json);
  7447. }
  7448. public void end_erp_aftersale()
  7449. {
  7450. if (UrlPostParmsCheck("ctid"))
  7451. {
  7452. string eid = GetPostString("ctid");
  7453. CeErpTradeCell entity = null;
  7454. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7455. if (entity != null)
  7456. {
  7457. string stype = GetPostString("stype");
  7458. string typeStr = stype;
  7459. entity.AfterSaleState = 4;
  7460. entity.FinishAfterSaleTime = DateTime.Now;
  7461. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7462. entity.Update();
  7463. ApiVo apiVo = new ApiVo();
  7464. apiVo.orderNumber = entity.ctid;
  7465. apiVo.actionName = "afterOver";
  7466. designHelper.API_WorkCore(apiVo); //afterOver
  7467. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7468. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7469. CeErpSukuraData.createInfo(entity.ctid, 8);
  7470. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7471. returnSuccessMsg("操作成功!");
  7472. return;
  7473. }
  7474. returnErrorMsg("找不到订单记录");
  7475. }
  7476. }
  7477. public void ins_erp_finishaftersale()
  7478. {
  7479. if (UrlPostParmsCheck("id"))
  7480. {
  7481. string eid = GetPostString("id");
  7482. CeErpTradeResponsible entity = null;
  7483. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7484. if (entity != null)
  7485. {
  7486. entity.VerifyState = 1;
  7487. entity.VerifyTime = DateTime.Now;
  7488. entity.Update();
  7489. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7490. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7491. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7492. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7493. if (dt.Rows.Count <= 0)
  7494. {
  7495. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7496. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7497. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7498. CeErpSukuraData.createInfo(entity.tid, 8);
  7499. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7500. {
  7501. CeErpDesignerBill.Del(entity.tid);
  7502. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7503. }
  7504. }
  7505. returnSuccessMsg("操作成功!");
  7506. return;
  7507. }
  7508. returnErrorMsg("找不到订单记录");
  7509. }
  7510. }
  7511. public void upd_erp_arbitrateaftersale()
  7512. {
  7513. if (UrlPostParmsCheck("id"))
  7514. {
  7515. string eid = GetPostString("id");
  7516. CeErpTradeResponsible entity = null;
  7517. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7518. if (entity != null)
  7519. {
  7520. entity.IsArbitrate = 1;
  7521. entity.ArbitradeMemo = GetPostString("reason");
  7522. entity.VerifyState = 2;
  7523. entity.Update();
  7524. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7525. if (tradecell != null)
  7526. {
  7527. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7528. tradecell.IsArbitrate = 1;
  7529. tradecell.Update();
  7530. }
  7531. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7532. returnSuccessMsg("操作成功!");
  7533. return;
  7534. }
  7535. returnErrorMsg("找不到订单记录");
  7536. }
  7537. }
  7538. public void upd_erp_backaftersale()
  7539. {
  7540. if (UrlPostParmsCheck("tid"))
  7541. {
  7542. string eid = GetPostString("tid");
  7543. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7544. int backNum = 0;
  7545. if (number != null)
  7546. {
  7547. backNum = number.BackNum;
  7548. }
  7549. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7550. CeErpTradeCell entity = null;
  7551. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7552. if (entity != null)
  7553. {
  7554. entity.AfterSaleBackReason = GetPostString("backreason");
  7555. entity.AfterSaleState = 1;
  7556. entity.AfterSaleSupplierState = 0;
  7557. entity.UpdateTime = DateTime.Now;
  7558. entity.Update();
  7559. returnSuccessMsg("操作成功!");
  7560. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7561. return;
  7562. }
  7563. returnErrorMsg("找不到订单记录");
  7564. }
  7565. }
  7566. public void get_erp_supplieraftersalelist()
  7567. {
  7568. DataStruct dStruct = GetPostStruct();
  7569. List<string> lw = new List<string>();
  7570. string tid = GetPostString("ctid");
  7571. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7572. string shopname = GetPostString("shopname");
  7573. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7574. string buyernick = GetPostString("buyer_nick");
  7575. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7576. string sellermemo = GetPostString("seller_memo");
  7577. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7578. string orderState = GetPostString("orderState");
  7579. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7580. string afterState = GetPostString("afterstate");
  7581. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7582. string date1 = GetPostString("date1");
  7583. string date2 = GetPostString("date2");
  7584. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7585. if (dw.Length > 0) lw.Add(dw);
  7586. string price1 = GetPostString("price1");
  7587. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7588. string price2 = GetPostString("price2");
  7589. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7590. string reason = GetPostString("reason");
  7591. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7592. string method = GetPostString("method");
  7593. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7594. string handledate1 = GetPostString("handledate1");
  7595. string handledate2 = GetPostString("handledate2");
  7596. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7597. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7598. string handler = GetPostString("handler");
  7599. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7600. string afterdate1 = GetPostString("afterdate1");
  7601. string afterdate2 = GetPostString("afterdate2");
  7602. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7603. if (afterDate.Length > 0) lw.Add(afterDate);
  7604. string customer = GetPostString("customer");
  7605. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7606. string design = GetPostString("design");
  7607. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7608. string afterMemoType = GetPostString("aftermemotype");
  7609. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7610. string vstate = GetPostString("vstate");
  7611. if (vstate.Length > 0)
  7612. {
  7613. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7614. }
  7615. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7616. string supplier = GetPostString("supplier");
  7617. int supid = commonHelper.getSupplierIDByName(supplier);
  7618. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7619. string posCode = CurrentUser.UserPost.Post.Code;
  7620. if (posCode == "Supplier")
  7621. {
  7622. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7623. }
  7624. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7625. {
  7626. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7627. }
  7628. else
  7629. {
  7630. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7631. }
  7632. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7633. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7634. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7635. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7636. writeGridDataTableJson(dStruct.TotalCount, dt);
  7637. }
  7638. public void upd_erp_supverifyaftersale()
  7639. {
  7640. if (UrlPostParmsCheck("id"))
  7641. {
  7642. string id = GetPostString("id");
  7643. int st = GetPostInt("afterstate");
  7644. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7645. CeErpTradeCell entity = null;
  7646. if (ceErpTradeResponsible != null)
  7647. {
  7648. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7649. }
  7650. string afmemo = GetPostString("supmemo");
  7651. string image = GetPostString("image");
  7652. if (entity != null)
  7653. {
  7654. entity.AfterSaleSupplierState = st;
  7655. entity.AfterSaleSupplierMemo = afmemo;
  7656. if (st == 1)
  7657. {
  7658. ceErpTradeResponsible.VerifyState = 1;
  7659. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7660. ceErpTradeResponsible.Update();
  7661. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7662. if (isAll)
  7663. {
  7664. entity.AfterSaleState = 4;
  7665. entity.FinishAfterSaleTime = DateTime.Now;
  7666. }
  7667. }
  7668. else
  7669. {
  7670. CeErpTradeResponsible.dateByTid(entity.ctid);
  7671. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7672. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7673. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7674. if (num <= 1)
  7675. {
  7676. entity.AfterSaleState = 1;
  7677. }
  7678. else
  7679. {
  7680. entity.AfterSaleState = 5;
  7681. }
  7682. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7683. if (ceErpTradeAfterSaleExtend != null)
  7684. {
  7685. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7686. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7687. ceErpTradeAfterSaleExtend.Update();
  7688. }
  7689. else
  7690. {
  7691. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7692. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7693. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7694. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7695. ceErpTradeAfterSaleExtend.Create();
  7696. }
  7697. }
  7698. if (entity.AfterSaleState == 4)
  7699. {
  7700. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7701. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7702. {
  7703. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7704. }
  7705. ApiVo apiVo = new ApiVo();
  7706. apiVo.orderNumber = entity.ctid;
  7707. apiVo.actionName = "afterOver";
  7708. designHelper.API_WorkCore(apiVo); //afterOver
  7709. }
  7710. entity.UpdateTime = DateTime.Now;
  7711. entity.Update();
  7712. returnSuccessMsg("操作成功!");
  7713. CeErpSukuraData.createInfo(entity.ctid, 8);
  7714. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7715. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7716. return;
  7717. }
  7718. returnErrorMsg("找不到订单记录");
  7719. }
  7720. }
  7721. public void upd_erp_masteraftersale()
  7722. {
  7723. if (UrlPostParmsCheck("id"))
  7724. {
  7725. string id = GetPostString("id");
  7726. int st = GetPostInt("afterstate");
  7727. string afmemo = GetPostString("supmemo");
  7728. string image = GetPostString("image");
  7729. string textResult = GetPostString("textResult");
  7730. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7731. if (ceErpTradeResponsible != null)
  7732. {
  7733. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7734. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7735. ceErpTradeResponsible.Update();
  7736. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7737. if (entity != null)
  7738. {
  7739. entity.AfterSaleSupplierState = st;
  7740. entity.AfterSaleSupplierMemo = afmemo;
  7741. if (st == 1)
  7742. {
  7743. }
  7744. else
  7745. {
  7746. CeErpTradeResponsible.dateByTid(entity.ctid);
  7747. //退回到售后
  7748. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7749. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7750. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7751. if (num <= 1)
  7752. {
  7753. entity.AfterSaleState = 1;
  7754. }
  7755. else
  7756. {
  7757. entity.AfterSaleState = 5;
  7758. }
  7759. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7760. if (ceErpTradeAfterSaleExtend != null)
  7761. {
  7762. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7763. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7764. ceErpTradeAfterSaleExtend.Update();
  7765. }
  7766. else
  7767. {
  7768. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7769. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7770. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7771. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7772. ceErpTradeAfterSaleExtend.Create();
  7773. }
  7774. }
  7775. entity.UpdateTime = DateTime.Now;
  7776. entity.Update();
  7777. returnSuccessMsg("操作成功!");
  7778. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7779. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7780. return;
  7781. }
  7782. }
  7783. returnErrorMsg("找不到订单记录");
  7784. }
  7785. }
  7786. public void upd_erp_personaftersale()
  7787. {
  7788. if (UrlPostParmsCheck("id"))
  7789. {
  7790. //林小连
  7791. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7792. {
  7793. upd_erp_masteraftersale();
  7794. return;
  7795. }
  7796. string id = GetPostString("id");
  7797. int st = GetPostInt("afterstate");
  7798. string afmemo = GetPostString("supmemo");
  7799. string image = GetPostString("image");
  7800. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7801. if (ceErpTradeResponsible != null)
  7802. {
  7803. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7804. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7805. ceErpTradeResponsible.Update();
  7806. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7807. if (entity != null)
  7808. {
  7809. entity.AfterSaleSupplierMemo = afmemo;
  7810. entity.AfterSaleSupplierState = st;
  7811. if (st == 1)
  7812. {
  7813. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7814. if (isAll)
  7815. {
  7816. entity.AfterSaleState = 4;
  7817. entity.FinishAfterSaleTime = DateTime.Now;
  7818. }
  7819. }
  7820. else
  7821. {
  7822. CeErpTradeResponsible.dateByTid(entity.ctid);
  7823. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7824. if (ceErpTradeAfterSaleExtend != null)
  7825. {
  7826. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7827. ceErpTradeAfterSaleExtend.Update();
  7828. }
  7829. else
  7830. {
  7831. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7832. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7833. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7834. ceErpTradeAfterSaleExtend.Create();
  7835. }
  7836. //退回到主管
  7837. //entity.AfterSaleState = 2;
  7838. }
  7839. if (entity.AfterSaleState == 4)
  7840. {
  7841. ApiVo apiVo = new ApiVo();
  7842. apiVo.orderNumber = entity.ctid;
  7843. apiVo.actionName = "afterOver";
  7844. designHelper.API_WorkCore(apiVo); //afterOver
  7845. }
  7846. entity.UpdateTime = DateTime.Now;
  7847. entity.Update();
  7848. returnSuccessMsg("操作成功!");
  7849. CeErpSukuraData.createInfo(entity.ctid, 8);
  7850. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7851. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7852. return;
  7853. }
  7854. }
  7855. returnErrorMsg("找不到订单记录");
  7856. }
  7857. }
  7858. public void set_erp_supplierrefundtag()
  7859. {
  7860. if (UrlPostParmsCheck("ctid"))
  7861. {
  7862. string eid = GetPostString("ctid");
  7863. CeErpTradeCell entity = null;
  7864. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7865. if (entity != null)
  7866. {
  7867. entity.IsSupplierRefund = GetPostInt("tag");
  7868. entity.Update();
  7869. returnSuccessMsg("操作成功!");
  7870. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7871. return;
  7872. }
  7873. returnErrorMsg("找不到订单记录");
  7874. }
  7875. }
  7876. public void get_erp_refundlist()
  7877. {
  7878. DataStruct dStruct = GetPostStruct();
  7879. List<string> lw = new List<string>();
  7880. string tid = GetPostString("tid");
  7881. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7882. //string rid = GetPostString("refund_id");
  7883. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7884. string shopname = GetPostString("shopname");
  7885. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7886. string buyernick = GetPostString("buyer_nick");
  7887. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7888. string customer = GetPostString("customer");
  7889. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7890. string design = GetPostString("design");
  7891. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7892. string sellermemo = GetPostString("seller_memo");
  7893. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7894. //string date1 = GetPostString("date1");
  7895. //string date2 = GetPostString("date2");
  7896. //string dateType = GetPostString("dateType");
  7897. //if (dateType.Length > 0)
  7898. //{
  7899. // if (dateType == "1001") dateType = "0";
  7900. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7901. // if (searchDT.Count == 2)
  7902. // {
  7903. // date1 = searchDT[0].ToString();
  7904. // date2 = searchDT[1].ToString();
  7905. // }
  7906. //}
  7907. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7908. //if (dw.Length > 0) lw.Add(dw);
  7909. string redate1 = GetPostString("refunddate1");
  7910. string redate2 = GetPostString("refunddate2");
  7911. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7912. if (dwdate.Length > 0) lw.Add(dwdate);
  7913. string price1 = GetPostString("price1");
  7914. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7915. string price2 = GetPostString("price2");
  7916. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7917. string ispartrefund = GetPostString("ispartrefund");
  7918. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7919. string refundState = GetPostString("refundvstate");
  7920. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7921. int st = GetInt("st");
  7922. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7923. {
  7924. string responsible = GetPostString("responsibleman");
  7925. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7926. lw.Add(string.Format("RefundState>={0}", st));
  7927. string code = CurrentUser.UserPost.Post.Code;
  7928. if (code == "CustomerService")
  7929. {
  7930. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7931. }
  7932. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7933. {
  7934. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7935. }
  7936. else if (code == "Place" || code == "PlaceMr")
  7937. {
  7938. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7939. }
  7940. dStruct.Order = "RefundState asc,created desc";
  7941. }
  7942. else if (st == 10)
  7943. {
  7944. string responsible = GetPostString("responsibleman");
  7945. if (responsible == "空白")
  7946. {
  7947. lw.Add(string.Format("ResponsibleUserName = ''"));
  7948. }
  7949. else if (responsible.Length > 0)
  7950. {
  7951. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7952. }
  7953. lw.Add(string.Format("RefundState>=0"));
  7954. dStruct.Order = "created desc";
  7955. }
  7956. else
  7957. {
  7958. string responsible = GetPostString("responsibleman");
  7959. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7960. lw.Add(string.Format("RefundState={0}", st));
  7961. dStruct.Order = "created desc";
  7962. }
  7963. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7964. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7965. dt.Columns.Add("refund_fees");
  7966. foreach (DataRow dr in dt.Rows)
  7967. {
  7968. String status = dr["status"].ToString();
  7969. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7970. {
  7971. dr["refund_fees"] = dr["refund_fee"];
  7972. }
  7973. else
  7974. {
  7975. dr["refund_fees"] = "0.0";
  7976. }
  7977. }
  7978. writeGridDataTableJson(dStruct.TotalCount, dt);
  7979. }
  7980. public void get_erp_refunddesignlist()
  7981. {
  7982. DataStruct dStruct = GetPostStruct();
  7983. List<string> lw = new List<string>();
  7984. string tid = GetPostString("tid");
  7985. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7986. string shopname = GetPostString("shopname");
  7987. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7988. string buyernick = GetPostString("buyer_nick");
  7989. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7990. string customer = GetPostString("customer");
  7991. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7992. string design = GetPostString("design");
  7993. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7994. string sellermemo = GetPostString("seller_memo");
  7995. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7996. string redate1 = GetPostString("refunddate1");
  7997. string redate2 = GetPostString("refunddate2");
  7998. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7999. if (dwdate.Length > 0) lw.Add(dwdate);
  8000. string price1 = GetPostString("price1");
  8001. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8002. string price2 = GetPostString("price2");
  8003. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8004. string ispartrefund = GetPostString("ispartrefund");
  8005. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8006. string designerorg = GetPostString("designerorg");
  8007. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8008. string refundState = GetPostString("refundState");
  8009. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8010. int myOrgid = CurrentUser.UserPost.OrgID;
  8011. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8012. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8013. {
  8014. if (CurrentUser.User.TeamIds.Length > 0)
  8015. {
  8016. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8017. }
  8018. else
  8019. {
  8020. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8021. }
  8022. }
  8023. else if ("SysAdmin".Equals(myOrgCode))
  8024. {
  8025. }
  8026. else
  8027. {
  8028. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8029. {
  8030. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8031. }
  8032. else
  8033. {
  8034. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8035. }
  8036. }
  8037. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8038. dStruct.Order = "created desc";
  8039. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8040. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8041. dt.Columns.Add("refund_fees");
  8042. foreach (DataRow dr in dt.Rows)
  8043. {
  8044. String status = dr["status"].ToString();
  8045. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8046. {
  8047. dr["refund_fees"] = dr["refund_fee"];
  8048. }
  8049. else
  8050. {
  8051. dr["refund_fees"] = "0.0";
  8052. }
  8053. }
  8054. writeGridDataTableJson(dStruct.TotalCount, dt);
  8055. }
  8056. public void handle_erp_refundtag()
  8057. {
  8058. if (UrlPostParmsCheck("refund_id"))
  8059. {
  8060. string eid = GetPostString("refund_id");
  8061. string respMan = GetPostString("ResponsibleName");
  8062. if (respMan.Length <= 0)
  8063. {
  8064. returnErrorMsg("责任人不能为空");
  8065. return;
  8066. }
  8067. CeErpTradeRefund entity = null;
  8068. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8069. if (entity != null)
  8070. {
  8071. entity.ResponsibleUserName = respMan;
  8072. string userid = GetPostString("ResponsibleUserId");
  8073. if (userid.Length > 0)
  8074. {
  8075. entity.ResponsibleUserId = userid;
  8076. }
  8077. entity.Memo = GetPostString("Memo");
  8078. if (respMan.IndexOf("客服") != -1 ||
  8079. respMan.IndexOf("设计师") != -1 ||
  8080. respMan.IndexOf("下单员") != -1)
  8081. {
  8082. entity.RefundState = 2;
  8083. }
  8084. else
  8085. {
  8086. entity.RefundState = 3;
  8087. }
  8088. entity.modified = DateTime.Now;
  8089. entity.Update();
  8090. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8091. returnSuccessMsg("操作成功!");
  8092. return;
  8093. }
  8094. returnErrorMsg("找不到订单记录");
  8095. }
  8096. }
  8097. public void handle_erp_designrefundtag()
  8098. {
  8099. if (UrlPostParmsCheck("refund_id"))
  8100. {
  8101. string eid = GetPostString("refund_id");
  8102. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8103. if (ceErpTradeCellExtend == null)
  8104. {
  8105. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8106. ceErpTradeCellExtend.ctid = eid;
  8107. }
  8108. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8109. if (ceErpTradeCellExtend.ID > 0)
  8110. {
  8111. ceErpTradeCellExtend.Update();
  8112. }
  8113. else
  8114. {
  8115. ceErpTradeCellExtend.Create();
  8116. }
  8117. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8118. returnSuccessMsg("操作成功!");
  8119. return;
  8120. }
  8121. returnErrorMsg("找不到订单记录");
  8122. }
  8123. public void upd_erp_refundverify()
  8124. {
  8125. if (UrlPostParmsCheck("refund_id"))
  8126. {
  8127. string eid = GetPostString("refund_id");
  8128. CeErpTradeRefund entity = null;
  8129. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8130. if (entity != null)
  8131. {
  8132. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8133. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8134. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8135. {
  8136. entity.RefundState = 2;
  8137. }
  8138. else
  8139. {
  8140. entity.RefundState = 3;
  8141. }
  8142. entity.Update();
  8143. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8144. returnSuccessMsg("操作成功!");
  8145. return;
  8146. }
  8147. returnErrorMsg("找不到订单记录");
  8148. }
  8149. }
  8150. public void upd_erp_refundapprove()
  8151. {
  8152. if (UrlPostParmsCheck("refund_id"))
  8153. {
  8154. string eid = GetPostString("refund_id");
  8155. CeErpTradeRefund entity = null;
  8156. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8157. if (entity != null)
  8158. {
  8159. int apr = GetPostInt("approve");
  8160. if (apr == 0)
  8161. {
  8162. entity.RefundState = 1;
  8163. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8164. }
  8165. else if (apr == 1)
  8166. {
  8167. entity.RefundState = 3;
  8168. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8169. }
  8170. entity.modified = DateTime.Now;
  8171. entity.Update();
  8172. returnSuccessMsg("操作成功!");
  8173. return;
  8174. }
  8175. returnErrorMsg("找不到订单记录");
  8176. }
  8177. }
  8178. public void get_erp_billlist()
  8179. {
  8180. DataStruct dStruct = GetPostStruct();
  8181. List<string> lw = new List<string>();
  8182. string title = GetPostString("title");
  8183. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8184. string tid = GetPostString("tid");
  8185. string tids = GetPostString("tids");
  8186. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8187. if (tids.Length > 0)
  8188. {
  8189. tids = "'" + tids + "'";
  8190. tids = tids.Replace(",", "','");
  8191. lw.Add(string.Format("tid in ({0})", tids));
  8192. }
  8193. string shopname = GetPostString("shopname");
  8194. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8195. string buyernick = GetPostString("buyer_nick");
  8196. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8197. string customer = GetPostString("customer");
  8198. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8199. string date1 = GetPostString("date1");
  8200. string date2 = GetPostString("date2");
  8201. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8202. if (dw.Length > 0) lw.Add(dw);
  8203. string price1 = GetPostString("price1");
  8204. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8205. string price2 = GetPostString("price2");
  8206. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8207. string returndate1 = GetPostString("returndate1");
  8208. string returndate2 = GetPostString("returndate2");
  8209. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8210. if (dw1.Length > 0) lw.Add(dw1);
  8211. string billtype = GetPostString("billtype");
  8212. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8213. string billstate = GetPostString("billstate");
  8214. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8215. string usershop = CurrentUser.User.pemShop;
  8216. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8217. dStruct.Order = "createTime desc";
  8218. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8219. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8220. //foreach (DataRow dr in dt.Rows)
  8221. //{
  8222. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8223. //}
  8224. writeGridDataTableJson(dStruct.TotalCount, dt);
  8225. }
  8226. public void modify_erp_billinfo()
  8227. {
  8228. if (UrlPostParmsCheck("ID"))
  8229. {
  8230. string eid = GetPostString("ID");
  8231. CeErpBill bill_entity = null;
  8232. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8233. if (bill_entity != null)
  8234. {
  8235. bill_entity.tid = GetPostString("tid");
  8236. bill_entity.title = GetPostString("title");
  8237. bill_entity.tax = GetPostString("tax");
  8238. bill_entity.bank = GetPostString("bank");
  8239. bill_entity.bankac = GetPostString("bankac");
  8240. bill_entity.address = GetPostString("address");
  8241. bill_entity.phone = GetPostString("phone");
  8242. bill_entity.price = GetPostString("price");
  8243. bill_entity.productId = GetPostInt("ProductName");
  8244. bill_entity.num = GetPostInt("num");
  8245. bill_entity.unit = GetPostString("unit");
  8246. bill_entity.type = GetPostString("type");
  8247. bill_entity.sendType = GetPostString("SendType");
  8248. bill_entity.email = GetPostString("email");
  8249. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8250. bill_entity.shopName = GetPostString("ShopName");
  8251. bill_entity.applymemo = GetPostString("applymemo");
  8252. bill_entity.modifyTime = DateTime.Now;
  8253. bill_entity.createTime = DateTime.Now;
  8254. bill_entity.state = 0;
  8255. bill_entity.Update();
  8256. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8257. returnSuccessMsg("发票修改成功!");
  8258. return;
  8259. }
  8260. returnErrorMsg("找不到对应记录");
  8261. }
  8262. }
  8263. public void set_erp_invoicing()
  8264. {
  8265. if (UrlPostParmsCheck("id"))
  8266. {
  8267. try
  8268. {
  8269. string eid = GetPostString("id");
  8270. CeErpBill bill_entity = null;
  8271. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8272. if (bill_entity != null)
  8273. {
  8274. int ComId = GetPostInt("ComId");
  8275. //string memo = GetPostString("Memo");
  8276. int allInfo = GetPostInt("allinfo");
  8277. string clert = CurrentUser.User.Name;
  8278. //string detailValue = GetPostString("detailvalue");
  8279. string billId = bill_entity.billOrderId;
  8280. string[] billIdList = billId.Split(',');
  8281. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8282. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8283. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8284. {
  8285. billCount += 1;
  8286. }
  8287. if (billId.Length <= 0 || billIdList.Length != billCount)
  8288. {
  8289. bill_entity.billOrderId = "";
  8290. string prebill = "ltb";
  8291. for (int idx = 1; idx <= billCount; idx++)
  8292. {
  8293. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8294. string billoid = prebill + idx + dtstr;
  8295. bill_entity.billOrderId += billoid;
  8296. if (idx < billCount)
  8297. {
  8298. bill_entity.billOrderId += ",";
  8299. }
  8300. }
  8301. }
  8302. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8303. if (bill_entity.state == 5)
  8304. {
  8305. string errMsg = bill_entity.failerror;
  8306. string[] errlist = errMsg.Split('|');
  8307. string[] errTags = new string[errlist.Length];
  8308. for (int itag = 0; itag < errlist.Length; itag++)
  8309. {
  8310. if (errlist[itag].Length <= 0) continue;
  8311. errTags[itag] = errlist[itag].Split('&')[0];
  8312. }
  8313. for (int iii = 0; iii < errTags.Length; iii++)
  8314. {
  8315. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8316. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8317. if (billOrderList.Length >= erroBillOrderTag)
  8318. {
  8319. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8320. if (needModifyBillId.Length <= 19)
  8321. {
  8322. needModifyBillId = needModifyBillId + "1";
  8323. }
  8324. else
  8325. {
  8326. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8327. last = last + 1;
  8328. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8329. }
  8330. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8331. }
  8332. }
  8333. }
  8334. bool isHaveBillSucces = false;
  8335. string totalRes = "";
  8336. bill_entity.failerror = "";
  8337. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8338. {
  8339. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8340. totalRes += res;
  8341. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8342. {
  8343. isHaveBillSucces = true;
  8344. bill_entity.comId = ComId;
  8345. bill_entity.state = 1;
  8346. bill_entity.executeTime = DateTime.Now;
  8347. bill_entity.executeUser = clert;
  8348. }
  8349. else
  8350. {
  8351. bill_entity.state = 5;
  8352. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8353. }
  8354. }
  8355. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8356. bill_entity.Update();
  8357. if (isHaveBillSucces)
  8358. {
  8359. StringBuilder sql = new StringBuilder();
  8360. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8361. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8362. }
  8363. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8364. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8365. {
  8366. returnErrorMsg("开票失败");
  8367. }
  8368. else
  8369. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8370. return;
  8371. }
  8372. returnErrorMsg("找不到对应记录");
  8373. }
  8374. catch (Exception ex)
  8375. {
  8376. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8377. returnErrorMsg("操作失败");
  8378. }
  8379. }
  8380. }
  8381. public void get_erp_invoicing_back()
  8382. {
  8383. if (UrlPostParmsCheck("id"))
  8384. {
  8385. try
  8386. {
  8387. string id = GetPostString("id");
  8388. CeErpBill entiy = CeErpBill.Get(id);
  8389. if (entiy != null)
  8390. {
  8391. if (entiy.state == 0)
  8392. {
  8393. returnErrorMsg("发票还未开具");
  8394. return;
  8395. }
  8396. string[] billOrderList = entiy.billOrderId.Split(',');
  8397. int iTag = 0;
  8398. entiy.fplsh = "";
  8399. entiy.fpdm = "";
  8400. entiy.fphm = "";
  8401. foreach (string billOrderId in billOrderList)
  8402. {
  8403. iTag++;
  8404. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8405. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8406. {
  8407. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8408. try
  8409. {
  8410. Invoicing_get_response_Obj iObj = null;
  8411. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8412. if (iObj != null)
  8413. {
  8414. entiy.state = 2;
  8415. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8416. entiy.fpdm += iObj.list[0].c_fpdm;
  8417. entiy.fphm += iObj.list[0].c_fphm;
  8418. if (iTag < billOrderList.Length)
  8419. {
  8420. entiy.fplsh += ",";
  8421. entiy.fpdm += ",";
  8422. entiy.fphm += ",";
  8423. }
  8424. entiy.Update();
  8425. }
  8426. StringBuilder sql = new StringBuilder();
  8427. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8428. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8429. returnSuccessMsg("开票成功");
  8430. }
  8431. catch (Exception ex)
  8432. {
  8433. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8434. }
  8435. return;
  8436. }
  8437. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8438. {
  8439. var res_obj = new
  8440. {
  8441. data = "开票中"
  8442. };
  8443. string ro_json = JsonConvert.SerializeObject(res_obj);
  8444. returnSuccess(ro_json);
  8445. return;
  8446. }
  8447. else
  8448. {
  8449. int eidx = res.IndexOf("c_resultmsg");
  8450. int lidx = res.IndexOf("c_status");
  8451. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8452. entiy.state = 5;
  8453. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8454. entiy.Update();
  8455. returnErrorMsg("开票失败");
  8456. return;
  8457. }
  8458. }
  8459. }
  8460. }
  8461. catch (Exception ex)
  8462. {
  8463. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8464. }
  8465. return;
  8466. }
  8467. }
  8468. public void get_erp_invoicing()
  8469. {
  8470. if (UrlPostParmsCheck("id"))
  8471. {
  8472. try
  8473. {
  8474. string id = GetPostString("id");
  8475. CeErpBill entiy = CeErpBill.Get(id);
  8476. if (entiy != null)
  8477. {
  8478. if (entiy.state == 0)
  8479. {
  8480. returnErrorMsg("发票还未开具");
  8481. return;
  8482. }
  8483. if (entiy.sendType == "纸质发票")
  8484. {
  8485. if (entiy.img.Length <= 0)
  8486. {
  8487. returnErrorMsg("查无纸质发票");
  8488. return;
  8489. }
  8490. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8491. returnSuccess(returnres);
  8492. return;
  8493. }
  8494. string[] billOrderList = entiy.billOrderId.Split(',');
  8495. int iTag = 0;
  8496. string fpUrl = "";
  8497. entiy.fplsh = "";
  8498. entiy.fpdm = "";
  8499. entiy.fphm = "";
  8500. foreach (string billOrderId in billOrderList)
  8501. {
  8502. iTag++;
  8503. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8504. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8505. {
  8506. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8507. Invoicing_get_response_Obj iObj = null;
  8508. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8509. if (iObj != null)
  8510. {
  8511. //entiy.state = 2;
  8512. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8513. entiy.fpdm += iObj.list[0].c_fpdm;
  8514. entiy.fphm += iObj.list[0].c_fphm;
  8515. if (iTag < billOrderList.Length)
  8516. {
  8517. entiy.fplsh += ",";
  8518. entiy.fpdm += ",";
  8519. entiy.fphm += ",";
  8520. }
  8521. entiy.Update();
  8522. fpUrl += iObj.list[0].c_url + ",";
  8523. }
  8524. //returnSuccess(res);
  8525. StringBuilder sql = new StringBuilder();
  8526. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8527. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8528. }
  8529. else
  8530. {
  8531. int eidx = res.IndexOf("c_resultmsg");
  8532. //int lidx = res.IndexOf("c_status");
  8533. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8534. //开票失败
  8535. entiy.state = 5;
  8536. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8537. entiy.Update();
  8538. returnErrorMsg("开票失败");
  8539. return;
  8540. }
  8541. }
  8542. var returnObj = new
  8543. {
  8544. data = fpUrl
  8545. };
  8546. string ro_json = JsonConvert.SerializeObject(returnObj);
  8547. returnSuccess(ro_json);
  8548. }
  8549. }
  8550. catch (Exception ex)
  8551. {
  8552. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8553. }
  8554. return;
  8555. }
  8556. }
  8557. public void save_erp_billimg()
  8558. {
  8559. if (UrlPostParmsCheck("id"))
  8560. {
  8561. string eid = GetPostString("id");
  8562. CeErpBill bill_entity = null;
  8563. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8564. if (bill_entity != null)
  8565. {
  8566. bill_entity.img = GetPostString("img");
  8567. bill_entity.executeTime = DateTime.Now;
  8568. bill_entity.state = 2;
  8569. bill_entity.Update();
  8570. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8571. returnSuccessMsg("保存成功");
  8572. }
  8573. return;
  8574. }
  8575. }
  8576. public void upd_erp_billreturnback()
  8577. {
  8578. if (UrlPostParmsCheck("id"))
  8579. {
  8580. int eid = GetPostInt("id");
  8581. CeErpBill bill_entity = null;
  8582. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8583. if (bill_entity != null)
  8584. {
  8585. bill_entity.state = 3;
  8586. bill_entity.returnReason = GetPostString("reason");
  8587. bill_entity.Update();
  8588. returnSuccessMsg("驳回成功!");
  8589. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8590. }
  8591. return;
  8592. }
  8593. }
  8594. public void cancel_erp_bill()
  8595. {
  8596. if (UrlPostParmsCheck("id"))
  8597. {
  8598. int eid = GetPostInt("id");
  8599. int detailValue = GetPostInt("detailvalue");
  8600. CeErpBill bill_entity = null;
  8601. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8602. string cres = "";
  8603. string gres = "";
  8604. if (bill_entity != null)
  8605. {
  8606. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8607. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8608. {
  8609. int iTag = 0;
  8610. bill_entity.fplsh = "";
  8611. bill_entity.fpdm = "";
  8612. bill_entity.fphm = "";
  8613. foreach (string billOrderId in billOrderList)
  8614. {
  8615. iTag++;
  8616. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8617. if (gres.IndexOf("success") != -1)
  8618. {
  8619. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8620. Invoicing_get_response_Obj iObj = null;
  8621. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8622. if (iObj != null)
  8623. {
  8624. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8625. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8626. bill_entity.fphm += iObj.list[0].c_fphm;
  8627. if (iTag < billOrderList.Length)
  8628. {
  8629. bill_entity.fplsh += ",";
  8630. bill_entity.fpdm += ",";
  8631. bill_entity.fphm += ",";
  8632. }
  8633. bill_entity.Update();
  8634. }
  8635. }
  8636. else
  8637. {
  8638. returnErrorMsg(gres);
  8639. return;
  8640. }
  8641. }
  8642. }
  8643. if (bill_entity.sendType == "纸质发票")
  8644. {
  8645. //作废
  8646. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8647. //if (DateTime.Now.Month == extime.Month)
  8648. //{
  8649. //cres = taobaoHelper.cancel_invoicing(eid);
  8650. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8651. //{
  8652. bill_entity.state = 4;//已作废
  8653. bill_entity.Update();
  8654. returnSuccessMsg("发票已作废");
  8655. return;
  8656. //}
  8657. //else
  8658. //{
  8659. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8660. // bill_entity.Update();
  8661. // returnErrorMsg(cres);
  8662. // return;
  8663. //}
  8664. //}
  8665. //else
  8666. //{
  8667. // returnErrorMsg("纸质发票只能作废本月的发票");
  8668. // return;
  8669. //}
  8670. }
  8671. //红冲
  8672. int redTag = 0;
  8673. string[] fpdmList = bill_entity.fpdm.Split(',');
  8674. string[] fphmList = bill_entity.fphm.Split(',');
  8675. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8676. {
  8677. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8678. return;
  8679. }
  8680. foreach (string billOrderId in billOrderList)
  8681. {
  8682. redTag++;
  8683. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8684. cres += onecres;
  8685. cres += ",";
  8686. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8687. {
  8688. bill_entity.state = 4;//已作废
  8689. //bill_entity.Update();
  8690. //returnSuccessMsg("发票已红冲");
  8691. }
  8692. else if (onecres.IndexOf("重复冲红") != -1)
  8693. {
  8694. bill_entity.state = 4;//已作废
  8695. //bill_entity.Update();
  8696. //returnSuccessMsg("发票已红冲");
  8697. }
  8698. else
  8699. {
  8700. string errmsg = commonHelper.KeepChinese(onecres);
  8701. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8702. }
  8703. }
  8704. bill_entity.Update();
  8705. if (cres.IndexOf("失败") != -1)
  8706. returnErrorMsg("红冲失败");
  8707. else
  8708. returnSuccessMsg("发票已红冲");
  8709. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8710. return;
  8711. }
  8712. return;
  8713. }
  8714. }
  8715. public void del_erp_billorder()
  8716. {
  8717. if (UrlPostParmsCheck("id"))
  8718. {
  8719. string eid = GetPostString("id");
  8720. CeErpBill.Del(eid);
  8721. CeErpBill bill = CeErpBill.Get(eid);
  8722. if (bill != null)
  8723. {
  8724. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8725. }
  8726. returnSuccessMsg("删除成功");
  8727. }
  8728. }
  8729. public void finish_erp_bill()
  8730. {
  8731. if (UrlPostParmsCheck("ids"))
  8732. {
  8733. string eids = GetPostString("ids");
  8734. string[] list = eids.Split(',');
  8735. foreach (string eid in list)
  8736. {
  8737. CeErpBill bill = CeErpBill.Get(eid);
  8738. if (bill != null)
  8739. {
  8740. bill.state = 2;
  8741. bill.Update();
  8742. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8743. }
  8744. }
  8745. returnSuccessMsg("操作成功");
  8746. }
  8747. }
  8748. public void get_erp_returncash()
  8749. {
  8750. DataStruct dStruct = GetPostStruct();
  8751. List<string> lw = new List<string>();
  8752. string tid = GetPostString("tid");
  8753. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8754. string shopname = GetPostString("shopname");
  8755. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8756. string buyernick = GetPostString("buyer_nick");
  8757. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8758. string customer = GetPostString("customer");
  8759. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8760. string returndate1 = GetPostString("returndate1");
  8761. string returndate2 = GetPostString("returndate2");
  8762. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8763. if (dw.Length > 0) lw.Add(dw);
  8764. string finishDate1 = GetPostString("finishdate1");
  8765. string finishDate2 = GetPostString("finishdate2");
  8766. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8767. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8768. string returntype = GetPostString("returntype");
  8769. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8770. string returnvstate = GetPostString("returnvstate");
  8771. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8772. dStruct.Order = "created desc";
  8773. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8774. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8775. writeGridDataTableJson(dStruct.TotalCount, dt);
  8776. }
  8777. public void get_erp_staygoods()
  8778. {
  8779. DataStruct dStruct = GetPostStruct();
  8780. List<string> lw = new List<string>();
  8781. string tid = GetPostString("tid");
  8782. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8783. string shopname = GetPostString("shopname");
  8784. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8785. string wangwang = GetPostString("wangwang");
  8786. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8787. string customer = GetPostString("customer");
  8788. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8789. string returndate1 = GetPostString("returndate1");
  8790. string returndate2 = GetPostString("returndate2");
  8791. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8792. if (dw.Length > 0) lw.Add(dw);
  8793. string finishDate1 = GetPostString("finishdate1");
  8794. string finishDate2 = GetPostString("finishdate2");
  8795. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8796. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8797. string returnvstate = GetPostString("returnvstate");
  8798. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8799. string persuadetype = GetPostString("persuadetype");
  8800. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8801. string customerOrg = GetPostString("customerOrg");
  8802. if (customerOrg.Length > 0)
  8803. {
  8804. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8805. }
  8806. dStruct.Order = "creata_time desc";
  8807. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8808. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8809. writeGridDataTableJson(dStruct.TotalCount, dt);
  8810. }
  8811. public void upd_erp_staygoods()
  8812. {
  8813. if (UrlPostParmsCheck("id"))
  8814. {
  8815. int eid = GetPostInt("id");
  8816. CeErpStayGoods entity = null;
  8817. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8818. if (entity != null)
  8819. {
  8820. entity.audit_type = 1;
  8821. entity.audit_time = DateTime.Now;
  8822. entity.audit_u_id = CurrentUser.UserID;
  8823. entity.audit_u_name = CurrentUser.UserName;
  8824. entity.Update();
  8825. returnSuccessMsg("审核成功!");
  8826. return;
  8827. }
  8828. returnErrorMsg("找不到订单记录");
  8829. }
  8830. }
  8831. public void upd_erp_stayGoodsback()
  8832. {
  8833. if (UrlPostParmsCheck("id"))
  8834. {
  8835. int eid = GetPostInt("id");
  8836. CeErpStayGoods entity = null;
  8837. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8838. if (entity != null)
  8839. {
  8840. entity.audit_text = GetPostString("reason");
  8841. entity.audit_type = 2;
  8842. entity.audit_time = DateTime.Now;
  8843. entity.audit_u_id = CurrentUser.UserID;
  8844. entity.audit_u_name = CurrentUser.UserName;
  8845. entity.Update();
  8846. returnSuccessMsg("退回成功!");
  8847. return;
  8848. }
  8849. returnErrorMsg("找不到订单记录");
  8850. }
  8851. }
  8852. public void upd_erp_returncashverify()
  8853. {
  8854. if (UrlPostParmsCheck("ID"))
  8855. {
  8856. int eid = GetPostInt("ID");
  8857. CeErpReturnCash entity = null;
  8858. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8859. if (entity != null)
  8860. {
  8861. entity.cashstate = 1;
  8862. entity.verifytime = DateTime.Now;
  8863. entity.verifyuserid = CurrentUser.UserID;
  8864. entity.Update();
  8865. returnSuccessMsg("审核成功!");
  8866. return;
  8867. }
  8868. returnErrorMsg("找不到订单记录");
  8869. }
  8870. }
  8871. public void upd_all_erp_returncashverify()
  8872. {
  8873. if (UrlPostParmsCheck("ID"))
  8874. {
  8875. String[] list = GetPostString("ID").Split(',');
  8876. CeErpReturnCash entity = null;
  8877. for (int i = 0; i < list.Length; i++)
  8878. {
  8879. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8880. if (entity != null)
  8881. {
  8882. if (entity.cashstate == 1)
  8883. {
  8884. returnErrorMsg("已审核过的订单不需要在审核!");
  8885. return;
  8886. }
  8887. entity.cashstate = 1;
  8888. entity.verifytime = DateTime.Now;
  8889. entity.verifyuserid = CurrentUser.UserID;
  8890. entity.Update();
  8891. }
  8892. }
  8893. returnSuccessMsg("审核成功!");
  8894. return;
  8895. }
  8896. }
  8897. public void upd_erp_returncashback()
  8898. {
  8899. if (UrlPostParmsCheck("ID"))
  8900. {
  8901. int eid = GetPostInt("ID");
  8902. CeErpReturnCash entity = null;
  8903. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8904. if (entity != null)
  8905. {
  8906. entity.backreason = GetPostString("reason");
  8907. entity.cashstate = 2;
  8908. entity.verifytime = DateTime.Now;
  8909. entity.verifyuserid = CurrentUser.UserID;
  8910. entity.Update();
  8911. returnSuccessMsg("退回成功!");
  8912. return;
  8913. }
  8914. returnErrorMsg("找不到订单记录");
  8915. }
  8916. }
  8917. public void upd_erp_returnprice()
  8918. {
  8919. if (UrlPostParmsCheck("ID"))
  8920. {
  8921. int eid = GetPostInt("ID");
  8922. CeErpReturnCash entity = null;
  8923. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8924. if (entity != null)
  8925. {
  8926. if (entity.cashstate == 1)
  8927. {
  8928. returnErrorMsg("审核通过了不能改");
  8929. return;
  8930. }
  8931. entity.returnprice = GetPostDouble("returnprice");
  8932. entity.Update();
  8933. returnSuccessMsg("修改成功!");
  8934. return;
  8935. }
  8936. returnErrorMsg("找不到订单记录");
  8937. }
  8938. }
  8939. public void del_erp_returncash()
  8940. {
  8941. if (UrlPostParmsCheck("ID"))
  8942. {
  8943. int eid = GetPostInt("ID");
  8944. CeErpReturnCash.Del(eid);
  8945. returnSuccessMsg("操作成功");
  8946. return;
  8947. }
  8948. }
  8949. public void test_for_do_sql()
  8950. {
  8951. string sql = GetPostString("sqlstr");
  8952. if (sql.Length > 0)
  8953. {
  8954. try
  8955. {
  8956. DbHelper.DbConn.ExecuteNonQuery(sql);
  8957. var res_obj = new
  8958. {
  8959. data = "成功",
  8960. };
  8961. string ro_json = JsonConvert.SerializeObject(res_obj);
  8962. returnSuccess(ro_json);
  8963. }
  8964. catch (Exception ex)
  8965. {
  8966. var res_obj = new
  8967. {
  8968. data = ex.Message,
  8969. };
  8970. string ro_json = JsonConvert.SerializeObject(res_obj);
  8971. returnSuccess(ro_json);
  8972. }
  8973. }
  8974. }
  8975. public void get_user_info()
  8976. {
  8977. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8978. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8979. }
  8980. public void get_total_data()
  8981. {
  8982. int userId = CurrentUser.UserID;
  8983. string sql = "";
  8984. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8985. {
  8986. 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);
  8987. }
  8988. else
  8989. {
  8990. 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 " +
  8991. "(select ID from CE_ErpUser where ID = {0}) d " +
  8992. "left join " +
  8993. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8994. ") a on d.ID = a.id left join " +
  8995. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8996. ") b on a.id = b.id1 left join" +
  8997. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8998. ") c on a.id = c.id2;", userId);
  8999. }
  9000. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9001. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9002. }
  9003. public void get_date_area_total_data2()
  9004. {
  9005. int userId = CurrentUser.UserID;
  9006. string date_type = GetPostString("timetype");
  9007. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9008. string sql = "";
  9009. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9010. {
  9011. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9012. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9013. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9014. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9015. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9016. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9017. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9018. ") a on e.ID = a.id left join " +
  9019. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9020. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9021. ") b on a.id = b.id1 " +
  9022. "left join " +
  9023. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9024. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9025. ") c on a.id = c.id2 " +
  9026. "left join " +
  9027. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9028. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9029. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9030. }
  9031. else
  9032. {
  9033. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9034. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9035. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9036. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9037. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9038. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9039. ") a on e.ID = a.id left join " +
  9040. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9041. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9042. ") c on a.id = c.id2 " +
  9043. "left join " +
  9044. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9045. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9046. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9047. }
  9048. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9049. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9050. }
  9051. public void get_date_area_total_data()
  9052. {
  9053. int userId = CurrentUser.UserID;
  9054. string date_type = GetPostString("timetype");
  9055. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9056. string date1 = searchDT[0].ToString();
  9057. string date2 = searchDT[1].ToString();
  9058. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9059. {
  9060. SqlParameter[] sqlParameter ={
  9061. new SqlParameter("@userId", SqlDbType.Int,4),
  9062. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9063. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9064. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9065. };
  9066. sqlParameter[0].Value = userId;
  9067. sqlParameter[1].Value = date1;
  9068. sqlParameter[2].Value = date2;
  9069. sqlParameter[3].Direction = ParameterDirection.Output;
  9070. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9071. string res = sqlParameter[3].Value.ToString();
  9072. var res_obj = new
  9073. {
  9074. data = res
  9075. };
  9076. string ro_json = JsonConvert.SerializeObject(res_obj);
  9077. returnSuccess(ro_json);
  9078. }
  9079. else
  9080. {
  9081. SqlParameter[] sqlParameter ={
  9082. new SqlParameter("@userId", SqlDbType.Int,4),
  9083. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9084. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9085. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9086. };
  9087. sqlParameter[0].Value = userId;
  9088. sqlParameter[1].Value = date1;
  9089. sqlParameter[2].Value = date2;
  9090. sqlParameter[3].Direction = ParameterDirection.Output;
  9091. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9092. string res = sqlParameter[3].Value.ToString();
  9093. var res_obj = new
  9094. {
  9095. data = res
  9096. };
  9097. string ro_json = JsonConvert.SerializeObject(res_obj);
  9098. returnSuccess(ro_json);
  9099. }
  9100. //writeGridDataViewJson(dt.Rows.Count, dv);
  9101. }
  9102. public void get_order_list()
  9103. {
  9104. string strFields = GetPostString("paraFields");
  9105. string strOrder = GetPostString("paraOrder");
  9106. string strWhere = GetPostString("paraWhere");
  9107. string strPageSize = GetPostString("paraPageSize");
  9108. DataStruct dStruct = GetPostStruct();
  9109. dStruct.PageSize = int.Parse(strPageSize);
  9110. dStruct.Fileds = strFields;
  9111. dStruct.Order = strOrder;
  9112. dStruct.MainWhere = strWhere;
  9113. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9114. writeGridDataTableJson(dStruct.TotalCount, dt);
  9115. }
  9116. ////获取待开始订单列表
  9117. //public void get_wait_design_order_list()
  9118. //{
  9119. // string date_type = GetPostString("date_type");
  9120. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9121. // DataStruct dStruct = GetPostStruct();
  9122. // dStruct.PageSize = 1000;
  9123. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9124. // List<string> lw = new List<string>();
  9125. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9126. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9127. // dStruct.Order = "WaitDesignTime asc";
  9128. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9129. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9130. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9131. //}
  9132. //获取完成单量排名
  9133. public void get_finish_order_count_ranking()
  9134. {
  9135. /* string date_type = GetPostString("date_type");
  9136. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9137. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9138. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9139. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9140. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9141. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9142. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9143. writeGridDataTableJson(0, new DataTable());
  9144. }
  9145. public void get_finish_order_amount_ranking()
  9146. {
  9147. /*string date_type = GetPostString("date_type");
  9148. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9149. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9150. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9151. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9152. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9153. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9154. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9155. writeGridDataTableJson(0, new DataTable());
  9156. }
  9157. public void get_finish_refund_count_ranking()
  9158. {
  9159. string date_type = GetPostString("date_type");
  9160. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9161. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9162. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9163. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9164. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9165. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9166. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9167. writeGridDataTableJson(dt.Rows.Count, dt);
  9168. }
  9169. public void get_finish_refund_amount_ranking()
  9170. {
  9171. string date_type = GetPostString("date_type");
  9172. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9173. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9174. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9175. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9176. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9177. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9178. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9179. writeGridDataTableJson(dt.Rows.Count, dt);
  9180. }
  9181. public void set_erp_finishorder_director()
  9182. {
  9183. if (UrlPostParmsCheck("ctid"))
  9184. {
  9185. string eid = GetPostString("ctid");
  9186. CeErpTradeCell entity = null;
  9187. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9188. if (entity != null)
  9189. {
  9190. entity.OrderState = 8;
  9191. entity.Update();
  9192. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9193. returnSuccessMsg("操作成功!");
  9194. return;
  9195. }
  9196. returnErrorMsg("找不到记录");
  9197. }
  9198. }
  9199. public void get_erp_placeregistlist()
  9200. {
  9201. DataStruct dStruct = GetPostStruct();
  9202. List<string> lw = new List<string>();
  9203. string outsid = GetPostString("outsid");
  9204. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9205. string memo = GetPostString("memo");
  9206. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9207. string filename = GetPostString("filename");
  9208. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9209. string islate = GetPostString("islate");
  9210. if (islate.Length > 0)
  9211. {
  9212. if (islate == "1")
  9213. lw.Add(string.Format("OutLate>0"));
  9214. else
  9215. lw.Add(string.Format("OutLate=0"));
  9216. }
  9217. string placedate1 = GetPostString("placedate1");
  9218. string placedate2 = GetPostString("placedate2");
  9219. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9220. if (dw.Length > 0) lw.Add(dw);
  9221. string deliveryDate1 = GetPostString("deliverydate1");
  9222. string deliveryDate2 = GetPostString("deliverydate2");
  9223. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9224. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9225. dStruct.Order = "ID desc";
  9226. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9227. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9228. writeGridDataTableJson(dStruct.TotalCount, dt);
  9229. }
  9230. public void ins_erp_placeregist()
  9231. {
  9232. if (UrlPostParmsCheck("id"))
  9233. {
  9234. string eid = GetPostString("id");
  9235. CeErpPlaceRegister entity = null;
  9236. if (eid == "0")//新增
  9237. {
  9238. entity = new CeErpPlaceRegister();
  9239. string xdTime = GetPostString("placeTime");
  9240. if (xdTime.Length > 0)
  9241. {
  9242. entity.PlactTime = Convert.ToDateTime(xdTime);
  9243. }
  9244. string fhTime = GetPostString("deliveryTime");
  9245. if (fhTime.Length > 0)
  9246. {
  9247. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9248. }
  9249. string preTime = GetPostString("preOutTime");
  9250. if (preTime.Length > 0)
  9251. {
  9252. entity.PreOutTime = Convert.ToDateTime(preTime);
  9253. }
  9254. entity.DeliveryCount = GetPostInt("deliveryCount");
  9255. entity.ReceiveCount = GetPostInt("receiveCount");
  9256. entity.OutSid = GetPostString("outSid");
  9257. entity.FileName = GetPostString("fileName");
  9258. entity.Memo = GetPostString("memo");
  9259. entity.AddUserId = CurrentUser.UserID;
  9260. entity.CreateTime = DateTime.Now;
  9261. entity.Img = GetPostString("img");
  9262. entity.Supplier = GetPostInt("supplier");
  9263. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9264. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9265. {
  9266. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9267. DateTime dt2 = (DateTime)entity.PreOutTime;
  9268. TimeSpan span = dt1.Subtract(dt2);
  9269. if (span.Days > 0)
  9270. {
  9271. entity.OutLate = span.Days;
  9272. }
  9273. }
  9274. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9275. entity.Create();
  9276. returnSuccessMsg("添加成功!");
  9277. return;
  9278. }
  9279. else //修改
  9280. {
  9281. entity = CeErpPlaceRegister.Get(eid);
  9282. if (entity != null)
  9283. {
  9284. string xdTime = GetPostString("placeTime");
  9285. if (xdTime.Length > 0)
  9286. {
  9287. entity.PlactTime = Convert.ToDateTime(xdTime);
  9288. }
  9289. string fhTime = GetPostString("deliveryTime");
  9290. if (fhTime.Length > 0)
  9291. {
  9292. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9293. }
  9294. string preTime = GetPostString("preOutTime");
  9295. if (preTime.Length > 0)
  9296. {
  9297. entity.PreOutTime = Convert.ToDateTime(preTime);
  9298. }
  9299. entity.DeliveryCount = GetPostInt("deliveryCount");
  9300. entity.ReceiveCount = GetPostInt("receiveCount");
  9301. if (entity.DeliveryCount == entity.ReceiveCount)
  9302. {
  9303. entity.CurState = "已完成";
  9304. }
  9305. else
  9306. {
  9307. entity.CurState = "未完成";
  9308. }
  9309. entity.OutSid = GetPostString("outSid");
  9310. entity.FileName = GetPostString("fileName");
  9311. entity.Memo = GetPostString("memo");
  9312. entity.Img = GetPostString("img");
  9313. entity.Supplier = GetPostInt("supplier");
  9314. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9315. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9316. {
  9317. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9318. DateTime dt2 = (DateTime)entity.PreOutTime;
  9319. TimeSpan span = dt1.Subtract(dt2);
  9320. if (span.Days > 0)
  9321. {
  9322. entity.OutLate = span.Days;
  9323. }
  9324. }
  9325. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9326. entity.Update();
  9327. returnSuccessMsg("修改成功");
  9328. return;
  9329. }
  9330. returnErrorMsg("找不到对应的记录");
  9331. return;
  9332. }
  9333. }
  9334. returnErrorMsg("缺少必要参数");
  9335. }
  9336. public void del_erp_placeregist()
  9337. {
  9338. string eid = GetPostString("id");
  9339. CeErpPlaceRegister.Del(eid);
  9340. returnSuccessMsg("删除成功!");
  9341. return;
  9342. }
  9343. public void ins_erp_placeregistbyorder()
  9344. {
  9345. string ctid = GetPostString("ctid");
  9346. if (ctid.Length > 0)
  9347. {
  9348. StringBuilder sql = new StringBuilder();
  9349. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9350. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9351. if (dt.Rows.Count > 0)
  9352. {
  9353. foreach (DataRow dr in dt.Rows)
  9354. {
  9355. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9356. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9357. entity.AddUserId = CurrentUser.UserID;
  9358. entity.tid = dr["tid"].ToString();
  9359. entity.Did = Convert.ToString(dr["ctid"]);
  9360. entity.splitTag = dr["SplitTag"].ToString();
  9361. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9362. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9363. if (pre_ctid.Length > 0)
  9364. {
  9365. sellmemo = sellmemo.Replace(pre_ctid, "");
  9366. }
  9367. sellmemo = sellmemo.Replace("[", "");
  9368. sellmemo = sellmemo.Replace("]", "");
  9369. entity.FileName = sellmemo;
  9370. string count = dr["ProductCount"].ToString();
  9371. int usecount = commonHelper.getIntCountFromString(count);
  9372. entity.DeliveryCount = usecount;
  9373. entity.CurState = "未完成";
  9374. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9375. {
  9376. entity.Supplier = 24;//dl手提袋定制
  9377. }
  9378. else
  9379. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9380. entity.CreateTime = DateTime.Now;
  9381. entity.Create();
  9382. }
  9383. returnSuccessMsg("操作成功");
  9384. return;
  9385. }
  9386. returnErrorMsg("没有找到对应订单");
  9387. return;
  9388. }
  9389. returnErrorMsg("缺少订单编号");
  9390. return;
  9391. }
  9392. public void get_erp_persuadelist()
  9393. {
  9394. DataStruct dStruct = GetPostStruct();
  9395. List<string> lw = new List<string>();
  9396. string ctid = GetPostString("ctid");
  9397. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9398. string shopname = GetPostString("shopname");
  9399. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9400. string buyernick = GetPostString("buyer_nick");
  9401. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9402. string customer = GetPostString("customer");
  9403. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9404. string returndate1 = GetPostString("returndate1");
  9405. string returndate2 = GetPostString("returndate2");
  9406. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9407. if (dw.Length > 0) lw.Add(dw);
  9408. string finishDate1 = GetPostString("finishdate1");
  9409. string finishDate2 = GetPostString("finishdate2");
  9410. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9411. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9412. string persuadetype = GetPostString("persuadetype");
  9413. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9414. string returnvstate = GetPostString("returnvstate");
  9415. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9416. dStruct.Order = "created desc";
  9417. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9418. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9419. writeGridDataTableJson(dStruct.TotalCount, dt);
  9420. }
  9421. public void upd_erp_returnpersuadeback()
  9422. {
  9423. if (UrlPostParmsCheck("ID"))
  9424. {
  9425. int eid = GetPostInt("ID");
  9426. CeErpPersuade entity = null;
  9427. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9428. if (entity != null)
  9429. {
  9430. entity.backreason = GetPostString("reason");
  9431. entity.pstate = 2;
  9432. entity.verifytime = DateTime.Now;
  9433. entity.verifyuserid = CurrentUser.UserID;
  9434. entity.Update();
  9435. returnSuccessMsg("退回成功!");
  9436. return;
  9437. }
  9438. returnErrorMsg("找不到订单记录");
  9439. }
  9440. }
  9441. public void upd_erp_returnpersuadeverify()
  9442. {
  9443. if (UrlPostParmsCheck("ID"))
  9444. {
  9445. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9446. {
  9447. returnErrorMsg("暂无权限审核");
  9448. return;
  9449. }
  9450. int eid = GetPostInt("ID");
  9451. CeErpPersuade entity = null;
  9452. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9453. if (entity != null)
  9454. {
  9455. entity.pstate = 1;
  9456. entity.verifytime = DateTime.Now;
  9457. entity.verifyuserid = CurrentUser.UserID;
  9458. entity.Update();
  9459. returnSuccessMsg("审核成功!");
  9460. return;
  9461. }
  9462. returnErrorMsg("找不到订单记录");
  9463. }
  9464. }
  9465. public void del_erp_persuade()
  9466. {
  9467. if (UrlPostParmsCheck("ID"))
  9468. {
  9469. int eid = GetPostInt("ID");
  9470. CeErpPersuade.Del(eid);
  9471. returnSuccessMsg("操作成功");
  9472. return;
  9473. }
  9474. }
  9475. public void get_erp_oldcustoupload()
  9476. {
  9477. DataStruct dStruct = GetPostStruct();
  9478. List<string> lw = new List<string>();
  9479. string buyernick = GetPostString("buyer_nick");
  9480. if (buyernick.Length > 0)
  9481. {
  9482. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9483. }
  9484. else
  9485. return;
  9486. dStruct.Order = "pay_time desc";
  9487. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9488. DataTable dt = null;
  9489. dt = WebCache.GetData("view_erptradecell", dStruct);
  9490. writeGridDataTableJson(dStruct.TotalCount, dt);
  9491. }
  9492. public void get_erp_checkorderlist()
  9493. {
  9494. DataStruct dStruct = GetPostStruct();
  9495. List<string> lw = new List<string>();
  9496. string tid = GetPostString("ctid");
  9497. if (tid.Length > 0)
  9498. {
  9499. string select_tid = getTidByCtid(tid);
  9500. lw.Add(string.Format("tid='{0}'", select_tid));
  9501. }
  9502. string shopname = GetPostString("shopname");
  9503. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9504. string buyernick = GetPostString("buyer_nick");
  9505. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9506. string customer = GetPostString("customer");
  9507. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9508. string design = GetPostString("design");
  9509. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9510. string orderState = GetPostString("orderState");
  9511. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9512. string address = GetPostString("address");
  9513. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9514. string sellermemo = GetPostString("seller_memo");
  9515. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9516. string supplier = GetPostString("supplier");
  9517. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9518. {
  9519. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9520. }
  9521. else
  9522. {
  9523. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9524. }
  9525. string date1 = GetPostString("date1");
  9526. string date2 = GetPostString("date2");
  9527. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9528. if (dw.Length > 0) lw.Add(dw);
  9529. string placedate1 = GetPostString("placedate1");
  9530. string placedate2 = GetPostString("placedate2");
  9531. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9532. if (fdw.Length > 0) lw.Add(fdw);
  9533. string price1 = GetPostString("price1");
  9534. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9535. string price2 = GetPostString("price2");
  9536. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9537. string checkst = GetPostString("checkstate");
  9538. if (checkst.Length > 0 && "10".Equals(checkst))
  9539. {
  9540. lw.Add(string.Format("CheckOut>0"));
  9541. }
  9542. else
  9543. {
  9544. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9545. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9546. }
  9547. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9548. {
  9549. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9550. }
  9551. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9552. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9553. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9554. writeGridDataTableJson(dStruct.TotalCount, dt);
  9555. }
  9556. public void ins_erp_startCheck()
  9557. {
  9558. if (UrlPostParmsCheck("ctid"))
  9559. {
  9560. string eid = GetPostString("ctid");
  9561. CeErpTradeCell entity = null;
  9562. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9563. if (entity != null)
  9564. {
  9565. entity.MemoOpt = 4;
  9566. entity.UpdateTime = DateTime.Now;
  9567. entity.Update();
  9568. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9569. CeErpSukuraData.createInfo(entity.ctid, 6);
  9570. returnSuccessMsg("操作成功!");
  9571. return;
  9572. }
  9573. returnErrorMsg("找不到记录");
  9574. }
  9575. }
  9576. public void upd_erp_sendXlw()
  9577. {
  9578. if (UrlPostParmsCheck("ctid"))
  9579. {
  9580. string eid = GetPostString("ctid");
  9581. CeErpTradeCell entity = null;
  9582. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9583. if (entity != null)
  9584. {
  9585. if (entity.IsSendGift == 1)
  9586. {
  9587. returnErrorMsg("请勿重复标记");
  9588. return;
  9589. }
  9590. entity.IsSendGift = 1;
  9591. entity.Update();
  9592. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9593. returnSuccessMsg("操作成功!");
  9594. return;
  9595. }
  9596. returnErrorMsg("找不到记录");
  9597. }
  9598. }
  9599. public void cancel_sendXlw()
  9600. {
  9601. if (UrlPostParmsCheck("ctid"))
  9602. {
  9603. string eid = GetPostString("ctid");
  9604. CeErpTradeCell entity = null;
  9605. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9606. if (entity != null)
  9607. {
  9608. if (entity.IsSendGift == 0)
  9609. {
  9610. returnErrorMsg("未标记小礼物");
  9611. return;
  9612. }
  9613. entity.IsSendGift = 0;
  9614. entity.Update();
  9615. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9616. returnSuccessMsg("操作成功!");
  9617. return;
  9618. }
  9619. returnErrorMsg("找不到记录");
  9620. }
  9621. }
  9622. public void get_erp_designbill()
  9623. {
  9624. DataStruct dStruct = GetPostStruct();
  9625. List<string> lw = new List<string>();
  9626. int isMy = GetInt("my");
  9627. if (isMy == 1)
  9628. {
  9629. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9630. }
  9631. string tid = GetPostString("tid");
  9632. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9633. string userName = GetPostString("design");
  9634. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9635. string price1 = GetPostString("price1");
  9636. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9637. string price2 = GetPostString("price2");
  9638. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9639. string rePrice1 = GetPostString("rePrice1");
  9640. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9641. string rePrice2 = GetPostString("rePrice2");
  9642. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9643. string designerType = GetPostString("designerType");
  9644. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9645. string orderState = GetPostString("orderState");
  9646. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9647. string endTime1 = GetPostString("endTime1");
  9648. string endTime2 = GetPostString("endTime2");
  9649. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9650. if (dw.Length > 0) lw.Add(dw);
  9651. string isDk = GetPostString("isDk");
  9652. if (isDk == "1")
  9653. {
  9654. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9655. }
  9656. else if (isDk == "0")
  9657. {
  9658. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9659. }
  9660. dStruct.Order = "oid, create_time desc";
  9661. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9662. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9663. writeGridDataTableJson(dStruct.TotalCount, dt);
  9664. }
  9665. public void upd_erp_designerbill()
  9666. {
  9667. if (UrlPostParmsCheck("ID"))
  9668. {
  9669. string eid = GetPostString("ID");
  9670. CeErpDesignerBill entity = null;
  9671. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9672. if (entity != null)
  9673. {
  9674. if (GetPostDouble("designerpirce") > 0)
  9675. {
  9676. entity.realPrice = GetPostDouble("designerpirce");
  9677. entity.update_time = DateTime.Now;
  9678. entity.update_u_id = CurrentUser.UserID;
  9679. entity.update_u_name = CurrentUser.UserName;
  9680. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9681. entity.Update();
  9682. returnSuccessMsg("操作成功!");
  9683. return;
  9684. }
  9685. else
  9686. {
  9687. entity.price = GetPostDouble("price");
  9688. entity.update_time = DateTime.Now;
  9689. entity.update_u_id = CurrentUser.UserID;
  9690. entity.update_u_name = CurrentUser.UserName;
  9691. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9692. entity.Update();
  9693. returnSuccessMsg("操作成功!");
  9694. return;
  9695. }
  9696. }
  9697. returnErrorMsg("找不到记录");
  9698. }
  9699. }
  9700. public void audit_erp_designerbill()
  9701. {
  9702. if (UrlPostParmsCheck("ID"))
  9703. {
  9704. string eid = GetPostString("ID");
  9705. CeErpDesignerBill entity = null;
  9706. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9707. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9708. if (entity != null)
  9709. {
  9710. entity.realPrice = GetPostDouble("designerpirce");
  9711. entity.update_time = DateTime.Now;
  9712. entity.update_u_id = CurrentUser.UserID;
  9713. entity.update_u_name = CurrentUser.UserName;
  9714. entity.isAudit = 1;
  9715. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9716. entity.Update();
  9717. if (orderEntity != null)
  9718. {
  9719. orderEntity.IsReadTag = 3;
  9720. orderEntity.Update();
  9721. }
  9722. returnSuccessMsg("操作成功!");
  9723. return;
  9724. }
  9725. returnErrorMsg("找不到记录");
  9726. }
  9727. }
  9728. public void all_audit_erp_designerbill()
  9729. {
  9730. if (UrlPostParmsCheck("idList"))
  9731. {
  9732. string[] list = GetPostString("idList").Split(',');
  9733. CeErpDesignerBill entity = null;
  9734. for (int i = 0; i < list.Length; i++)
  9735. {
  9736. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9737. if (entity == null) return;
  9738. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9739. if (orderEntity == null) return;
  9740. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9741. entity.update_time = DateTime.Now;
  9742. entity.update_u_id = CurrentUser.UserID;
  9743. entity.update_u_name = CurrentUser.UserName;
  9744. entity.isAudit = 1;
  9745. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9746. entity.Update();
  9747. orderEntity.IsReadTag = 3;
  9748. orderEntity.Update();
  9749. }
  9750. returnSuccessMsg("操作成功!");
  9751. return;
  9752. }
  9753. }
  9754. public void get_erp_sameorders()
  9755. {
  9756. if (UrlPostParmsCheck("ctid"))
  9757. {
  9758. string eid = GetPostString("ctid");
  9759. CeErpTradeCell entity = null;
  9760. entity = CeErpTradeCell.GetByCtid(eid);
  9761. if (entity != null)
  9762. {
  9763. StringBuilder sql = new StringBuilder();
  9764. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9765. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9766. var res = new
  9767. {
  9768. data = dt.Rows.Count
  9769. };
  9770. string ro_jsond = JsonConvert.SerializeObject(res);
  9771. returnSuccess(ro_jsond);
  9772. return;
  9773. }
  9774. returnErrorMsg("未找到订单");
  9775. return;
  9776. }
  9777. returnErrorMsg("缺少必要的参数");
  9778. }
  9779. public void get_erp_islasthavesameorder()
  9780. {
  9781. if (UrlPostParmsCheck("ctid"))
  9782. {
  9783. string eid = GetPostString("ctid");
  9784. string[] ctidList = eid.Split(',');
  9785. StringBuilder sql = new StringBuilder();
  9786. string tisCtid = "";
  9787. foreach (string ctid in ctidList)
  9788. {
  9789. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9790. if (entity != null)
  9791. {
  9792. sql = new StringBuilder();
  9793. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9794. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9795. if (dth.Rows.Count > 0)
  9796. {
  9797. tisCtid += entity.ctid;
  9798. tisCtid += ",";
  9799. }
  9800. }
  9801. }
  9802. if (tisCtid.Length > 0)
  9803. {
  9804. var res = new
  9805. {
  9806. data = tisCtid
  9807. };
  9808. string ro_jsond = JsonConvert.SerializeObject(res);
  9809. returnSuccess(ro_jsond);
  9810. }
  9811. else
  9812. {
  9813. var res = new
  9814. {
  9815. data = ""
  9816. };
  9817. string ro_jsond = JsonConvert.SerializeObject(res);
  9818. returnSuccess(ro_jsond);
  9819. }
  9820. return;
  9821. }
  9822. returnErrorMsg("缺少必要的参数");
  9823. }
  9824. public void file_client_down_url()
  9825. {
  9826. if (!UrlPostParmsCheck("userId"))
  9827. {
  9828. returnErrorMsg("缺少必要的参数");
  9829. }
  9830. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9831. }
  9832. public void checkout_form_data()
  9833. {
  9834. if (!UrlPostParmsCheck("tid"))
  9835. {
  9836. returnErrorMsg("缺少必要的参数");
  9837. }
  9838. string tid = GetPostString("tid");
  9839. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9840. if (ceErpOrderFormData != null)
  9841. {
  9842. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9843. returnSuccess(ro_jsond);
  9844. return;
  9845. }
  9846. returnErrorMsg("尚未有文件!");
  9847. }
  9848. public void back_supplier_audit()
  9849. {
  9850. int userId = CurrentUser.UserID;
  9851. StringBuilder sql = new StringBuilder();
  9852. 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);
  9853. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9854. if (dt.Rows.Count > 0)
  9855. {
  9856. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9857. }
  9858. else
  9859. {
  9860. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9861. }
  9862. }
  9863. public void back_supplier_query()
  9864. {
  9865. string eid = GetPostString("ctid");
  9866. if (eid != "")
  9867. {
  9868. StringBuilder sql = new StringBuilder();
  9869. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9870. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9871. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9872. }
  9873. else
  9874. {
  9875. returnErrorMsg("找不到订单记录");
  9876. return;
  9877. }
  9878. }
  9879. public void verified_to_order()
  9880. {
  9881. int userId = CurrentUser.UserID;
  9882. StringBuilder sql = new StringBuilder();
  9883. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9884. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9885. if (dt.Rows.Count > 0)
  9886. {
  9887. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9888. }
  9889. else
  9890. {
  9891. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9892. }
  9893. }
  9894. public void upd_supplier_audit()
  9895. {
  9896. if (UrlPostParmsCheck("ctid"))
  9897. {
  9898. string eid = GetPostString("ctid");
  9899. string reason = GetPostString("returnreason");
  9900. CeErpTradeCell entity = null;
  9901. CeWithdraw withdraw = null;
  9902. withdraw = CeWithdraw.GetByTid(eid);
  9903. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9904. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9905. {
  9906. if (withdraw != null)
  9907. {
  9908. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9909. {
  9910. returnSuccessMsg("您没有权限操作!");
  9911. return;
  9912. }
  9913. else
  9914. {
  9915. if (reason.Equals("1"))
  9916. {
  9917. if (entity.OrderState == -1)
  9918. {
  9919. if (entity.FinishPlaceTime == null)
  9920. {
  9921. entity.OrderState = 2;
  9922. }
  9923. else
  9924. {
  9925. entity.OrderState = 6;
  9926. }
  9927. }
  9928. entity.Update();
  9929. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9930. if (withdraw != null)
  9931. {
  9932. withdraw.status = int.Parse(reason);
  9933. withdraw.Update();
  9934. }
  9935. returnSuccessMsg("操作成功!");
  9936. return;
  9937. }
  9938. else
  9939. {
  9940. withdraw.status = int.Parse(reason);
  9941. withdraw.acknowledgingtime = DateTime.Now;
  9942. withdraw.Update();
  9943. returnSuccessMsg("查看详细请点击线下订单查询");
  9944. return;
  9945. }
  9946. }
  9947. }
  9948. // 第一个字符是 'N'
  9949. }
  9950. if (eid[0] != 'N')
  9951. {
  9952. }
  9953. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9954. {
  9955. entity.IsVerifyToSupplier = false;
  9956. entity.IsReturn = 1;
  9957. entity.ReturnTime = DateTime.Now;
  9958. entity.ReturnReason = reason;
  9959. if (entity.OrderState == 6)
  9960. {
  9961. entity.OrderState = 5;
  9962. }
  9963. entity.Update();
  9964. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9965. if (withdraw != null)
  9966. {
  9967. withdraw.status = int.Parse(reason);
  9968. withdraw.Update();
  9969. }
  9970. returnSuccessMsg("操作成功!");
  9971. return;
  9972. }
  9973. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9974. {
  9975. ;
  9976. if (withdraw != null)
  9977. {
  9978. withdraw.status = int.Parse(reason);
  9979. withdraw.acknowledgingtime = DateTime.Now;
  9980. withdraw.Update();
  9981. returnSuccessMsg("供应商取消撤回!");
  9982. return;
  9983. }
  9984. }
  9985. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9986. {
  9987. if (entity.OrderState == -1)
  9988. {
  9989. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  9990. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9991. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  9992. {
  9993. returnErrorMsg("台湾客户需填写身份证!");
  9994. return;
  9995. }
  9996. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9997. {
  9998. returnErrorMsg("订单spu没有确认无法通过审核!");
  9999. return;
  10000. }
  10001. if (entity.FinishPlaceTime == null)
  10002. {
  10003. entity.OrderState = 2;
  10004. }
  10005. else
  10006. {
  10007. entity.OrderState = 3;
  10008. }
  10009. commonHelper.getCytPrice(entity);
  10010. }
  10011. entity.Update();
  10012. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10013. if (withdraw != null)
  10014. {
  10015. withdraw.status = int.Parse(reason);
  10016. withdraw.Update();
  10017. }
  10018. returnSuccessMsg("操作成功!");
  10019. return;
  10020. }
  10021. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10022. {
  10023. if (withdraw == null)
  10024. {
  10025. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10026. return;
  10027. }
  10028. }
  10029. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10030. {
  10031. if (withdraw != null)
  10032. {
  10033. withdraw.status = int.Parse(reason);
  10034. withdraw.acknowledgingtime = DateTime.Now;
  10035. withdraw.Update();
  10036. returnSuccessMsg("查看详细请点击线下订单查询");
  10037. return;
  10038. }
  10039. }
  10040. return;
  10041. }
  10042. }
  10043. //校验报价
  10044. public void refund_order_tip()
  10045. {
  10046. int userid = CurrentUser.UserID;
  10047. int sectionId = CurrentUser.UserPost.OrgID;
  10048. StringBuilder sql = new StringBuilder();
  10049. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10050. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10051. List<string> ids = new List<string>();
  10052. if (dth.Rows.Count > 0)
  10053. {
  10054. foreach (DataRow dr in dth.Rows)
  10055. {
  10056. ids.Add(dr["ID"].ToString());
  10057. }
  10058. try
  10059. {
  10060. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10061. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10062. }
  10063. catch (Exception ex)
  10064. {
  10065. }
  10066. }
  10067. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10068. }
  10069. public void refund_order_Design()
  10070. {
  10071. int userid = CurrentUser.UserID;
  10072. int sectionId = CurrentUser.UserPost.OrgID;
  10073. StringBuilder sql = new StringBuilder();
  10074. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10075. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10076. List<string> ids = new List<string>();
  10077. if (dth.Rows.Count > 0)
  10078. {
  10079. foreach (DataRow dr in dth.Rows)
  10080. {
  10081. ids.Add(dr["ID"].ToString());
  10082. }
  10083. try
  10084. {
  10085. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10086. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10087. }
  10088. catch (Exception ex)
  10089. {
  10090. }
  10091. }
  10092. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10093. }
  10094. public void change_order_info()
  10095. {
  10096. int userid = CurrentUser.UserID;
  10097. StringBuilder sql = new StringBuilder();
  10098. 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);
  10099. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10100. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10101. }
  10102. public void change_win_mome()
  10103. {
  10104. if (UrlPostParmsCheck("id,ctid"))
  10105. {
  10106. string id = GetPostString("id");
  10107. string ctid = GetPostString("ctid");
  10108. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10109. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10110. if (ce == null || ceErpMessageTip == null)
  10111. {
  10112. returnSuccessMsg("未找到对应的订单!");
  10113. return;
  10114. }
  10115. if (ce.OrderState >= 5)
  10116. {
  10117. ceErpMessageTip.isVisit = true;
  10118. ceErpMessageTip.Update();
  10119. returnSuccessMsg("已上传文件无法修改!");
  10120. return;
  10121. }
  10122. int type = GetPostInt("type");
  10123. string content = GetPostString("content");
  10124. if (type == 0)
  10125. {
  10126. content = content.Replace("(", "(");
  10127. content = content.Replace(")", ")");
  10128. string check = MidStrEx(content, "(", ")").Trim();
  10129. if (string.IsNullOrEmpty(check))
  10130. {
  10131. returnSuccessMsg("文件名格式不正确");
  10132. return;
  10133. }
  10134. }
  10135. ce.seller_memo = content;
  10136. ce.Update();
  10137. ceErpMessageTip.isVisit = true;
  10138. ceErpMessageTip.Update();
  10139. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10140. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10141. ApiVo apiVo = new ApiVo();
  10142. apiVo.orderNumber = ce.ctid;
  10143. apiVo.actionName = "demandDesign";
  10144. apiVo.orderRemarks = content;
  10145. apiVo.demandExamine = type + 1;
  10146. designHelper.API_WorkCore(apiVo);//demandDesign
  10147. returnSuccessMsg("修改成功!");
  10148. }
  10149. }
  10150. public static string MidStrEx(string sourse, string startstr, string endstr)
  10151. {
  10152. string result = string.Empty;
  10153. int startindex, endindex;
  10154. try
  10155. {
  10156. startindex = sourse.IndexOf(startstr);
  10157. if (startindex == -1)
  10158. return result;
  10159. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10160. endindex = tmpstr.IndexOf(endstr);
  10161. if (endindex == -1)
  10162. return result;
  10163. result = tmpstr.Remove(endindex);
  10164. }
  10165. catch (Exception ex)
  10166. {
  10167. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10168. }
  10169. return result;
  10170. }
  10171. public void refund_order_list()
  10172. {
  10173. int userid = CurrentUser.UserID;
  10174. int sectionId = CurrentUser.UserPost.OrgID;
  10175. StringBuilder sql = new StringBuilder();
  10176. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10177. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10178. DataStruct dStruct = GetPostStruct();
  10179. DataTable dt = null;
  10180. List<string> ids = new List<string>();
  10181. List<string> tids = new List<string>();
  10182. if (dth.Rows.Count > 0)
  10183. {
  10184. foreach (DataRow dr in dth.Rows)
  10185. {
  10186. tids.Add("'" + dr["tid"].ToString() + "'");
  10187. ids.Add(dr["id"].ToString());
  10188. }
  10189. try
  10190. {
  10191. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10192. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10193. List<string> lw = new List<string>();
  10194. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10195. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10196. dt = WebCache.GetData("view_orderlist", dStruct);
  10197. }
  10198. catch (Exception ex)
  10199. {
  10200. }
  10201. }
  10202. writeGridDataTableJson(dStruct.TotalCount, dt);
  10203. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10204. }
  10205. //新增
  10206. public void order_batch_downloads()
  10207. {
  10208. string ceid = GetPostString("tid");
  10209. String[] tid = ceid.Split(',');
  10210. order_batch_caiyingtong(tid);
  10211. /* (string success, string errors) = UploadFiles(tid);
  10212. returnSuccessMsg(success + errors);*/
  10213. return;
  10214. }
  10215. //报价接口
  10216. public void Get_To_Quote()
  10217. {
  10218. string ceid = GetPostString("ctid");
  10219. if (ceid != null)
  10220. {
  10221. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10222. if (entity != null)
  10223. {
  10224. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10225. {
  10226. return;
  10227. }
  10228. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10229. double price = 0;
  10230. if (cp == null)
  10231. {
  10232. JObject jsonObject12 = new JObject
  10233. {
  10234. { "UserId", "77886" },
  10235. { "Pwd", "lt666888" },
  10236. { "Filename", entity.seller_memo }
  10237. };
  10238. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10239. JObject jsonObjects1 = JObject.Parse(response1);
  10240. string ms1g = (string)jsonObjects1["msg"];
  10241. if (ms1g == "报价成功")
  10242. {
  10243. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10244. string data = (string)jsonObject1["price"];
  10245. 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 + "');";
  10246. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10247. returnSuccessMsg("获取报价成功:" + data);
  10248. price = Convert.ToDouble(data);
  10249. }
  10250. else
  10251. {
  10252. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10253. return;
  10254. }
  10255. }
  10256. String[] beizhu = entity.seller_memo.Split('-');
  10257. String chanp = "";
  10258. if (beizhu.Length > 0)
  10259. {
  10260. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10261. }
  10262. else
  10263. {
  10264. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10265. }
  10266. JObject jsonObject = new JObject
  10267. {
  10268. { "UserId", "77886" },
  10269. { "Pwd", "lt666888" },
  10270. { "Filename", chanp }
  10271. };
  10272. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10273. JObject jsonObjects = JObject.Parse(response);
  10274. string msg = (string)jsonObjects["msg"];
  10275. if (msg == "报价成功")
  10276. {
  10277. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10278. string data = (string)jsonObject1["price"];
  10279. 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 + "');";
  10280. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10281. returnSuccessMsg("获取报价成功:" + data);
  10282. price = Convert.ToDouble(data);
  10283. }
  10284. else
  10285. {
  10286. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10287. return;
  10288. }
  10289. if (price > 0)
  10290. {
  10291. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10292. if (ceErpTradeCellExtend == null)
  10293. {
  10294. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10295. ceErpTradeCellExtend.ctid = entity.ctid;
  10296. ceErpTradeCellExtend.payment_cyt = price;
  10297. ceErpTradeCellExtend.Create();
  10298. }
  10299. else
  10300. {
  10301. ceErpTradeCellExtend.payment_cyt = price;
  10302. ceErpTradeCellExtend.Update();
  10303. }
  10304. }
  10305. return;
  10306. }
  10307. }
  10308. else
  10309. {
  10310. returnErrorMsg("请至少选择一条数据");
  10311. return;
  10312. }
  10313. }
  10314. //新增
  10315. public void order_To_Supplier()
  10316. {
  10317. string ceid = GetPostString("tid");
  10318. String[] tid = ceid.Split(',');
  10319. if (tid.Length > 0)
  10320. {
  10321. try
  10322. {
  10323. for (int i = 0; i < tid.Length; i++)
  10324. {
  10325. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10326. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10327. entity.SupplierId = suid;
  10328. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10329. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10330. entity.Update();
  10331. }
  10332. }
  10333. catch (Exception ex)
  10334. {
  10335. returnErrorMsg("自动匹配供应商失败");
  10336. return;
  10337. }
  10338. }
  10339. else
  10340. {
  10341. returnErrorMsg("请至少选择一条数据");
  10342. return;
  10343. }
  10344. returnSuccessMsg("自动匹配供应商成功");
  10345. return;
  10346. }
  10347. public (string, string) UploadFiles(string[] urls)
  10348. {
  10349. string success = "";
  10350. string errors = "";
  10351. int userid = CurrentUser.UserID;
  10352. foreach (string url in urls)
  10353. {
  10354. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10355. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10356. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10357. {
  10358. JObject jsonObject = new JObject
  10359. {
  10360. { "Userid", "77886" },
  10361. { "pwd", "cyt86435015" },
  10362. { "content", base64FileContent },
  10363. { "ext", Path.GetExtension(fileName) }
  10364. };
  10365. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10366. JObject jsonObjects = JObject.Parse(response);
  10367. string msg = (string)jsonObjects["msg"];
  10368. if (msg.Equals("上传成功"))
  10369. {
  10370. success += url + " 上传成功";
  10371. }
  10372. else
  10373. {
  10374. errors += url + " 上传失败";
  10375. }
  10376. }
  10377. else
  10378. {
  10379. errors += url + " 格式出现问题";
  10380. }
  10381. }
  10382. if (urls.Length == 0)
  10383. {
  10384. return (success, errors);
  10385. }
  10386. return (success, errors);
  10387. }
  10388. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10389. {
  10390. return true; //总是接受
  10391. }
  10392. public static string HttpPost(string url, string param = null)
  10393. {
  10394. HttpWebRequest request;
  10395. //如果是发送HTTPS请求
  10396. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10397. {
  10398. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10399. request = WebRequest.Create(url) as HttpWebRequest;
  10400. request.ProtocolVersion = HttpVersion.Version10;
  10401. }
  10402. else
  10403. {
  10404. request = WebRequest.Create(url) as HttpWebRequest;
  10405. }
  10406. request.Method = "POST";
  10407. request.ContentType = "application/json";
  10408. request.Accept = "*/*";
  10409. request.Timeout = 120000;
  10410. request.AllowAutoRedirect = false;
  10411. StreamWriter requestStream = null;
  10412. WebResponse response = null;
  10413. string responseStr = null;
  10414. try
  10415. {
  10416. requestStream = new StreamWriter(request.GetRequestStream());
  10417. requestStream.Write(param);
  10418. requestStream.Close();
  10419. response = request.GetResponse();
  10420. if (response != null)
  10421. {
  10422. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10423. responseStr = reader.ReadToEnd();
  10424. reader.Close();
  10425. }
  10426. }
  10427. catch (Exception ex)
  10428. {
  10429. return ex.Message;
  10430. }
  10431. finally
  10432. {
  10433. request = null;
  10434. requestStream = null;
  10435. response = null;
  10436. }
  10437. return responseStr;
  10438. }
  10439. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10440. {
  10441. string base64FileContent;
  10442. string fileName;
  10443. using (WebClient webClient = new WebClient())
  10444. {
  10445. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10446. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10447. {
  10448. using (Stream stream = response.GetResponseStream())
  10449. {
  10450. using (MemoryStream memoryStream = new MemoryStream())
  10451. {
  10452. stream.CopyTo(memoryStream);
  10453. byte[] fileBytes = memoryStream.ToArray();
  10454. base64FileContent = Convert.ToBase64String(fileBytes);
  10455. fileName = response.Headers["Content-Disposition"];
  10456. if (!string.IsNullOrEmpty(fileName))
  10457. {
  10458. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10459. if (index >= 0)
  10460. {
  10461. fileName = fileName.Substring(index + 9).Trim('\"');
  10462. }
  10463. }
  10464. else
  10465. {
  10466. fileName = Path.GetFileName(downloadUrl);
  10467. }
  10468. }
  10469. }
  10470. }
  10471. }
  10472. return (fileName, base64FileContent);
  10473. }
  10474. //新增
  10475. public void order_batch_caiyingtong(string[] downloadUrls)
  10476. {
  10477. try
  10478. {
  10479. //遍历文件
  10480. DataStruct dStruct = GetPostStruct();
  10481. DataTable dt = null;
  10482. int userid = CurrentUser.UserID;
  10483. List<string> ids = new List<string>();//失败组
  10484. List<string> tids = new List<string>();
  10485. using (WebClient webClient = new WebClient())
  10486. {
  10487. foreach (var url in downloadUrls)
  10488. {
  10489. try
  10490. {
  10491. tids.Add("'" + url + "'");
  10492. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10493. if (entity != null)
  10494. {
  10495. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10496. if (cp == null)
  10497. {
  10498. JObject jsonObject = new JObject
  10499. {
  10500. { "Userid", "77886" },
  10501. { "pwd", "lt666888" },
  10502. { "Filename",entity.seller_memo }
  10503. };
  10504. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10505. JObject jsonObjects = JObject.Parse(response);
  10506. string msg = (string)jsonObjects["msg"];
  10507. if (msg == "报价成功")
  10508. {
  10509. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10510. DownloadAndConvertToBase64(url1);
  10511. }
  10512. else
  10513. {
  10514. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10515. }
  10516. }
  10517. else
  10518. {
  10519. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10520. JObject jsonObject = new JObject
  10521. {
  10522. { "Userid", "77886" },
  10523. { "pwd", "lt666888" },
  10524. { "Filename",chanp }
  10525. };
  10526. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10527. JObject jsonObjects = JObject.Parse(response);
  10528. string msg = (string)jsonObjects["msg"];
  10529. if (msg == "报价成功")
  10530. {
  10531. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10532. DownloadAndConvertToBase64(url1);
  10533. }
  10534. else
  10535. {
  10536. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10537. }
  10538. }
  10539. }
  10540. // 上传文件到FTP
  10541. }
  10542. catch (Exception ex)
  10543. {
  10544. Console.WriteLine($"An error occurred: {ex.Message}");
  10545. }
  10546. }
  10547. List<string> lw = new List<string>();
  10548. lw.Add(string.Format("( OrderState < 6 )"));
  10549. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10550. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10551. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10552. if (dt.Rows.Count > 0)
  10553. {
  10554. foreach (DataRow dr in dt.Rows)
  10555. {
  10556. ids.Add(dr["ctid"].ToString());
  10557. }
  10558. }
  10559. String ErrorMsgs = "";
  10560. foreach (String id in ids)
  10561. {
  10562. ErrorMsgs += id + ",";
  10563. }
  10564. if (ErrorMsgs.Length > 1)
  10565. {
  10566. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10567. }
  10568. if (ErrorMsgs.Length < 1)
  10569. {
  10570. ErrorMsgs = "上传成功";
  10571. returnSuccessMsg(ErrorMsgs);
  10572. }
  10573. else
  10574. {
  10575. returnErrorMsg("以下订单" + ErrorMsgs);
  10576. }
  10577. }
  10578. // 删除文件夹及其内容
  10579. /* Directory.Delete(localDirectory, true);*/
  10580. }
  10581. catch { }
  10582. }
  10583. public void get_center_data()
  10584. {
  10585. int userId = CurrentUser.UserID;
  10586. string postCode = CurrentUser.UserPost.Post.Code;
  10587. List<string> lw = new List<string>();
  10588. List<string> ww = new List<string>();
  10589. DateTime currentTime = DateTime.Now;
  10590. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10591. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10592. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10593. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10594. string sql = " SELECT ";
  10595. string startTime = "2023-10-01 11:22:31";
  10596. //设计
  10597. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10598. {
  10599. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10600. 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));
  10601. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10602. 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));
  10603. }
  10604. //客服
  10605. else if (postCode == "CustomerService" || postCode == "Director")
  10606. {
  10607. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10608. 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));
  10609. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10610. 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));
  10611. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10612. 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));
  10613. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10614. 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));
  10615. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10616. 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));
  10617. }
  10618. //售后
  10619. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10620. {
  10621. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10622. 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));
  10623. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10624. 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));
  10625. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10626. 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));
  10627. }
  10628. //下单部
  10629. else if (postCode == "Place" || postCode == "PlaceMr")
  10630. {
  10631. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10632. 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));
  10633. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10634. 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));
  10635. }
  10636. //车间
  10637. else if (postCode == "Supplier")
  10638. {
  10639. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10640. 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));
  10641. }
  10642. DataTable dt = new DataTable();
  10643. if (lw.Count > 0)
  10644. {
  10645. sql += string.Join(" , ", lw);
  10646. sql += " FROM ";
  10647. sql += string.Join(" , ", ww);
  10648. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10649. }
  10650. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10651. }
  10652. public void get_center_data_list()
  10653. {
  10654. int userId = CurrentUser.UserID;
  10655. string postCode = CurrentUser.UserPost.Post.Code;
  10656. string shopIds = CurrentUser.User.pemShop;
  10657. DataStruct dStruct = GetPostStruct();
  10658. List<string> lw = new List<string>();
  10659. DateTime currentTime = DateTime.Now;
  10660. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10661. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10662. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10663. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10664. string startTime = "2023-10-01 11:22:31";
  10665. int order_type = GetPostInt("order_type");
  10666. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10667. {
  10668. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10669. if (order_type == 0)
  10670. {
  10671. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10672. }
  10673. else if (order_type == 3)
  10674. {
  10675. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10676. }
  10677. else
  10678. {
  10679. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10680. }
  10681. }
  10682. //客服
  10683. if (postCode == "CustomerService" || postCode == "Director")
  10684. {
  10685. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10686. if (order_type == 0)
  10687. {
  10688. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10689. }
  10690. else if (order_type == 1)
  10691. {
  10692. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10693. }
  10694. else if (order_type == 2)
  10695. {
  10696. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10697. }
  10698. else if (order_type == 3)
  10699. {
  10700. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10701. }
  10702. else if (order_type == 4)
  10703. {
  10704. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10705. }
  10706. else
  10707. {
  10708. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10709. }
  10710. }
  10711. //售后
  10712. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10713. {
  10714. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10715. if (shopIds != "")
  10716. {
  10717. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10718. }
  10719. if (order_type == 2)
  10720. {
  10721. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10722. }
  10723. else if (order_type == 4)
  10724. {
  10725. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10726. }
  10727. else if (order_type == 5)
  10728. {
  10729. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10730. }
  10731. else
  10732. {
  10733. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10734. }
  10735. }
  10736. //下单部
  10737. if (postCode == "Place" || postCode == "PlaceMr")
  10738. {
  10739. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10740. if (shopIds != "")
  10741. {
  10742. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10743. }
  10744. else if (order_type == 1)
  10745. {
  10746. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10747. }
  10748. else if (order_type == 2)
  10749. {
  10750. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10751. }
  10752. else
  10753. {
  10754. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10755. }
  10756. }
  10757. //车间
  10758. if (postCode == "Supplier")
  10759. {
  10760. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10761. if (order_type == 5)
  10762. {
  10763. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10764. }
  10765. else
  10766. {
  10767. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10768. }
  10769. }
  10770. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10771. dStruct.Fileds = "tid,ctid";
  10772. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10773. writeGridDataTableJson(dStruct.TotalCount, dt);
  10774. }
  10775. public void aftersale_audit_master()
  10776. {
  10777. if (UrlPostParmsCheck("ctid"))
  10778. {
  10779. string ctid = GetPostString("ctid");
  10780. if (ctid.Length > 0)
  10781. {
  10782. bool result = aftersale_data_change(ctid);
  10783. if (result)
  10784. {
  10785. returnSuccessMsg("修改成功!");
  10786. return;
  10787. }
  10788. }
  10789. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10790. }
  10791. }
  10792. public void aftersale_batch_audit_master()
  10793. {
  10794. if (UrlPostParmsCheck("ctids"))
  10795. {
  10796. string ctids = GetPostString("ctids");
  10797. if (ctids.Length > 0)
  10798. {
  10799. List<string> list = new List<string>();
  10800. string[] ctid_list = ctids.Split(',');
  10801. foreach (var item in ctid_list)
  10802. {
  10803. bool result = aftersale_data_change(item);
  10804. if (!result)
  10805. {
  10806. list.Add(item);
  10807. }
  10808. }
  10809. if (list.Count > 0)
  10810. {
  10811. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10812. return;
  10813. }
  10814. returnSuccessMsg("修改成功!");
  10815. return;
  10816. }
  10817. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10818. }
  10819. }
  10820. public bool aftersale_data_change(string ctid)
  10821. {
  10822. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10823. if (ceErpTradeCell != null)
  10824. {
  10825. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10826. ceErpTradeCell.AfterSaleSupplierState = 0;
  10827. StringBuilder sql = new StringBuilder();
  10828. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10829. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10830. CeErpTradeResponsible.DelByTid(ctid, 0);
  10831. 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 == "不理赔")
  10832. {
  10833. CeErpTradeResponsible.DelByTid(ctid, 1);
  10834. ceErpTradeCell.AfterSaleSupplierState = 1;
  10835. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10836. ceErpTradeCell.AfterSaleState = 4;
  10837. }
  10838. else
  10839. {
  10840. ceErpTradeCell.AfterSaleState = 3;
  10841. }
  10842. bool needCyt = false;
  10843. if (dt != null)
  10844. {
  10845. if (dt.Rows.Count == 1)
  10846. {
  10847. bool isEnd = false;
  10848. foreach (DataRow dr in dt.Rows)
  10849. {
  10850. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10851. {
  10852. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10853. isEnd = true;
  10854. }
  10855. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10856. {
  10857. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10858. isEnd = true;
  10859. }
  10860. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10861. {
  10862. needCyt = true;
  10863. }
  10864. }
  10865. if (isEnd)
  10866. {
  10867. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10868. ceErpTradeCell.AfterSaleState = 4;
  10869. ceErpTradeCell.AfterSaleSupplierState = 1;
  10870. }
  10871. }
  10872. else
  10873. {
  10874. bool isAll = true;
  10875. foreach (DataRow dr in dt.Rows)
  10876. {
  10877. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10878. {
  10879. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10880. continue;
  10881. }
  10882. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10883. {
  10884. string path = "";
  10885. int OrgID = 0;
  10886. if (!Convert.IsDBNull(dr["OrgPath"]))
  10887. {
  10888. path = dr["OrgPath"].ToString();
  10889. }
  10890. if (!Convert.IsDBNull(dr["OrgID"]))
  10891. {
  10892. OrgID = Convert.ToInt32(dr["OrgID"]);
  10893. }
  10894. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10895. {
  10896. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10897. continue;
  10898. }
  10899. }
  10900. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  10901. {
  10902. needCyt = true;
  10903. }
  10904. isAll = false;
  10905. }
  10906. if (isAll)
  10907. {
  10908. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10909. ceErpTradeCell.AfterSaleState = 4;
  10910. ceErpTradeCell.AfterSaleSupplierState = 1;
  10911. }
  10912. }
  10913. }
  10914. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10915. {
  10916. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10917. }
  10918. if (ceErpTradeCell.AfterSaleState == 4)
  10919. {
  10920. ApiVo apiVo = new ApiVo();
  10921. apiVo.orderNumber = ceErpTradeCell.ctid;
  10922. apiVo.actionName = "afterOver";
  10923. designHelper.API_WorkCore(apiVo); //afterOver
  10924. }
  10925. ceErpTradeCell.Update();
  10926. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10927. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10928. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10929. return true;
  10930. }
  10931. return false;
  10932. }
  10933. public void get_erp_wechatorder()
  10934. {
  10935. DataStruct dStruct = GetPostStruct();
  10936. List<string> lw = new List<string>();
  10937. string tid = GetPostString("tid");
  10938. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10939. string shopname = GetPostString("shopname");
  10940. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10941. string buyernick = GetPostString("buyer_nick");
  10942. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10943. string customer = GetPostString("customer");
  10944. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10945. string returndate1 = GetPostString("returndate1");
  10946. string returndate2 = GetPostString("returndate2");
  10947. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10948. if (dw.Length > 0) lw.Add(dw);
  10949. string finishDate1 = GetPostString("finishdate1");
  10950. string finishDate2 = GetPostString("finishdate2");
  10951. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10952. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10953. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10954. dStruct.Order = "created desc";
  10955. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10956. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10957. writeGridDataTableJson(dStruct.TotalCount, dt);
  10958. }
  10959. public void get_erp_wechatlist_sumprice()
  10960. {
  10961. DataStruct dStruct = GetPostStruct();
  10962. List<string> lw = new List<string>();
  10963. string tid = GetPostString("tid");
  10964. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10965. string shopname = GetPostString("shopname");
  10966. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10967. string buyernick = GetPostString("buyer_nick");
  10968. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10969. string customer = GetPostString("customer");
  10970. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10971. string returndate1 = GetPostString("returndate1");
  10972. string returndate2 = GetPostString("returndate2");
  10973. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10974. if (dw.Length > 0) lw.Add(dw);
  10975. string finishDate1 = GetPostString("finishdate1");
  10976. string finishDate2 = GetPostString("finishdate2");
  10977. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10978. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10979. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10980. string mainWhere = string.Join(" and ", lw.ToArray());
  10981. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10982. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10983. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10984. decimal total = 0;
  10985. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10986. {
  10987. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10988. }
  10989. var res = new
  10990. {
  10991. data = total
  10992. };
  10993. string ro_jsond = JsonConvert.SerializeObject(res);
  10994. returnSuccess(ro_jsond);
  10995. return;
  10996. }
  10997. public void get_erp_qr_waitdeliverylist()
  10998. {
  10999. DataStruct dStruct = GetPostStruct();
  11000. List<string> lw = new List<string>();
  11001. string tid = GetPostString("ctid");
  11002. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11003. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11004. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11005. var res_objz = new
  11006. {
  11007. restype = 1,
  11008. data = dt
  11009. };
  11010. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11011. returnSuccess(ro_jsonz);
  11012. }
  11013. public void get_erp_yield_list()
  11014. {
  11015. DataStruct dStruct = GetPostStruct();
  11016. List<string> lw = new List<string>();
  11017. string tid = GetPostString("ctid");
  11018. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11019. string shopname = GetPostString("shopname");
  11020. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11021. string buyernick = GetPostString("buyer_nick");
  11022. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11023. //if (tid.Length == 0 && buyernick.Length == 0)
  11024. //{
  11025. // lw.Add(string.Format("IsRefund<={0}", 1));
  11026. //}
  11027. string customer = GetPostString("customer");
  11028. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11029. string design = GetPostString("design");
  11030. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11031. string orderState = GetPostString("orderState");
  11032. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11033. string address = GetPostString("address");
  11034. 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));
  11035. string sellermemo = GetPostString("seller_memo");
  11036. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11037. string supplier = GetPostString("supplier");
  11038. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11039. string OrderArea = GetPostString("order_area");
  11040. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11041. string placedate1 = GetPostString("placedate1");
  11042. string placedate2 = GetPostString("placedate2");
  11043. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11044. if (fdw.Length > 0) lw.Add(fdw);
  11045. string price1 = GetPostString("price1");
  11046. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11047. string price2 = GetPostString("price2");
  11048. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11049. string unusualCon = GetPostString("unusualcon");
  11050. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11051. string posTag = CurrentUser.UserPost.Post.Code;
  11052. if (posTag == "Supplier")
  11053. {
  11054. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11055. }
  11056. lw.Add(string.Format("OrderState = 6 "));
  11057. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11058. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11059. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11060. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11061. writeGridDataTableJson(dStruct.TotalCount, dt);
  11062. }
  11063. public void change_erp_sup_state()
  11064. {
  11065. if (UrlPostParmsCheck("ctid"))
  11066. {
  11067. string ctid = GetPostString("ctid");
  11068. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11069. if (ceErpTradeCell != null)
  11070. {
  11071. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11072. if (ceErpTradeCellExtend == null)
  11073. {
  11074. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11075. ceErpTradeCellExtend.ctid = ctid;
  11076. ceErpTradeCellExtend.SupState = 1;
  11077. ceErpTradeCellExtend.Create();
  11078. }
  11079. else
  11080. {
  11081. ceErpTradeCellExtend.SupState = 1;
  11082. ceErpTradeCellExtend.Update();
  11083. }
  11084. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11085. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11086. return;
  11087. }
  11088. returnErrorMsg("找不到订单");
  11089. }
  11090. }
  11091. public void supplier_all_downs()
  11092. {
  11093. if (UrlPostParmsCheck("tids"))
  11094. {
  11095. string tids = GetPostString("tids");
  11096. if (tids != null && tids.Length > 0)
  11097. {
  11098. StringBuilder sql = new StringBuilder();
  11099. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11100. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11101. sql = new StringBuilder();
  11102. 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, "下载设计文件");
  11103. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11104. string[] list = tids.Split(',');
  11105. foreach (string ctid in list)
  11106. {
  11107. CeErpSukuraData.createInfo(ctid, 3);
  11108. }
  11109. designHelper.api_approveDesign(tids); //approveDesign
  11110. returnSuccessMsg("下载成功!");
  11111. return;
  11112. }
  11113. returnErrorMsg("下载订单更新失败");
  11114. }
  11115. }
  11116. public void uploaderFileSuccess()
  11117. {
  11118. if (UrlPostParmsCheck("fileName"))
  11119. {
  11120. string fileName = GetPostString("fileName");
  11121. ApiVo apiVo = new ApiVo();
  11122. apiVo.orderNumber = fileName;
  11123. apiVo.actionName = "finishDesign";
  11124. designHelper.API_WorkCore(apiVo);//finishDesign
  11125. returnSuccessMsg("");
  11126. }
  11127. }
  11128. public void get_sample2_order()
  11129. {
  11130. if (UrlPostParmsCheck("ctid"))
  11131. {
  11132. string ctid = GetPostString("ctid");
  11133. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11134. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11135. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11136. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11137. double total = 0.0;
  11138. double order_price = 0.0;
  11139. if (dt_bu.Rows.Count > 0)
  11140. {
  11141. foreach (DataRow dr in dt_bu.Rows)
  11142. {
  11143. total += Convert.ToDouble(dr["payment"]);
  11144. }
  11145. }
  11146. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11147. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11148. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11149. string tid = ctid.Replace("S_", "");
  11150. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11151. double paymant = 0.0;
  11152. if (entity != null)
  11153. {
  11154. paymant = entity.payment;
  11155. }
  11156. string return_reason = "";
  11157. if (dt_after != null && dt_after.Rows.Count > 0)
  11158. {
  11159. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11160. }
  11161. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11162. }
  11163. }
  11164. public void get_erp_design_status()
  11165. {
  11166. string designName = GetPostString("designName");
  11167. DataStruct dStruct = GetPostStruct();
  11168. if (designName.Length > 0)
  11169. {
  11170. 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";
  11171. sql_user += " and Name like '%" + designName + "%'";
  11172. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11173. List<string> ids_list = new List<string>();
  11174. if (user_table.Rows.Count > 0)
  11175. {
  11176. foreach (DataRow item in user_table.Rows)
  11177. {
  11178. ids_list.Add(item["id"].ToString());
  11179. string ids_s = item["TeamIds"].ToString();
  11180. if (ids_s.Length > 0)
  11181. {
  11182. ids_list.AddRange(ids_s.Split(','));
  11183. }
  11184. }
  11185. }
  11186. HashSet<string> set = new HashSet<string>(ids_list);
  11187. ids_list = set.ToList();
  11188. if (ids_list.Count > 0)
  11189. {
  11190. 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));
  11191. dStruct.MainWhere = sql;
  11192. DataTable dt = null;
  11193. dt = WebCache.GetData("view_ErpUser", dStruct);
  11194. writeGridDataTableJson(dStruct.TotalCount, dt);
  11195. }
  11196. }
  11197. }
  11198. public void change_erp_order_price()
  11199. {
  11200. string ctid = GetPostString("ctid");
  11201. double price = GetPostDouble("price");
  11202. if (ctid.Length > 0)
  11203. {
  11204. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11205. if (ceErpTradeCellExtend == null)
  11206. {
  11207. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11208. ceErpTradeCellExtend.ctid = ctid;
  11209. ceErpTradeCellExtend.payment_cyt = price;
  11210. ceErpTradeCellExtend.Create();
  11211. }
  11212. else
  11213. {
  11214. ceErpTradeCellExtend.payment_cyt = price;
  11215. ceErpTradeCellExtend.Update();
  11216. }
  11217. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11218. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11219. {
  11220. ceErpDataSendOrderInfo.isSync = false;
  11221. ceErpDataSendOrderInfo.Update();
  11222. }
  11223. if (ceErpDataSendOrderInfo == null)
  11224. {
  11225. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11226. ceErpDataSendOrderInfo.isSync = false;
  11227. ceErpDataSendOrderInfo.ctid = ctid;
  11228. ceErpDataSendOrderInfo.Create();
  11229. }
  11230. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11231. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11232. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11233. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11234. {
  11235. dataSendOrderBean dataSendOrderBean = null;
  11236. foreach (DataRow item in dth.Rows)
  11237. {
  11238. try
  11239. {
  11240. dataSendOrderBean = new dataSendOrderBean();
  11241. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11242. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11243. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11244. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11245. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11246. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11247. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11248. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11249. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11250. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11251. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11252. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11253. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11254. if (result != null)
  11255. {
  11256. if ("0".Equals(result.errcode))
  11257. {
  11258. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11259. }
  11260. else
  11261. {
  11262. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11263. }
  11264. }
  11265. }
  11266. catch (Exception ex)
  11267. {
  11268. }
  11269. }
  11270. }
  11271. returnSuccessMsg("修改成功!");
  11272. return;
  11273. }
  11274. returnErrorMsg("找不到订单");
  11275. }
  11276. public void find_he_together()
  11277. {
  11278. string ctid = GetPostString("ctid");
  11279. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11280. List<string> list = new List<string>();
  11281. if (ceErpTradeCell != null)
  11282. {
  11283. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11284. {
  11285. 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);
  11286. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11287. if (table != null && table.Rows.Count > 0)
  11288. {
  11289. foreach (TableRow row in table.Rows)
  11290. {
  11291. }
  11292. }
  11293. }
  11294. }
  11295. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11296. }
  11297. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11298. {
  11299. //chy----19
  11300. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11301. //GD-CYT-----64
  11302. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11303. //ZHX----3
  11304. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11305. //JK----97
  11306. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11307. //ZT----70
  11308. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11309. //LHCY-----98
  11310. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11311. //XD-----90
  11312. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11313. //CYCY-----14
  11314. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11315. };
  11316. //其他改名
  11317. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11318. {
  11319. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11320. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11321. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11322. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11323. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11324. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11325. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11326. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11327. };
  11328. //不统计
  11329. List<int> no_suppliers = new List<int>()
  11330. {
  11331. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11332. };
  11333. //配件单
  11334. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11335. {
  11336. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11337. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11338. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11339. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11340. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11341. {"旗杆",new List<string>(){ "班旗" } },
  11342. {"牙签",new List<string>(){ "不干胶" } }
  11343. };
  11344. public void get_place_order_data()
  11345. {
  11346. string date1 = GetPostString("date1");
  11347. string date2 = GetPostString("date2");
  11348. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11349. DateTime start = DateTime.Parse(starttime);
  11350. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11351. DateTime end = DateTime.Parse(endtime);
  11352. if (date1 != null && date1.Length > 0)
  11353. {
  11354. DateTime dateTime = DateTime.Parse(date1);
  11355. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11356. start = DateTime.Parse(starttime);
  11357. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11358. end = DateTime.Parse(endtime);
  11359. }
  11360. if (date2 != null && date2.Length > 0)
  11361. {
  11362. DateTime dateTime = DateTime.Parse(date2);
  11363. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11364. end = DateTime.Parse(endtime);
  11365. }
  11366. 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);
  11367. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11368. //不干胶-----1,卡片-----29
  11369. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11370. foreach (DataRow row in data.Rows)
  11371. {
  11372. int productId = Convert.ToInt32(row["ProductId"]);
  11373. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11374. if (no_suppliers.Contains(supplierId))
  11375. {
  11376. continue;
  11377. }
  11378. string seller_memo = row["seller_memo"].ToString();
  11379. bool ispj = false;//是否配件单
  11380. bool isfirst = true;//第一个配
  11381. maps.Keys.ForEach(key =>
  11382. {
  11383. //备注包含配件
  11384. if (seller_memo.Contains(key) && isfirst)
  11385. {
  11386. List<string> list = maps[key];
  11387. ispj = true;
  11388. isfirst = false;
  11389. for (int i = 0; i < list.Count; i++)
  11390. {
  11391. if (seller_memo.Contains(list[i]))
  11392. {
  11393. ispj = false;
  11394. break;
  11395. }
  11396. }
  11397. }
  11398. });
  11399. if (ispj)
  11400. {
  11401. continue;
  11402. }
  11403. seller_memo = seller_memo.Replace("UV", "uv");
  11404. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11405. //吊牌归到卡片
  11406. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11407. seller_memo = seller_memo.Replace("卡套", "卡片");
  11408. seller_memo = seller_memo.Replace("封套", "卡片");
  11409. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11410. seller_memo = seller_memo.Replace("腰封", "卡片");
  11411. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11412. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11413. seller_memo = seller_memo.Replace("横幅", "条幅");
  11414. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11415. string map_key = "";
  11416. string type = "";
  11417. if (supplierMap.ContainsKey(supplierId))
  11418. {
  11419. foreach (var kvp in supplierMap[supplierId])
  11420. {
  11421. if (seller_memo.Contains(kvp.Key))
  11422. {
  11423. map_key = kvp.Value;
  11424. type = kvp.Value;
  11425. break;
  11426. }
  11427. }
  11428. }
  11429. if (map_key == "")
  11430. {
  11431. type = "其他";
  11432. map_key = "其他";
  11433. }
  11434. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11435. {
  11436. map_key = suppliers[supplierId];
  11437. }
  11438. if (supplierId == 70)
  11439. {
  11440. supplierId = 70;
  11441. }
  11442. map_key += "_" + row["SupplierName"].ToString();
  11443. Dictionary<string, int> map = null;
  11444. if (other_map.ContainsKey(map_key))
  11445. {
  11446. other_map.TryGetValue(map_key, out map);
  11447. }
  11448. else
  11449. {
  11450. map = new Dictionary<string, int>();
  11451. map.Add("dayDev", 0);//当天出货
  11452. map.Add("dayTotal", 0);//下单总数
  11453. map.Add("payTotal", 0);//500以上
  11454. map.Add("today", 0);//当天出货数量
  11455. map.Add("unusua", 0);//异常数
  11456. other_map.Add(map_key, map);
  11457. other_map.TryGetValue(map_key, out map);
  11458. }
  11459. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11460. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11461. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11462. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11463. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11464. {
  11465. map["dayTotal"]++;
  11466. if (supplierId == 97)
  11467. {
  11468. supplierId = 97;
  11469. }
  11470. }
  11471. if (Convert.ToDecimal(row["payment"]) >= 500)
  11472. {
  11473. map["payTotal"]++;
  11474. }
  11475. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11476. {
  11477. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11478. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11479. {
  11480. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11481. {
  11482. map["today"]++;
  11483. }
  11484. }
  11485. else
  11486. {
  11487. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11488. {
  11489. map["today"]++;
  11490. }
  11491. else
  11492. {
  11493. if (supplierId == 119)
  11494. {
  11495. Debug.WriteLine(row["seller_memo"].ToString());
  11496. }
  11497. }
  11498. }
  11499. }
  11500. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11501. {
  11502. map["unusua"]++;
  11503. }
  11504. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11505. //GD-CYT-----64
  11506. DateTime two = palceTimeStart.AddHours(14);
  11507. DateTime three = palceTimeStart.AddHours(15);
  11508. DateTime four = palceTimeStart.AddHours(16);
  11509. DateTime six = palceTimeStart.AddHours(18);
  11510. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11511. {
  11512. //下午四点前 500-1000
  11513. string count = row["ProductCount"].ToString();
  11514. if (count != null && count.Length > 0)
  11515. {
  11516. int productCount = commonHelper.getPlaceProductCount(count);
  11517. if (productCount >= 500 && productCount <= 1000)
  11518. {
  11519. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11520. {
  11521. map["dayDev"]++;
  11522. }
  11523. }
  11524. }
  11525. }
  11526. //UV
  11527. else if ("uv".Equals(type))
  11528. {
  11529. //ZT----70
  11530. //ZHX----3
  11531. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11532. {
  11533. map["dayDev"]++;
  11534. }
  11535. //JK----97
  11536. //HZX----105
  11537. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11538. {
  11539. map["dayDev"]++;
  11540. }
  11541. }
  11542. //帆布---52|条幅---27
  11543. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11544. {
  11545. //LHCY-----98
  11546. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11547. {
  11548. map["dayDev"]++;
  11549. }
  11550. }
  11551. //条幅
  11552. else if ("条幅".Equals(type))
  11553. {
  11554. //XD-----90
  11555. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11556. {
  11557. map["dayDev"]++;
  11558. }
  11559. }
  11560. //桌布
  11561. else if ("桌布".Equals(type))
  11562. {
  11563. //XD-----90
  11564. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11565. {
  11566. map["dayDev"]++;
  11567. }
  11568. }
  11569. //DL---10
  11570. //AYTW---119
  11571. //FS-CYT-DY ----80
  11572. //JK----97
  11573. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11574. {
  11575. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11576. {
  11577. map["dayDev"]++;
  11578. }
  11579. }
  11580. // QC---121
  11581. else if (supplierId == 121)
  11582. {
  11583. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11584. {
  11585. map["dayDev"]++;
  11586. }
  11587. }
  11588. }
  11589. DataTable dt = new DataTable();
  11590. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11591. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11592. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11593. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11594. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11595. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11596. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11597. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11598. other_map.Keys.ForEach(key =>
  11599. {
  11600. DataRow dr = dt.NewRow();
  11601. Dictionary<string, int> map = other_map[key];
  11602. string[] key_list = key.Split('_');
  11603. dr[0] = key_list[0];
  11604. dr[1] = key_list[1];
  11605. if (key_list.Length > 2)
  11606. {
  11607. dr[1] += "(" + key_list[2] + ")";
  11608. }
  11609. dr[2] = map["dayTotal"];
  11610. dr[3] = map["payTotal"];
  11611. dr[4] = map["today"];
  11612. dr[5] = map["unusua"];
  11613. dr[6] = map["dayDev"];
  11614. double rate = 0.00;
  11615. if (map["dayDev"] > 0)
  11616. {
  11617. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11618. }
  11619. dr[7] = rate.ToString();
  11620. dt.Rows.Add(dr);
  11621. });
  11622. DataView dv = new DataView(dt);
  11623. dv.Sort = "SupplierName";
  11624. //dv.Sort = "AllOrder desc";
  11625. DataTable dtNew = dv.ToTable();
  11626. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11627. }
  11628. public void check_order_desing_info()
  11629. {
  11630. string ctid = GetPostString("ctid");
  11631. if (!string.IsNullOrEmpty(ctid))
  11632. {
  11633. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11634. if (ceErpTradeCell != null)
  11635. {
  11636. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11637. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11638. return;
  11639. }
  11640. returnErrorMsg("找不到订单");
  11641. return;
  11642. }
  11643. returnErrorMsg("找不到订单");
  11644. }
  11645. public void get_timeout_detail()
  11646. {
  11647. string poscode = CurrentUser.UserPost.Post.Code;
  11648. DataStruct dStruct = GetPostStruct();
  11649. List<string> lw = new List<string>();
  11650. string id = GetPostString("id");
  11651. string pay_date1 = GetPostString("pay_date1");
  11652. string pay_date2 = GetPostString("pay_date2");
  11653. int type = GetPostInt("type");
  11654. if (type == 0)
  11655. {
  11656. if (pay_date1.Length > 0)
  11657. {
  11658. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11659. }
  11660. if (pay_date2.Length > 0)
  11661. {
  11662. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11663. }
  11664. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11665. }
  11666. if (type == 1)
  11667. {
  11668. if (pay_date1.Length > 0)
  11669. {
  11670. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11671. }
  11672. if (pay_date2.Length > 0)
  11673. {
  11674. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11675. }
  11676. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11677. }
  11678. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11679. DataTable dt = null;
  11680. dt = WebCache.GetData("view_orderlist", dStruct);
  11681. writeGridDataTableJson(dStruct.TotalCount, dt);
  11682. }
  11683. public void saveUrgentChargePrice()
  11684. {
  11685. string ctid = GetPostString("ctid");
  11686. if (!string.IsNullOrEmpty(ctid))
  11687. {
  11688. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11689. if (ceErpTradeCell != null)
  11690. {
  11691. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11692. if (prices <= 100)
  11693. {
  11694. returnErrorMsg("此订单金额不足100元,无法加急。");
  11695. return;
  11696. }
  11697. double price = GetPostDouble("price");
  11698. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11699. if (ceErpTradeCellExtend == null)
  11700. {
  11701. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11702. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11703. }
  11704. ceErpTradeCellExtend.urgentCharge = price;
  11705. if (ceErpTradeCellExtend.ID > 0)
  11706. {
  11707. ceErpTradeCellExtend.Update();
  11708. }
  11709. else
  11710. {
  11711. ceErpTradeCellExtend.Save();
  11712. }
  11713. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11714. returnSuccessMsg("修改成功!");
  11715. return;
  11716. }
  11717. returnErrorMsg("找不到订单");
  11718. return;
  11719. }
  11720. returnErrorMsg("找不到订单");
  11721. }
  11722. public void finish_erp_order()
  11723. {
  11724. string ctid = GetPostString("ctid");
  11725. if (!string.IsNullOrEmpty(ctid))
  11726. {
  11727. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11728. {
  11729. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11730. if (ceErpTradeCell != null)
  11731. {
  11732. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11733. ceErpTradeCell.Update();
  11734. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11735. returnSuccessMsg("修改成功!");
  11736. return;
  11737. }
  11738. }
  11739. }
  11740. returnErrorMsg("找不到订单");
  11741. }
  11742. public void get_trade_order_list()
  11743. {
  11744. string tid = GetPostString("tid");
  11745. if (!string.IsNullOrEmpty(tid))
  11746. {
  11747. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11748. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11749. writeGridDataTableJson(data.Rows.Count, data);
  11750. return;
  11751. }
  11752. returnErrorMsg("找不到订单");
  11753. }
  11754. public void save_cell_spu()
  11755. {
  11756. string ctid = GetPostString("ctid");
  11757. string spu_id = GetPostString("spu_id");
  11758. if (!string.IsNullOrEmpty(ctid))
  11759. {
  11760. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11761. if (ceErpTradeCellExtend == null)
  11762. {
  11763. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11764. ceErpTradeCellExtend.ctid = ctid;
  11765. }
  11766. ceErpTradeCellExtend.spu_id = spu_id;
  11767. if (!string.IsNullOrEmpty(spu_id))
  11768. {
  11769. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11770. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11771. }
  11772. if (ceErpTradeCellExtend.ID == 0)
  11773. {
  11774. ceErpTradeCellExtend.Create();
  11775. }
  11776. else
  11777. {
  11778. ceErpTradeCellExtend.Update();
  11779. }
  11780. returnSuccessMsg("修改成功!");
  11781. return;
  11782. }
  11783. returnErrorMsg("找不到订单");
  11784. }
  11785. public void change_express_info()
  11786. {
  11787. string ctid = GetPostString("ctid");
  11788. string transNo = GetPostString("transNo");
  11789. string transCom = GetPostString("transCom");
  11790. if (!string.IsNullOrEmpty(ctid))
  11791. {
  11792. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11793. if (ceErpTradeCellExtend == null)
  11794. {
  11795. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11796. ceErpTradeCellExtend.ctid = ctid;
  11797. }
  11798. ceErpTradeCellExtend.modExpressNo = transNo;
  11799. ceErpTradeCellExtend.modExpressCom = transCom;
  11800. ceErpTradeCellExtend.readMod = 2;
  11801. if (ceErpTradeCellExtend.ID == 0)
  11802. {
  11803. ceErpTradeCellExtend.Create();
  11804. }
  11805. else
  11806. {
  11807. ceErpTradeCellExtend.Update();
  11808. }
  11809. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11810. returnSuccessMsg("修改成功!");
  11811. return;
  11812. }
  11813. returnErrorMsg("找不到订单");
  11814. }
  11815. public void get_change_express_list()
  11816. {
  11817. DataStruct dStruct = GetPostStruct();
  11818. List<string> lw = new List<string>();
  11819. int st = 2;
  11820. string tid = GetPostString("ctid");
  11821. if (tid.Length > 0)
  11822. {
  11823. string select_tid = getTidByCtid(tid);
  11824. lw.Add(string.Format("tid='{0}'", select_tid));
  11825. }
  11826. string shopname = GetPostString("shopname");
  11827. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11828. string buyernick = GetPostString("buyer_nick");
  11829. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11830. string sellermemo = GetPostString("seller_memo");
  11831. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11832. string supplier = GetPostString("supplier");
  11833. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11834. string customer = GetPostString("customer");
  11835. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11836. string design = GetPostString("design");
  11837. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11838. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11839. string poscode = CurrentUser.UserPost.Post.Code;
  11840. if (poscode != "SysAdmin")
  11841. {
  11842. string shopid = CurrentUser.User.pemShop;
  11843. lw.Add(string.Format("shopId in ({0})", shopid));
  11844. }
  11845. lw.Add("readMod = 2");
  11846. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11847. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11848. writeGridDataTableJson(dStruct.TotalCount, dt);
  11849. }
  11850. public void deal_express_complete()
  11851. {
  11852. string ctid = GetPostString("ctid");
  11853. if (!string.IsNullOrEmpty(ctid))
  11854. {
  11855. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11856. if (ceErpTradeCellExtend == null)
  11857. {
  11858. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11859. ceErpTradeCellExtend.ctid = ctid;
  11860. }
  11861. ceErpTradeCellExtend.readMod = 1;
  11862. if (ceErpTradeCellExtend.ID == 0)
  11863. {
  11864. ceErpTradeCellExtend.Create();
  11865. }
  11866. else
  11867. {
  11868. ceErpTradeCellExtend.Update();
  11869. }
  11870. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11871. returnSuccessMsg("修改成功!");
  11872. return;
  11873. }
  11874. returnErrorMsg("找不到订单");
  11875. }
  11876. public void aftersale_return_visit()
  11877. {
  11878. string ctid = GetPostString("ctid");
  11879. if (!string.IsNullOrEmpty(ctid))
  11880. {
  11881. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11882. if (ceErpTradeCellExtend == null)
  11883. {
  11884. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11885. ceErpTradeCellExtend.ctid = ctid;
  11886. }
  11887. ceErpTradeCellExtend.returnVisit = 1;
  11888. if (ceErpTradeCellExtend.ID == 0)
  11889. {
  11890. ceErpTradeCellExtend.Create();
  11891. }
  11892. else
  11893. {
  11894. ceErpTradeCellExtend.Update();
  11895. }
  11896. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11897. if (ceErpTradeAfterSaleExtend != null)
  11898. {
  11899. ceErpTradeAfterSaleExtend.TextResult = "";
  11900. ceErpTradeAfterSaleExtend.Update();
  11901. }
  11902. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11903. returnSuccessMsg("修改成功!");
  11904. return;
  11905. }
  11906. returnErrorMsg("找不到订单");
  11907. }
  11908. public void orderPlaceInfo()
  11909. {
  11910. string ctids = GetPostString("ctids");
  11911. string[] list = ctids.Split(',');
  11912. foreach (string ctid in list)
  11913. {
  11914. CeErpSukuraData.createInfo(ctid, 3);
  11915. }
  11916. StringBuilder sql = new StringBuilder();
  11917. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11918. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11919. designHelper.api_approveDesign(ctids); //approveDesign
  11920. returnSuccessMsg("");
  11921. }
  11922. public void get_issue_list()
  11923. {
  11924. DataStruct dStruct = GetPostStruct();
  11925. List<string> lw = new List<string>();
  11926. int st = 2;
  11927. string tid = GetPostString("ctid");
  11928. if (tid.Length > 0)
  11929. {
  11930. string select_tid = getTidByCtid(tid);
  11931. lw.Add(string.Format("tid='{0}'", select_tid));
  11932. }
  11933. string shopname = GetPostString("shopname");
  11934. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11935. string buyernick = GetPostString("buyer_nick");
  11936. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11937. string sellermemo = GetPostString("seller_memo");
  11938. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11939. string supplier = GetPostString("supplier");
  11940. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11941. string customer = GetPostString("customer");
  11942. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11943. string design = GetPostString("design");
  11944. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11945. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11946. string poscode = CurrentUser.UserPost.Post.Code;
  11947. if (poscode != "SysAdmin")
  11948. {
  11949. string shopid = CurrentUser.User.pemShop;
  11950. lw.Add(string.Format("shopId in ({0})", shopid));
  11951. }
  11952. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  11953. {
  11954. lw.Add("IssueState = 1");
  11955. }
  11956. else
  11957. {
  11958. string iisstate = GetPostString("iisstate");
  11959. if ("1".Equals(iisstate))
  11960. {
  11961. lw.Add("IssueState =1");
  11962. }
  11963. else if ("2".Equals(iisstate))
  11964. {
  11965. lw.Add("IssueState = 2");
  11966. }
  11967. else
  11968. {
  11969. lw.Add("IssueState > 0");
  11970. }
  11971. }
  11972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11973. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11974. writeGridDataTableJson(dStruct.TotalCount, dt);
  11975. }
  11976. public void saveIssueContent()
  11977. {
  11978. string ctid = GetPostString("ctid");
  11979. if (!string.IsNullOrEmpty(ctid))
  11980. {
  11981. string content = GetPostString("content");
  11982. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11983. if (ceErpTradeAfterSaleExtend == null)
  11984. {
  11985. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11986. ceErpTradeAfterSaleExtend.tid = ctid;
  11987. }
  11988. ceErpTradeAfterSaleExtend.IssueContent = content;
  11989. ceErpTradeAfterSaleExtend.IssueState = 1;
  11990. if (ceErpTradeAfterSaleExtend.ID > 0)
  11991. {
  11992. ceErpTradeAfterSaleExtend.Update();
  11993. }
  11994. else
  11995. {
  11996. ceErpTradeAfterSaleExtend.Create();
  11997. }
  11998. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11999. returnSuccessMsg("添加成功!");
  12000. return;
  12001. }
  12002. returnErrorMsg("找不到订单");
  12003. }
  12004. public void dealIssueContent()
  12005. {
  12006. string ctid = GetPostString("ctid");
  12007. if (!string.IsNullOrEmpty(ctid))
  12008. {
  12009. string content = GetPostString("content");
  12010. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12011. if (ceErpTradeAfterSaleExtend != null)
  12012. {
  12013. ceErpTradeAfterSaleExtend.IssueState = 2;
  12014. ceErpTradeAfterSaleExtend.Update();
  12015. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12016. returnSuccessMsg("修改完成!");
  12017. return;
  12018. }
  12019. }
  12020. returnErrorMsg("找不到订单");
  12021. }
  12022. public void set_tid_attachments()
  12023. {
  12024. string tid = GetPostString("tid");
  12025. string atta = GetPostString("atta");
  12026. if (!string.IsNullOrEmpty(tid))
  12027. {
  12028. if (string.IsNullOrEmpty(atta))
  12029. {
  12030. returnErrorMsg("文件地址为空");
  12031. return;
  12032. }
  12033. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12034. if (ceErpTradeCell != null)
  12035. {
  12036. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12037. if (ceErpTrade == null)
  12038. {
  12039. returnErrorMsg("找不到订单");
  12040. return;
  12041. }
  12042. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12043. bool isSend = false;
  12044. if (dt != null && dt.Rows.Count > 0)
  12045. {
  12046. foreach (DataRow row in dt.Rows)
  12047. {
  12048. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12049. {
  12050. isSend = true;
  12051. }
  12052. }
  12053. if (isSend)
  12054. {
  12055. returnErrorMsg("已发货无法修改");
  12056. return;
  12057. }
  12058. ceErpTrade.Attachments = atta;
  12059. ceErpTrade.Update();
  12060. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12061. returnSuccessMsg("上传成功!");
  12062. return;
  12063. }
  12064. }
  12065. }
  12066. returnErrorMsg("找不到订单");
  12067. }
  12068. public void get_tid_attachments()
  12069. {
  12070. string tid = GetPostString("tid");
  12071. if (!string.IsNullOrEmpty(tid))
  12072. {
  12073. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12074. if (ceErpTradeCell != null)
  12075. {
  12076. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12077. if (ceErpTrade == null)
  12078. {
  12079. returnErrorMsg("找不到订单");
  12080. return;
  12081. }
  12082. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12083. return;
  12084. }
  12085. }
  12086. returnErrorMsg("找不到订单");
  12087. }
  12088. public void check_erp_sameorders()
  12089. {
  12090. if (UrlPostParmsCheck("ctid"))
  12091. {
  12092. string eid = GetPostString("ctid");
  12093. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12094. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12095. if (entity != null && ceErpTrade != null)
  12096. {
  12097. if (entity.OrderState > 6)
  12098. {
  12099. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12100. return;
  12101. }
  12102. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12103. List<string> ids = new List<string>();
  12104. if (dt != null && dt.Rows.Count > 1)
  12105. {
  12106. bool needhe = true;
  12107. foreach (DataRow dr in dt.Rows)
  12108. {
  12109. ids.Add("'" + dr["ctid"] + "'");
  12110. /* //备注有合包
  12111. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12112. {
  12113. needhe = true;
  12114. }
  12115. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12116. {
  12117. needhe = true;
  12118. }
  12119. //顺丰快递
  12120. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12121. {
  12122. needhe = true;
  12123. }*/
  12124. }
  12125. if (!needhe)
  12126. {
  12127. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12128. return;
  12129. }
  12130. StringBuilder sql = new StringBuilder();
  12131. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12132. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12133. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12134. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12135. foreach (DataRow dr in dt.Rows)
  12136. {
  12137. dr["dstate"] = 0;
  12138. dr["dnumber"] = 0;
  12139. foreach (DataRow row in dt1.Rows)
  12140. {
  12141. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12142. {
  12143. dr["dstate"] = 2;
  12144. dr["default"] = 1;
  12145. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12146. }
  12147. }
  12148. if (eid.Equals(dr["ctid"].ToString()))
  12149. {
  12150. dr["dstate"] = 1;
  12151. dr["default"] = 1;
  12152. }
  12153. }
  12154. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12155. return;
  12156. }
  12157. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12158. return;
  12159. }
  12160. returnErrorMsg("未找到订单");
  12161. return;
  12162. }
  12163. returnErrorMsg("缺少必要的参数");
  12164. }
  12165. public void get_mark_number()
  12166. {
  12167. string eid = GetPostString("ctid");
  12168. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12169. if (entity != null)
  12170. {
  12171. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12172. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12173. int current = 1;
  12174. if (ceErpDeliverMark == null)
  12175. {
  12176. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12177. List<string> ids = new List<string>();
  12178. if (dt != null && dt.Rows.Count > 1)
  12179. {
  12180. foreach (DataRow dr in dt.Rows)
  12181. {
  12182. ids.Add("'" + dr["ctid"] + "'");
  12183. }
  12184. //查询已有的编号
  12185. StringBuilder sql = new StringBuilder();
  12186. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12187. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12188. if (dt1 == null || dt1.Rows.Count == 0)
  12189. {
  12190. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12191. List<int> list_number = new List<int>();
  12192. foreach (DataRow row in numbers.Rows)
  12193. {
  12194. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12195. }
  12196. //查询空余编号
  12197. for (int i = 0; i < list_number.Count + 2; i++)
  12198. {
  12199. if (!list_number.Contains(current))
  12200. {
  12201. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12202. //防止查询过程中有新数据生成
  12203. if (ceErpDeliverMark1 == null)
  12204. {
  12205. break;
  12206. }
  12207. }
  12208. current++;
  12209. }
  12210. }
  12211. else
  12212. {
  12213. foreach (DataRow row in dt1.Rows)
  12214. {
  12215. current = Convert.ToInt32(row["markNumber"]);
  12216. }
  12217. }
  12218. ceErpDeliverMark = new CeErpDeliverMark();
  12219. ceErpDeliverMark.ctid = eid;
  12220. ceErpDeliverMark.createtime = DateTime.Now;
  12221. if (ceErpTrade != null)
  12222. {
  12223. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12224. }
  12225. ceErpDeliverMark.markNumber = current;
  12226. ceErpDeliverMark.Create();
  12227. }
  12228. }
  12229. else
  12230. {
  12231. current = ceErpDeliverMark.markNumber;
  12232. }
  12233. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12234. return;
  12235. }
  12236. }
  12237. public void aftersaleCytSend()
  12238. {
  12239. string ctid = GetPostString("ctid");
  12240. if (!string.IsNullOrEmpty(ctid))
  12241. {
  12242. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12243. if (ceErpTradeCell != null)
  12244. {
  12245. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12246. }
  12247. returnSuccessMsg("推送成功");
  12248. return;
  12249. }
  12250. returnErrorMsg("缺少必要的参数");
  12251. }
  12252. public void packOrderInfo()
  12253. {
  12254. string ctids = GetPostString("ctids");
  12255. if (!string.IsNullOrEmpty(ctids))
  12256. {
  12257. string[] ctid_list = ctids.Split(',');
  12258. if (ctid_list.Length > 20)
  12259. {
  12260. returnErrorMsg("单次下载次数不能超过20个");
  12261. return;
  12262. }
  12263. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12264. StringBuilder sql = new StringBuilder();
  12265. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12266. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12267. int supplierId = 0;
  12268. StringBuilder insterSql = new StringBuilder();
  12269. for (int i = 0; i < dt.Rows.Count; i++)
  12270. {
  12271. DataRow row = dt.Rows[i];
  12272. if (i == 0)
  12273. {
  12274. supplierId = Convert.ToInt32(row["SupplierId"]);
  12275. }
  12276. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12277. {
  12278. returnErrorMsg("同车间的订单才能一起打包");
  12279. return;
  12280. }
  12281. int orderState = Convert.ToInt32(row["OrderState"]);
  12282. if (orderState != 5)
  12283. {
  12284. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12285. return;
  12286. }
  12287. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12288. }
  12289. CeErpPackData ceErpPackData = new CeErpPackData();
  12290. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12291. ceErpPackData.supplierId = supplierId;
  12292. ceErpPackData.createtime = DateTime.Now;
  12293. ceErpPackData.createBy = CurrentUser.UserID;
  12294. ceErpPackData.createName = CurrentUser.UserName;
  12295. ceErpPackData.Create();
  12296. if (ceErpPackData.ID > 0)
  12297. {
  12298. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12299. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12300. }
  12301. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12302. returnSuccessMsg("打包成功");
  12303. return;
  12304. }
  12305. returnErrorMsg("缺少必要的参数");
  12306. }
  12307. public void rePackOrderInfo()
  12308. {
  12309. string id = GetPostString("id");
  12310. if (!string.IsNullOrEmpty(id))
  12311. {
  12312. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12313. if (ceErpPackData == null)
  12314. {
  12315. returnSuccessMsg("查无数据");
  12316. return;
  12317. }
  12318. ceErpPackData.upStatus = 0;
  12319. ceErpPackData.message = "";
  12320. ceErpPackData.Update();
  12321. returnSuccessMsg("打包成功");
  12322. return;
  12323. }
  12324. returnErrorMsg("缺少必要的参数");
  12325. }
  12326. public void backPackOrderInfo()
  12327. {
  12328. string id = GetPostString("id");
  12329. if (!string.IsNullOrEmpty(id))
  12330. {
  12331. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12332. if (ceErpPackData == null)
  12333. {
  12334. returnSuccessMsg("查无数据");
  12335. return;
  12336. }
  12337. ceErpPackData.upStatus = 4;
  12338. ceErpPackData.Update();
  12339. List<string> list = new List<string>();
  12340. StringBuilder sql = new StringBuilder();
  12341. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12342. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12343. for (int i = 0; i < dt.Rows.Count; i++)
  12344. {
  12345. DataRow row = dt.Rows[i];
  12346. list.Add("'" + row["ctid"].ToString() + "'");
  12347. }
  12348. string textCtids = string.Join(",", list);
  12349. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12350. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12351. returnSuccessMsg("退回成功");
  12352. return;
  12353. }
  12354. returnErrorMsg("缺少必要的参数");
  12355. }
  12356. public void addPackDownNum()
  12357. {
  12358. string id = GetPostString("id");
  12359. if (!string.IsNullOrEmpty(id))
  12360. {
  12361. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12362. returnSuccessMsg("下载成功");
  12363. return;
  12364. }
  12365. returnErrorMsg("缺少必要的参数");
  12366. }
  12367. public void get_pack_list()
  12368. {
  12369. DataStruct dStruct = GetPostStruct();
  12370. List<string> lw = new List<string>();
  12371. string supplier = GetPostString("supplier");
  12372. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12373. string posTag = CurrentUser.UserPost.Post.Code;
  12374. if (posTag == "Supplier")
  12375. {
  12376. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12377. }
  12378. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12379. dStruct.Order = "createtime desc";
  12380. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12381. writeGridDataTableJson(dStruct.TotalCount, dt);
  12382. }
  12383. public void get_pack_order_list()
  12384. {
  12385. string packId = GetPostString("packId");
  12386. if (string.IsNullOrEmpty(packId))
  12387. {
  12388. returnErrorMsg("缺少必要的参数");
  12389. return;
  12390. }
  12391. StringBuilder sql = new StringBuilder();
  12392. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12393. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12394. if (dt == null || dt.Rows.Count == 0)
  12395. {
  12396. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12397. return;
  12398. }
  12399. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12400. return;
  12401. }
  12402. public void get_supplier_product_time_list()
  12403. {
  12404. DataStruct dStruct = GetPostStruct();
  12405. List<string> lw = new List<string>();
  12406. string supplier = GetPostString("supplier");
  12407. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12408. string posTag = CurrentUser.UserPost.Post.Code;
  12409. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12410. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12411. writeGridDataTableJson(dStruct.TotalCount, dt);
  12412. }
  12413. public void saveSupplierProductTime()
  12414. {
  12415. string productId = GetPostString("productId");
  12416. if (string.IsNullOrEmpty(productId))
  12417. {
  12418. returnErrorMsg("缺少必要的参数");
  12419. return;
  12420. }
  12421. string productName = GetPostString("productName");
  12422. int supplierId = GetPostInt("supplierId");
  12423. if (supplierId == 0)
  12424. {
  12425. returnErrorMsg("缺少必要的参数");
  12426. return;
  12427. }
  12428. int quantity = GetPostInt("quantity");
  12429. int sendDay = GetPostInt("sendTime");
  12430. string supplierName = GetPostString("supplierName");
  12431. string craft = GetPostString("craft");
  12432. string deadLine = GetPostString("deadLine");
  12433. string dayDeadLine = GetPostString("dayDeadLine");
  12434. try
  12435. {
  12436. int eid = GetPostInt("eid");
  12437. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12438. if (ceErpSupplierProductTime == null)
  12439. {
  12440. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12441. }
  12442. ceErpSupplierProductTime.productId = productId;
  12443. ceErpSupplierProductTime.productName = productName;
  12444. ceErpSupplierProductTime.supplierId = supplierId;
  12445. ceErpSupplierProductTime.supplierName = supplierName;
  12446. ceErpSupplierProductTime.craft = craft;
  12447. ceErpSupplierProductTime.sendDay = sendDay;
  12448. ceErpSupplierProductTime.quantity = quantity;
  12449. if (!string.IsNullOrEmpty(deadLine))
  12450. {
  12451. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12452. }
  12453. if (!string.IsNullOrEmpty(dayDeadLine))
  12454. {
  12455. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12456. }
  12457. if (ceErpSupplierProductTime.ID == 0)
  12458. {
  12459. ceErpSupplierProductTime.Save();
  12460. }
  12461. else
  12462. {
  12463. ceErpSupplierProductTime.Update();
  12464. }
  12465. }
  12466. catch (Exception e)
  12467. {
  12468. }
  12469. returnSuccessMsg("保存成功");
  12470. return;
  12471. }
  12472. public void delSupplierProductTime()
  12473. {
  12474. int eid = GetPostInt("eid");
  12475. if (eid > 0)
  12476. {
  12477. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12478. if (ceErpSupplierProductTime == null)
  12479. {
  12480. returnErrorMsg("查无数据");
  12481. return;
  12482. }
  12483. ceErpSupplierProductTime.Delete();
  12484. returnSuccessMsg("保存成功");
  12485. return;
  12486. }
  12487. returnErrorMsg("缺少必要的参数");
  12488. }
  12489. public void getExpressInfo()
  12490. {
  12491. string ctid = GetPostString("ctid");
  12492. if (!string.IsNullOrEmpty(ctid))
  12493. {
  12494. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12495. if (ceErpTradeCell != null)
  12496. {
  12497. string outSid = ceErpTradeCell.OutSid;
  12498. if (outSid.Length > 0)
  12499. {
  12500. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12501. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12502. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12503. return;
  12504. }
  12505. }
  12506. returnErrorMsg("查无记录");
  12507. return;
  12508. }
  12509. returnErrorMsg("缺少必要的参数");
  12510. }
  12511. public void getExpressPostData()
  12512. {
  12513. string express = GetPostString("express");
  12514. if (!string.IsNullOrEmpty(express))
  12515. {
  12516. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12517. if (ceErpExpressInfo != null)
  12518. {
  12519. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12520. return;
  12521. }
  12522. }
  12523. returnErrorMsg("缺少必要的参数");
  12524. }
  12525. public void checkSupplierOrder()
  12526. {
  12527. string ctids = GetPostString("ctids");
  12528. if (ctids != null)
  12529. {
  12530. List<string> list = new List<string>();
  12531. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12532. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12533. for (int i = 0; i < dt.Rows.Count; i++)
  12534. {
  12535. DataRow row = dt.Rows[i];
  12536. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12537. {
  12538. continue;
  12539. }
  12540. list.Add(row["seller_memo"].ToString());
  12541. }
  12542. if (list.Count > 0)
  12543. {
  12544. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12545. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12546. return;
  12547. }
  12548. }
  12549. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12550. return;
  12551. }
  12552. public void addPersonId()
  12553. {
  12554. string tid = GetPostString("tid");
  12555. string personId = GetPostString("personId");
  12556. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12557. if (ceErpTrade != null)
  12558. {
  12559. ceErpTrade.receiver_zip = personId;
  12560. ceErpTrade.Update();
  12561. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12562. returnSuccessMsg("保存成功");
  12563. return;
  12564. }
  12565. returnErrorMsg("缺少必要的参数");
  12566. }
  12567. }
  12568. }