sync.order.cs 624 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475
  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. namespace SiteCore.Handler
  48. {
  49. public partial class sync
  50. {
  51. public void get_erp_orderlist()
  52. {
  53. string poscode = CurrentUser.UserPost.Post.Code;
  54. DataStruct dStruct = GetPostStruct();
  55. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\CE_ErpProduct(1).xlsx");
  56. //apiHelper.Api_SyncOrderByTime("598825");
  57. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  58. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  59. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  60. //banniuApiHelper.sendLogisticsInfo(null);
  61. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  62. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  63. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  64. //int sid = commonHelper.autoDistributeToSupplier(entity);
  65. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  66. //tmcHelper.Api_TmcTradeMsg("{\r\n \"content\": {\r\n \"businessType\": \"GUARANTEE\",\r\n \"buyerMemo\": \"\",\r\n \"consolidateType\": \"\",\r\n \"createTime\": 1744882656361,\r\n \"deliveryType\": \"OFFLINE\",\r\n \"discountFee\": 0.0,\r\n \"flag\": \"NONE\",\r\n \"latestDeliveryTime\": 1744882656361,\r\n \"lines\": [\r\n {\r\n \"mark2\": [],\r\n \"num\": 4,\r\n \"outerId\": \"\",\r\n \"payment\": 60.0,\r\n \"picUrl\": \"https://img.alicdn.com/bao/uploaded/i4/2209226402185/O1CN011Zh53V1S0mQKgHJyF_!!4611686018427382153-0-item_pic.jpg\",\r\n \"platServiceFee\": 0.0,\r\n \"price\": 10.0,\r\n \"refOlId\": \"1111122222333338942\",\r\n \"refSkuId\": \"0\",\r\n \"refSpuId\": \"908453435193\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellPrice\": 10.0,\r\n \"singleFee\": 10.0,\r\n \"standards\": \"测试内部\",\r\n \"status\": \"NOT_SHIPPED\",\r\n \"title\": \"【老客户订单2】测试老客户订单内部\",\r\n \"totalFee\": 60.0,\r\n \"totalPrice\": 60.0,\r\n \"totalSellPrice\": 60.0\r\n }\r\n ],\r\n \"logisticsOrderNo\": \"\",\r\n \"mark2\": [],\r\n \"modifyTime\": 1744882656361,\r\n \"openBuyerId\": \"AAG1RHraABkUZRPgSx3g7Eam\",\r\n \"openBuyerNick\": \"0**\",\r\n \"openSellerNick\": \"海角七旗舰店\",\r\n \"orderSource\": \"SYNC\",\r\n \"orderTime\": 1744882656361,\r\n \"payTime\": 1744882656361,\r\n \"payment\": 100.0,\r\n \"platServiceFee\": 0.0,\r\n \"posCode\": \"HJQ\",\r\n \"posId\": 663281,\r\n \"postFee\": 0.0,\r\n \"props\": {\r\n \"payType\": \"ALI_PAY\",\r\n \"govSubsidyAmount\": 0\r\n },\r\n \"receivedPayment\": 0.0,\r\n \"receiverCity\": \"龙岩市\",\r\n \"receiverCountry\": \"中国\",\r\n \"receiverDistrict\": \"新罗区\",\r\n \"receiverId\": \"d1b65912ef886228ac4ada4b65055e52$\",\r\n \"receiverState\": \"福建省\",\r\n \"receiverTown\": \"西陂街道\",\r\n \"refOid\": \"1111122222333338942\",\r\n \"refType\": \"TB\",\r\n \"refundStatus\": \"NO_REFUND\",\r\n \"sellerMemo\": \"\",\r\n \"serviceFee\": 0.0,\r\n \"status\": \"NOT_SHIPPED\",\r\n \"totalFee\": 100.0,\r\n \"totalPrice\": 100.0,\r\n \"totalSellPrice\": 100.0,\r\n \"type\": \"SALE\"\r\n }\r\n}");
  67. //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}}");
  68. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  69. List<string> lw = new List<string>();
  70. string tid = GetPostString("ctid");
  71. string date1 = GetPostString("date1");
  72. //12-1 修改
  73. string urgent = GetPostString("urgent");
  74. string back = GetPostString("back");
  75. string offlineSearch = GetPostString("offlineSearch");
  76. int paramsCount = 0;
  77. if (!string.IsNullOrWhiteSpace(urgent))
  78. {
  79. if (urgent.Equals("true"))
  80. {
  81. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  82. }
  83. }
  84. if (!string.IsNullOrWhiteSpace(back))
  85. {
  86. if (back.Equals("true"))
  87. {
  88. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  89. }
  90. }
  91. if (!string.IsNullOrWhiteSpace(offlineSearch))
  92. {
  93. if (offlineSearch.Equals("true"))
  94. {
  95. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  96. }
  97. }
  98. //end
  99. string date2 = GetPostString("date2");
  100. string buyernick = GetPostString("buyer_nick");
  101. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  102. {
  103. if (tid.Length <= 0 && buyernick.Length <= 0)
  104. {
  105. return;
  106. }
  107. }
  108. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  109. {
  110. if (tid.Length > 0)
  111. {
  112. string select_tid = getTidByCtid(tid);
  113. lw.Add(string.Format("tid='{0}'", select_tid));
  114. }
  115. if (buyernick.Length > 0)
  116. {
  117. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  118. }
  119. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  120. if (dw.Length > 0)
  121. {
  122. lw.Add(dw);
  123. }
  124. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  125. {
  126. string usershop = CurrentUser.User.pemShop;
  127. lw.Add(string.Format("ShopId in ({0})", usershop));
  128. }
  129. }
  130. else
  131. {
  132. if (ex_psize == 0)
  133. {
  134. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  135. }
  136. if (PKey != "admin")
  137. {
  138. string usershop = CurrentUser.User.pemShop;
  139. lw.Add(string.Format("ShopId in ({0})", usershop));
  140. paramsCount++;
  141. }
  142. }
  143. string uploaddate1 = GetPostString("uploaddate1");
  144. string uploaddate2 = GetPostString("uploaddate2");
  145. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  146. if (update.Length > 0) lw.Add(update);
  147. string deliverydate1 = GetPostString("deliverydate1");
  148. string deliverydate2 = GetPostString("deliverydate2");
  149. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  150. if (deliverydate.Length > 0)
  151. {
  152. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  153. };
  154. string shopname = GetPostString("shopname");
  155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  156. string addwechat = GetPostString("addwechat");
  157. if (addwechat.Length > 0)
  158. {
  159. int addWt = Convert.ToInt32(addwechat);
  160. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  161. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  162. }
  163. string customer = GetPostString("customer");
  164. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  165. string design = GetPostString("design");
  166. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  167. string orderState = GetPostString("orderState");
  168. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  169. string address = GetPostString("address");
  170. 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));
  171. string sellermemo = GetPostString("seller_memo");
  172. if (sellermemo.Length > 0)
  173. {
  174. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  175. }
  176. string backReason = GetPostString("backReason");
  177. if (backReason.Length > 0)
  178. {
  179. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  180. }
  181. string apdate1 = GetPostString("apdate1");
  182. string apdate2 = GetPostString("apdate2");
  183. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  184. if (dwap.Length > 0) lw.Add(dwap);
  185. string price1 = GetPostString("price1");
  186. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  187. string price2 = GetPostString("price2");
  188. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  189. string isoldcustomer = GetPostString("isoldcus");
  190. string spudata = GetPostString("spudata");
  191. if ("0".Equals(spudata))
  192. {
  193. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  194. }
  195. if ("1".Equals(spudata))
  196. {
  197. lw.Add(string.Format("spu_id <> ''"));
  198. }
  199. string finishdate1 = GetPostString("finishdate1");
  200. string finishdate2 = GetPostString("finishdate2");
  201. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  202. bool isFinish = false;
  203. if (finishdate.Length > 0)
  204. {
  205. lw.Add(finishdate);
  206. isFinish = true;
  207. paramsCount++;
  208. }
  209. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  210. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  211. if (ex_psize > 0)
  212. {
  213. int UserID = CurrentUser.UserID;
  214. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  215. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  216. {
  217. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  218. }
  219. dStruct.Order = "pay_time desc";
  220. }
  221. string isNew = GetPostString("isNew");
  222. if (isNew == "true")
  223. {
  224. lw.Add(string.Format("IsNew = {0}", 1));
  225. }
  226. string overtime = GetPostString("overtime");
  227. if (overtime == "1")
  228. {
  229. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  230. }
  231. String usePost = CurrentUser.UserPost.Post.Code;
  232. if (usePost.Equals("Operation") == true)
  233. {
  234. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  235. }
  236. else
  237. {
  238. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  239. }
  240. //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";
  241. if (dStruct.PageSize == 100000)
  242. {
  243. dStruct.Order = "";
  244. }
  245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  246. DataTable dt = null;
  247. string tablename = "view_orderlist";
  248. if (isFinish)
  249. {
  250. tablename = "view_orderlist_end";
  251. }
  252. dt = WebCache.GetData(tablename, dStruct);
  253. if (dt != null && dt.Rows.Count > 0)
  254. {
  255. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  256. foreach (DataRow dr in dt.Rows)
  257. {
  258. try
  259. {
  260. if (dr["refund_fees"] != null)
  261. {
  262. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  263. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  264. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  265. if (payment == refund_fees)
  266. {
  267. dr["refund_fees"] = Math.Round(refund_fees, 2);
  268. }
  269. else if (refund_fees == total_fee)
  270. {
  271. dr["refund_fees"] = payment;
  272. }
  273. else
  274. {
  275. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  276. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  277. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  278. }
  279. }
  280. // 对象操作
  281. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  282. ceErpTradeCell.ctid = dr["ctid"].ToString();
  283. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  284. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  285. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  286. if (dStruct.PageSize != 100000)
  287. {
  288. if (dr["DispatchSort"].ToString() == "2")
  289. {
  290. dr["gongchuang"] = 200;
  291. }
  292. else if ("外协".Equals(dr["ToType"].ToString()))
  293. {
  294. dr["gongchuang"] = 200;
  295. }
  296. else if ("内部".Equals(dr["ToType"].ToString()))
  297. {
  298. dr["gongchuang"] = -1;
  299. }
  300. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  301. {
  302. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  303. dr["gongchuang"] = response.code;
  304. }
  305. }
  306. }
  307. catch (NullReferenceException ex)
  308. {
  309. // 处理空引用异常
  310. dr["refund_fees"] = "0.00";
  311. }
  312. }
  313. }
  314. writeGridDataTableJson(dStruct.TotalCount, dt);
  315. }
  316. public void get_erp_orderlist_sumprice()
  317. {
  318. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  319. return;
  320. List<string> lw = new List<string>();
  321. string tid = GetPostString("ctid");
  322. string date1 = GetPostString("date1");
  323. string date2 = GetPostString("date2");
  324. if (tid.Length > 0 || date1.Length > 0)
  325. {
  326. lw.Add(string.Format("ctid like '%{0}%'", tid));
  327. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  328. if (dw.Length > 0) lw.Add(dw);
  329. }
  330. else
  331. {
  332. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  333. }
  334. string shopname = GetPostString("shopname");
  335. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  336. string buyernick = GetPostString("buyer_nick");
  337. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  338. string customer = GetPostString("customer");
  339. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  340. string design = GetPostString("design");
  341. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  342. string orderState = GetPostString("orderState");
  343. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  344. string address = GetPostString("address");
  345. 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));
  346. string sellermemo = GetPostString("seller_memo");
  347. if (sellermemo.Length > 0)
  348. {
  349. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  350. }
  351. string apdate1 = GetPostString("apdate1");
  352. string apdate2 = GetPostString("apdate2");
  353. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  354. if (dwap.Length > 0) lw.Add(dwap);
  355. string price1 = GetPostString("price1");
  356. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  357. string price2 = GetPostString("price2");
  358. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  359. string isoldcustomer = GetPostString("isoldcus");
  360. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  361. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  362. if (PKey != "admin")
  363. {
  364. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  365. lw.Add(string.Format("shopId in ({0})", usershop));
  366. }
  367. //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";
  368. string mainWhere = string.Join(" and ", lw.ToArray());
  369. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  370. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  371. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  372. decimal total = 0;
  373. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  374. {
  375. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  376. }
  377. var res = new
  378. {
  379. data = total
  380. };
  381. string ro_jsond = JsonConvert.SerializeObject(res);
  382. returnSuccess(ro_jsond);
  383. return;
  384. }
  385. public void get_erp_CustomerServiceGather()
  386. {
  387. string userWhere = "", orderWhere = "";
  388. List<string> lw = new List<string>();
  389. string customer = GetPostString("customer");
  390. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  391. string shopname = GetPostString("shopname");
  392. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  393. string date1 = GetPostString("date1");
  394. string date2 = GetPostString("date2");
  395. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  396. if (dw.Length > 0) lw.Add(dw);
  397. orderWhere = string.Join(" and ", lw.ToArray());
  398. 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 " +
  399. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  400. "left join " +
  401. "( " +
  402. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  403. ") as b on a.ID = b.CustomerUserId " +
  404. "left join " +
  405. "( " +
  406. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  407. ") as d on a.ID = d.CustomerUserId " +
  408. "left join " +
  409. "( " +
  410. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  411. ") as e on a.ID = e.CustomerUserId " +
  412. "left join " +
  413. "( " +
  414. " select CustomerUserId, RefundCount, RefundSum from " +
  415. " ( " +
  416. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  417. " from CE_ErpTradeRefund a " +
  418. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  419. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  420. " group by CustomerUserId " +
  421. " ) as a " +
  422. ") as f on a.ID = f.CustomerUserId " +
  423. "where a.PostCode = 'CustomerService'",
  424. userWhere, orderWhere);
  425. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  426. writeGridDataTableJson(dt.Rows.Count, dt);
  427. //writeGridDataTableJson(dt.Rows.Count, dt);
  428. }
  429. //设计汇总
  430. public void get_erp_DesignerGather()
  431. {
  432. string userWhere = "", orderWhere = "";
  433. List<string> lw = new List<string>();
  434. string Designer = GetPostString("designer");
  435. int org = GetPostInt("org");
  436. if (Designer.Length > 0)
  437. {
  438. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  439. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  440. }
  441. else if (org > 0)
  442. {
  443. userWhere = string.Format(" where OrgID ={0}", org);
  444. }
  445. string shopname = GetPostString("shopname");
  446. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  447. string state = GetPostString("state");
  448. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  449. string OrderArea = GetPostString("order_area");
  450. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  451. string date1 = GetPostString("date1");
  452. string date2 = GetPostString("date2");
  453. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  454. if (dw.Length > 0) lw.Add(dw);
  455. string UpDate1 = GetPostString("UpDate1");
  456. string UpDate2 = GetPostString("UpDate2");
  457. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  458. if (dw.Length > 0) lw.Add(dw);
  459. orderWhere = string.Join(" and ", lw.ToArray());
  460. 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 (" +
  461. "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 " +
  462. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  463. "left join " +
  464. "( " +
  465. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  466. ") as b on a.ID = b.DesignUserId " +
  467. "left join " +
  468. "( " +
  469. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  470. ") as d on a.ID = d.DesignUserId " +
  471. "left join " +
  472. "( " +
  473. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  474. ") as e on a.ID = e.DesignUserId " +
  475. "left join " +
  476. "( " +
  477. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  478. ") as g on a.ID = g.DesignUserId " +
  479. "left join " +
  480. "( " +
  481. " select CustomerUserId, RefundCount, RefundSum from " +
  482. " ( " +
  483. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  484. " from CE_ErpTradeRefund a " +
  485. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  486. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  487. " group by CustomerUserId " +
  488. " ) as a " +
  489. ") as f on a.ID = f.CustomerUserId " +
  490. "where a.PostCode = 'Designer') as z",
  491. userWhere, orderWhere);
  492. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  493. writeGridDataTableJson(dt.Rows.Count, dt);
  494. }
  495. //删除tradecell的订单
  496. public void del_erp_cellorder()
  497. {
  498. if (UrlPostParmsCheck("ctid"))
  499. {
  500. string eid = GetPostString("ctid");
  501. CeErpTradeCell.DelByCtid(eid);
  502. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  503. returnSuccessMsg("删除成功");
  504. }
  505. }
  506. public void clear_erp_refundstate()
  507. {
  508. if (UrlPostParmsCheck("ids"))
  509. {
  510. string eids = GetPostString("ids");
  511. string[] ctidList = eids.Split(',');
  512. foreach (string ctid in ctidList)
  513. {
  514. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  515. if (entity != null)
  516. {
  517. entity.IsRefund = 0;
  518. entity.Update();
  519. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  520. }
  521. else
  522. continue;
  523. }
  524. returnSuccessMsg("操作成功");
  525. return;
  526. }
  527. returnErrorMsg("缺少必要参数");
  528. }
  529. public void set_erp_urgency()
  530. {
  531. if (UrlPostParmsCheck("ctid"))
  532. {
  533. string eid = GetPostString("ctid");
  534. CeErpTradeCell entity = null;
  535. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  536. if (entity != null)
  537. {
  538. string utime = GetPostString("urgencytime");
  539. if (utime.Length > 0)
  540. {
  541. entity.UrgencyTime = Convert.ToDateTime(utime);
  542. }
  543. else
  544. {
  545. returnErrorMsg("请选择加急时间");
  546. return;
  547. }
  548. if (entity.OrderState <= 4)
  549. {
  550. //entity.seller_memo = entity.seller_memo + "-加急";
  551. string smemo = entity.seller_memo;
  552. int kindex = smemo.IndexOf(")");
  553. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  554. if (lastoneStr != "-")
  555. {
  556. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  557. }
  558. string prememo = smemo.Substring(0, kindex + 2);
  559. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  560. int lastkindex = lastmemo.IndexOf("(");
  561. DateTime urgtime = Convert.ToDateTime(utime);
  562. string newlastmemo = "";
  563. if (lastkindex == 0)
  564. {
  565. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  566. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  567. }
  568. else
  569. {
  570. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  571. }
  572. entity.seller_memo = prememo + newlastmemo;
  573. }
  574. entity.IsUrgency = true;
  575. entity.UpdateTime = DateTime.Now;
  576. entity.Update();
  577. ApiVo apiVo = new ApiVo();
  578. apiVo.orderNumber = entity.ctid;
  579. apiVo.actionName = "changeDesign";
  580. apiVo.orderRemarks = entity.seller_memo;
  581. apiVo.remarkSign = 3;
  582. designHelper.API_WorkCore(apiVo); //changeDesign
  583. CeErpSukuraData.createInfo(entity.ctid, 7);
  584. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  585. returnSuccessMsg("设置成功!");
  586. return;
  587. }
  588. returnErrorMsg("找不到记录");
  589. }
  590. }
  591. public void set_erp_reset()
  592. {
  593. if (UrlPostParmsCheck("ctid"))
  594. {
  595. string eid = GetPostString("ctid");
  596. CeErpTradeCell entity = null;
  597. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  598. if (entity != null)
  599. {
  600. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  601. {
  602. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  603. {
  604. returnErrorMsg("财务要求已下单已发货无法重置");
  605. return;
  606. }
  607. }
  608. entity.IsUrgency = false;
  609. entity.seller_memo = "";
  610. entity.OtherMemo = "";
  611. entity.OrderState = 0;
  612. entity.IsReturn = 0;
  613. //entity.IsRefund = 0;
  614. entity.MemoOpt = 0;
  615. entity.AfterSaleState = 0;
  616. entity.AfterSaleResponsible = "";
  617. entity.AfterSaleUserId = 0;
  618. entity.IsNeedBill = 0;
  619. entity.CustomerUserId = 0;
  620. entity.DesignUserId = 0;
  621. entity.SupplierId = 0;
  622. entity.PlaceUserId = 0;
  623. entity.ptid = "";
  624. entity.IsSample = 0;
  625. entity.IsXianHuo = 0;
  626. entity.isDianziOrder = 0;
  627. entity.DispatchSort = 0;
  628. entity.FinishPlaceTime = null;
  629. entity.Update();
  630. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  631. if (trade != null)
  632. {
  633. trade.seller_memo = "";
  634. trade.Update();
  635. }
  636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  637. returnSuccessMsg("重置成功!");
  638. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  639. if (desginBill != null)
  640. {
  641. desginBill.isDel = 1;
  642. desginBill.Update();
  643. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  644. }
  645. ApiVo apiVo = new ApiVo();
  646. apiVo.orderNumber = entity.ctid;
  647. apiVo.actionName = "resetDesign";
  648. designHelper.API_WorkCore(apiVo);//resetDesign
  649. return;
  650. }
  651. returnErrorMsg("找不到记录");
  652. }
  653. }
  654. public void save_erp_sellermemo()
  655. {
  656. if (UrlPostParmsCheck("ctid"))
  657. {
  658. string ctid = GetPostString("ctid");
  659. CeErpTradeCell entity = null;
  660. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  661. if (entity != null)
  662. {
  663. string memo = GetPostString("seller_memo");
  664. memo = memo.Replace(" ", "");
  665. if (memo.Contains("补差"))
  666. {
  667. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  668. return;
  669. }
  670. List<string> bitList = new List<string>
  671. {
  672. "\\","/",":","*","?", "\"","<" ,">","|"
  673. };
  674. bool isIn = false;
  675. foreach (string bit in bitList)
  676. {
  677. if (memo.Contains(bit))
  678. {
  679. isIn = true;
  680. }
  681. }
  682. if (isIn)
  683. {
  684. returnErrorMsg("不能使用 一些符合作为文件名");
  685. return;
  686. }
  687. if (entity.seller_memo != memo)
  688. {
  689. if (entity.IsSample == 2)
  690. {
  691. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  692. return;
  693. }
  694. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  695. {
  696. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  697. {
  698. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  699. return;
  700. }
  701. }
  702. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  703. }
  704. commonHelper.getCytPrice(entity);
  705. int memoopt = GetPostInt("MemoOpt");
  706. Boolean ismemoopt = false;
  707. if (memoopt > 0)
  708. {
  709. string stropt = "";
  710. if (memoopt == 1)
  711. {
  712. stropt = "“改稿”";
  713. ismemoopt = true;
  714. }
  715. else if (memoopt == 2)
  716. {
  717. stropt = "“定稿”";
  718. }
  719. else if (memoopt == 3)
  720. {
  721. stropt = "“查货”";
  722. CeErpSukuraData.createInfo(entity.ctid, 6);
  723. }
  724. entity.MemoOpt = Convert.ToInt32(memoopt);
  725. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  726. }
  727. if (entity.OrderState < 5)
  728. {
  729. memo = memo.Replace("(", "(");
  730. memo = memo.Replace(")", ")");
  731. }
  732. if (entity.OrderState < 3)
  733. {
  734. entity.DispatchSort = 0;
  735. }
  736. entity.seller_memo = memo;
  737. entity.UpdateTime = DateTime.Now;
  738. entity.Update();
  739. ApiVo apiVo = new ApiVo();
  740. apiVo.orderNumber = entity.ctid;
  741. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  742. apiVo.orderRemarks = memo;
  743. apiVo.remarkSign = memoopt;
  744. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  745. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  746. returnSuccessMsg("保存成功!");
  747. return;
  748. }
  749. returnErrorMsg("找不到记录");
  750. }
  751. }
  752. public void ins_erp_checkorder()
  753. {
  754. if (UrlPostParmsCheck("ctid"))
  755. {
  756. string ctid = GetPostString("ctid");
  757. CeErpTradeCell entity = null;
  758. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  759. if (entity != null)
  760. {
  761. if (entity.OrderState < 6)
  762. {
  763. returnErrorMsg("下单完成后才可查货");
  764. return;
  765. }
  766. /*if (entity.OrderState > 6)
  767. {
  768. returnErrorMsg("订单已发货");
  769. return;
  770. }*/
  771. if (entity.FinishPlaceTime != null)
  772. {
  773. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  774. {
  775. returnErrorMsg("下单时间不足,无法查货");
  776. return;
  777. }
  778. }
  779. entity.MemoOpt = 3;
  780. entity.CheckOrderTime = DateTime.Now;
  781. entity.UpdateTime = DateTime.Now;
  782. entity.Update();
  783. CeErpSukuraData.createInfo(entity.ctid, 6);
  784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  785. returnSuccessMsg("操作成功!");
  786. return;
  787. }
  788. returnErrorMsg("找不到记录");
  789. }
  790. }
  791. public void save_erp_othermemo()
  792. {
  793. if (UrlPostParmsCheck("ctid"))
  794. {
  795. string ctid = GetPostString("ctid");
  796. CeErpTradeCell entity = null;
  797. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  798. if (entity != null)
  799. {
  800. entity.OtherMemo = GetPostString("otherMemo");
  801. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  802. {
  803. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  804. StringBuilder sql = new StringBuilder();
  805. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  806. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  807. if (dt != null && dt.Rows.Count > 0)
  808. {
  809. foreach (DataRow dr in dt.Rows)
  810. {
  811. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  812. {
  813. //品类一直
  814. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  815. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  816. if (ceErpSampleCustomer == null)
  817. {
  818. ceErpSampleCustomer = new CeErpSampleCustomer();
  819. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  820. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  821. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  822. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  823. ceErpSampleCustomer.shopId = entity.ShopId;
  824. }
  825. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  826. ceErpSampleCustomer.lastTid = entity.tid;
  827. if (ceErpSampleCustomer.ID > 0)
  828. {
  829. ceErpSampleCustomer.Update();
  830. }
  831. else
  832. {
  833. ceErpSampleCustomer.Create();
  834. }
  835. }
  836. }
  837. }
  838. }
  839. //if (entity.IsOldCustomer == 1)
  840. //{
  841. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  842. //{
  843. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  844. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  845. //}
  846. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  847. //{
  848. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  849. // {
  850. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  851. // {
  852. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  853. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  854. // }
  855. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  856. // {
  857. // entity.OrderState = 2;
  858. // entity.DesignUserId = 0;
  859. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  860. // }
  861. // else
  862. // {
  863. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  864. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  865. // }
  866. // }
  867. //}
  868. //}
  869. entity.UpdateTime = DateTime.Now;
  870. entity.Update();
  871. returnSuccessMsg("保存成功!");
  872. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  873. return;
  874. }
  875. returnErrorMsg("找不到记录");
  876. }
  877. }
  878. public void save_erp_customermemo()
  879. {
  880. if (UrlPostParmsCheck("ctid"))
  881. {
  882. string ctid = GetPostString("ctid");
  883. CeErpTradeCell entity = null;
  884. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  885. if (entity != null)
  886. {
  887. entity.UpdateTime = DateTime.Now;
  888. entity.CustomerMemo = GetPostString("CustomerMemo");
  889. entity.Update();
  890. ApiVo apiVo = new ApiVo();
  891. apiVo.orderNumber = entity.ctid;
  892. apiVo.actionName = "followRemarks";
  893. apiVo.orderRemarks = entity.CustomerMemo;
  894. designHelper.API_WorkCore(apiVo);//followRemarks
  895. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  896. returnSuccessMsg("保存成功!");
  897. return;
  898. }
  899. returnErrorMsg("找不到记录");
  900. }
  901. }
  902. public void upd_erp_addmemotag()
  903. {
  904. if (UrlPostParmsCheck("ctid"))
  905. {
  906. ;
  907. string eid = GetPostString("ctid");
  908. string sfTagstr = GetPostString("memotag");
  909. CeErpTradeCell entity = null;
  910. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  911. if (entity != null)
  912. {
  913. ApiVo apiVo = new ApiVo();
  914. if (entity.OrderState == 0)
  915. {
  916. returnErrorMsg("请先领单");
  917. return;
  918. }
  919. //撤销顺丰
  920. if (sfTagstr == "撤销顺丰")
  921. {
  922. entity.IsSF = 0;
  923. string reMsg = "";
  924. string oldmemo = entity.seller_memo;
  925. if (entity.OrderState < 5)
  926. {
  927. oldmemo = oldmemo.Replace("顺丰到付", "");
  928. oldmemo = oldmemo.Replace("顺丰寄付", "");
  929. entity.seller_memo = oldmemo;
  930. }
  931. else
  932. {
  933. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  934. {
  935. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  936. }
  937. }
  938. entity.Update();
  939. apiVo.orderNumber = entity.ctid;
  940. apiVo.actionName = "orderRemarks";
  941. apiVo.orderRemarks = entity.seller_memo;
  942. apiVo.isSf = entity.IsSF.ToString();
  943. designHelper.API_WorkCore(apiVo);//orderRemarks
  944. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  945. returnSuccessMsg("撤销成功!" + reMsg);
  946. return;
  947. }
  948. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  949. {
  950. //string oldmemo = entity.seller_memo;
  951. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  952. string sfStr = GetPostString("memotag");
  953. string smemo = entity.seller_memo;
  954. int kindex = smemo.IndexOf(")");
  955. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  956. if (lastoneStr != "-")
  957. {
  958. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  959. }
  960. string prememo = smemo.Substring(0, kindex + 2);
  961. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  962. int lastkindex = lastmemo.IndexOf("(");
  963. string newlastmemo = "";
  964. if (lastkindex == 0)
  965. {
  966. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  967. newlastmemo = "(" + sfStr + "." + useLastmemo;
  968. }
  969. else
  970. {
  971. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  972. }
  973. entity.seller_memo = prememo + newlastmemo;
  974. }
  975. string sfTagMSg = "";
  976. if (sfTagstr == "顺丰寄付")
  977. {
  978. entity.IsSF = 1;
  979. sfTagMSg = "顺丰寄付";
  980. }
  981. else if (sfTagstr == "顺丰到付")
  982. {
  983. entity.IsSF = 2;
  984. sfTagMSg = "顺丰到付";
  985. }
  986. entity.Update();
  987. apiVo = new ApiVo();
  988. apiVo.orderNumber = entity.ctid;
  989. apiVo.actionName = "orderRemarks";
  990. apiVo.orderRemarks = entity.seller_memo;
  991. apiVo.isSf = entity.IsSF.ToString();
  992. designHelper.API_WorkCore(apiVo);//orderRemarks
  993. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  994. returnSuccessMsg("标记成功!");
  995. return;
  996. }
  997. returnErrorMsg("找不到记录");
  998. }
  999. }
  1000. public void upd_erp_ordertag()
  1001. {
  1002. if (UrlPostParmsCheck("ctid"))
  1003. {
  1004. string eid = GetPostString("ctid");
  1005. CeErpTradeCell entity = null;
  1006. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1007. if (entity != null)
  1008. {
  1009. int tag = GetPostInt("wechattag");
  1010. //if(tag==4 && entity.IsSample == 2)
  1011. //{
  1012. // returnErrorMsg("补差价单不能标记微信单");
  1013. // return;
  1014. //}
  1015. entity.wechatTag = tag;
  1016. entity.Update();
  1017. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1018. if (tag == 1)
  1019. {
  1020. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1021. if (cash == null)
  1022. {
  1023. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1024. cash = new CeErpReturnCash();
  1025. cash.tid = entity.tid;
  1026. cash.seller_nick = main.seller_nick;
  1027. cash.payment = trade.payment;
  1028. cash.buyer_nick = main.buyer_nick;
  1029. cash.cashstate = 0;
  1030. cash.rtype = "微信返现";
  1031. cash.returnprice = 0;
  1032. cash.created = DateTime.Now;
  1033. cash.con = "订单标记微信单";
  1034. cash.img = "";
  1035. cash.applyuserid = CurrentUser.UserID;
  1036. cash.Create();
  1037. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1038. }
  1039. else
  1040. {
  1041. cash.cashstate = 0;
  1042. cash.Update();
  1043. }
  1044. CeErpSukuraData.createInfo(entity.ctid, 9);
  1045. }
  1046. else if (tag == 2)
  1047. {
  1048. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1049. if (cash == null)
  1050. {
  1051. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1052. cash = new CeErpReturnCash();
  1053. cash.tid = entity.tid;
  1054. cash.seller_nick = main.seller_nick;
  1055. cash.payment = trade.payment;
  1056. cash.buyer_nick = main.buyer_nick;
  1057. cash.cashstate = 0;
  1058. cash.rtype = "推购返现";
  1059. cash.returnprice = 5;
  1060. cash.created = DateTime.Now;
  1061. cash.con = "订单标记推购单";
  1062. cash.img = "";
  1063. cash.applyuserid = CurrentUser.UserID;
  1064. cash.Create();
  1065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1066. }
  1067. else
  1068. {
  1069. cash.cashstate = 0;
  1070. cash.Update();
  1071. }
  1072. CeErpSukuraData.createInfo(entity.ctid, 9);
  1073. }
  1074. else if (tag == 3)
  1075. {
  1076. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1077. if (pers == null)
  1078. {
  1079. pers = new CeErpPersuade();
  1080. pers.ctid = entity.ctid;
  1081. pers.pstate = 0;
  1082. pers.created = DateTime.Now;
  1083. pers.applyuserid = CurrentUser.UserID;
  1084. pers.Create();
  1085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1086. }
  1087. else
  1088. {
  1089. pers.pstate = 0;
  1090. pers.Update();
  1091. }
  1092. }
  1093. else if (tag == 4 || tag == 5)
  1094. {
  1095. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1096. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1097. if (pers == null)
  1098. {
  1099. pers = new CeErpStayGoods();
  1100. pers.t_id = entity.tid;
  1101. pers.status = "待审核";
  1102. pers.audit_type = 0;
  1103. if (tag == 4)
  1104. {
  1105. pers.stay_type = "微信推购";
  1106. }
  1107. else
  1108. {
  1109. pers.stay_type = "旺旺推购";
  1110. }
  1111. if (entity.IsXianHuo == 0)
  1112. {
  1113. pers.product_id = entity.ProductId;
  1114. }
  1115. pers.wangwang = main.buyer_nick;
  1116. pers.shop_name = main.seller_nick;
  1117. pers.creata_time = DateTime.Now;
  1118. pers.create_u_id = CurrentUser.UserID;
  1119. pers.create_u_name = CurrentUser.UserName;
  1120. pers.Create();
  1121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1122. }
  1123. else
  1124. {
  1125. pers.audit_type = 0;
  1126. pers.Update();
  1127. }
  1128. CeErpSukuraData.createInfo(entity.ctid, 10);
  1129. }
  1130. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1131. returnSuccessMsg("标记成功!");
  1132. return;
  1133. }
  1134. returnErrorMsg("找不到记录");
  1135. }
  1136. }
  1137. public void upd_erp_ordertag_cancel()
  1138. {
  1139. if (UrlPostParmsCheck("ctid"))
  1140. {
  1141. string eid = GetPostString("ctid");
  1142. CeErpTradeCell entity = null;
  1143. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1144. if (entity != null)
  1145. {
  1146. entity.wechatTag = 0;
  1147. entity.Update();
  1148. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1149. if (pers != null)
  1150. {
  1151. pers.status = "取消推购";
  1152. pers.audit_type = 3;
  1153. pers.Update();
  1154. }
  1155. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1156. returnSuccessMsg("标记成功!");
  1157. return;
  1158. }
  1159. returnErrorMsg("找不到记录");
  1160. }
  1161. }
  1162. public void upd_erp_addweichattag()
  1163. {
  1164. if (UrlPostParmsCheck("ctid"))
  1165. {
  1166. ;
  1167. string eid = GetPostString("ctid");
  1168. CeErpTradeCell entity = null;
  1169. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1170. if (entity != null)
  1171. {
  1172. if (entity.IsAddWechat > 0)
  1173. {
  1174. returnErrorMsg("此单已经标记过了");
  1175. return;
  1176. }
  1177. 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);
  1178. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1179. if (dt.Rows.Count > 0)
  1180. {
  1181. entity.IsAddWechat = 2;
  1182. }
  1183. else
  1184. {
  1185. entity.IsAddWechat = 1;
  1186. }
  1187. entity.Update();
  1188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1189. returnSuccessMsg("标记成功!");
  1190. return;
  1191. }
  1192. returnErrorMsg("找不到记录");
  1193. }
  1194. }
  1195. public void upd_erp_getmyorder()
  1196. {
  1197. if (UrlPostParmsCheck("ctid"))
  1198. {
  1199. ;
  1200. string eid = GetPostString("ctid");
  1201. CeErpTradeCell entity = null;
  1202. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1203. if (entity != null)
  1204. {
  1205. if (entity.ctid.IndexOf("C") != -1)
  1206. {
  1207. StringBuilder sql = new StringBuilder();
  1208. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1209. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1210. if (dt.Rows.Count > 0)
  1211. {
  1212. decimal total = 0;
  1213. foreach (DataRow dr in dt.Rows)
  1214. {
  1215. total += Convert.ToDecimal(dr["payment"]);
  1216. }
  1217. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1218. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1219. {
  1220. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1221. return;
  1222. }
  1223. }
  1224. }
  1225. if (entity.OrderState == -1)
  1226. {
  1227. returnErrorMsg("待审核订单无法领取!");
  1228. return;
  1229. }
  1230. entity.CustomerUserId = CurrentUser.UserID;
  1231. if (entity.OrderState < 2)
  1232. {
  1233. entity.OrderState = 2;
  1234. if (entity.ShopId != 0)
  1235. {
  1236. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1237. }
  1238. }
  1239. entity.UpdateTime = DateTime.Now;
  1240. entity.Update();
  1241. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1242. returnSuccessMsg("领单成功!");
  1243. return;
  1244. }
  1245. returnErrorMsg("找不到记录");
  1246. }
  1247. }
  1248. public void getmyorder_from_init()
  1249. {
  1250. if (UrlPostParmsCheck("ctid"))
  1251. {
  1252. string eid = GetPostString("ctid");
  1253. CeErpTradeCell entity = null;
  1254. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1255. if (entity != null)
  1256. {
  1257. string sellerMemo = GetPostString("sellerMemo");
  1258. if (sellerMemo.Length > 0)
  1259. {
  1260. entity.seller_memo = sellerMemo;
  1261. }
  1262. string oterhMemo = GetPostString("otherMemo");
  1263. if (oterhMemo.Length > 0)
  1264. {
  1265. entity.OtherMemo = oterhMemo;
  1266. }
  1267. int urg = GetPostInt("urgency");
  1268. entity.IsUrgency = (urg == 1 ? true : false);
  1269. int wechat = GetPostInt("wechat");
  1270. int command = GetPostInt("command");
  1271. if (wechat == 1)
  1272. {
  1273. entity.wechatTag = 1;
  1274. }
  1275. if (command == 1)
  1276. {
  1277. entity.wechatTag = 2;
  1278. }
  1279. string pPro = GetPostString("pprofession");
  1280. if (pPro.Length > 0)
  1281. {
  1282. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1283. string spro = GetPostString("profession");
  1284. if (spro.Length > 0)
  1285. {
  1286. entity.ProfessionId = Convert.ToInt32(spro);
  1287. }
  1288. }
  1289. string proId = GetPostString("productId");
  1290. if (proId.Length > 0)
  1291. {
  1292. entity.ProductId = Convert.ToInt32(proId);
  1293. }
  1294. entity.Material = GetPostString("material");
  1295. entity.Craft = GetPostString("craft");
  1296. entity.CustomerUserId = CurrentUser.UserID;
  1297. if (entity.OrderState < 2)
  1298. {
  1299. entity.OrderState = 2;
  1300. if (entity.ShopId != 0)
  1301. {
  1302. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1303. }
  1304. }
  1305. entity.Update();
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1307. returnSuccessMsg("领单成功!");
  1308. return;
  1309. }
  1310. returnErrorMsg("找不到记录");
  1311. }
  1312. }
  1313. public void upd_erp_setrelationorder()
  1314. {
  1315. if (UrlPostParmsCheck("ctid"))
  1316. {
  1317. ;
  1318. string eid = GetPostString("ctid");
  1319. string ftid = GetPostString("ftid");
  1320. CeErpTradeCell entity = null;
  1321. CeErpTradeCell fentity = null;
  1322. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1323. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1324. if (fentity == null)
  1325. {
  1326. returnErrorMsg("找不到关联的主订单");
  1327. return;
  1328. }
  1329. if (entity != null)
  1330. {
  1331. if (entity.OrderState >= 5)
  1332. {
  1333. returnErrorMsg("本单已经设计完成无法关联");
  1334. return;
  1335. }
  1336. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1337. {
  1338. returnErrorMsg("线下单续审核后才能关联!");
  1339. return;
  1340. }
  1341. entity.ptid = ftid;
  1342. entity.OrderState = fentity.OrderState;
  1343. //entity.status = fentity.status;
  1344. entity.CustomerUserId = fentity.CustomerUserId;
  1345. entity.DesignUserId = fentity.DesignUserId;
  1346. entity.seller_memo = "补差价单:" + ftid;
  1347. entity.IsSample = 2;
  1348. entity.Update();
  1349. ApiVo apiVo = new ApiVo();
  1350. apiVo.orderNumber = ftid;
  1351. apiVo.payment = entity.payment;
  1352. apiVo.actionName = "repairDesign";
  1353. designHelper.API_WorkCore(apiVo);//repairDesign
  1354. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1355. returnSuccessMsg("关联成功!");
  1356. return;
  1357. }
  1358. else
  1359. returnErrorMsg("找不到记录");
  1360. }
  1361. }
  1362. public void download_erp_neworder()
  1363. {
  1364. string seller = GetPostString("seller_nick");
  1365. string tid = GetPostString("tid");
  1366. if (seller.Length <= 0 || tid.Length <= 0)
  1367. {
  1368. returnErrorMsg("数据错误");
  1369. }
  1370. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1371. //{
  1372. // returnErrorMsg("找不到店铺Sessionkey");
  1373. //}
  1374. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1375. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1376. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1377. if (res.IndexOf("refOid") == -1)
  1378. {
  1379. returnErrorMsg("下载订单数据失败");
  1380. return;
  1381. }
  1382. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1383. returnSuccessMsg("下载完成");
  1384. //tmcHelper.createNewOrder(res);
  1385. //CeErpTrade entr = null;
  1386. //entr = CeErpTrade.Get(tid);
  1387. //if (entr != null)
  1388. //{
  1389. // returnSuccess("下载成功");
  1390. // //下载成功之后,Cell表生成对应的订单;
  1391. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1392. //}
  1393. //else
  1394. //{
  1395. // returnErrorMsg("下载失败或者创建订单失败");
  1396. //}
  1397. }
  1398. public void set_erp_atersale()
  1399. {
  1400. if (UrlPostParmsCheck("ctid"))
  1401. {
  1402. string eid = GetPostString("ctid");
  1403. string reason = GetPostString("AfterSaleReason");
  1404. CeErpTradeCell entity = null;
  1405. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1406. if (entity != null)
  1407. {
  1408. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1409. {
  1410. returnErrorMsg("此订单已经在售后");
  1411. return;
  1412. }
  1413. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1414. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1415. entity.AfterSaleTime = DateTime.Now;
  1416. entity.Update();
  1417. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1418. returnSuccessMsg("转售后成功!");
  1419. return;
  1420. }
  1421. returnErrorMsg("找不到记录");
  1422. }
  1423. }
  1424. public void set_erp_withdraw()
  1425. {
  1426. if (UrlPostParmsCheck("ctid"))
  1427. {
  1428. try
  1429. {
  1430. string eid = GetPostString("ctid");//商品id
  1431. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1432. CeWithdraw ceWithdrawSelect = null;
  1433. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1434. if (ceWithdrawSelect != null)
  1435. {
  1436. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1437. {
  1438. ceWithdrawSelect.status = -1;
  1439. ceWithdrawSelect.Update();
  1440. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1441. returnSuccessMsg("重新发起审核成功");
  1442. return;
  1443. }
  1444. else
  1445. {
  1446. returnSuccessMsg("请勿重复申请!");
  1447. return;
  1448. }
  1449. }
  1450. else
  1451. {
  1452. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1453. if (string.IsNullOrEmpty(CustomerUserId))
  1454. {
  1455. CustomerUserId = "-1";
  1456. }
  1457. int Userid = CurrentUser.UserID;//用户id
  1458. CeWithdraw ceWithdraw = new CeWithdraw();
  1459. ceWithdraw.tid = eid;
  1460. ceWithdraw.userid = Userid;
  1461. ceWithdraw.providerid = CustomerUserId;
  1462. ceWithdraw.status = 3;
  1463. ceWithdraw.creationtime = DateTime.Now;
  1464. ceWithdraw.Create();
  1465. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1466. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1467. return;
  1468. }
  1469. }
  1470. catch
  1471. {
  1472. returnErrorMsg("申请撤回订单失败");
  1473. return;
  1474. }
  1475. }
  1476. }
  1477. public void ins_erp_billinfo()
  1478. {
  1479. if (UrlPostParmsCheck("ctid"))
  1480. {
  1481. string eid = GetPostString("ctid");
  1482. CeErpTradeCell entity = null;
  1483. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1484. if (entity != null)
  1485. {
  1486. CeErpBill bill = CeErpBill.GetByTid(eid);
  1487. bool isHave = false;
  1488. if (bill != null)
  1489. {
  1490. isHave = true;
  1491. if (bill.state != 4)
  1492. {
  1493. returnErrorMsg("此单已经申请过发票了");
  1494. return;
  1495. }
  1496. }
  1497. if (entity.IsNeedBill == 0)
  1498. {
  1499. entity.IsNeedBill = 1;
  1500. }
  1501. entity.Update();
  1502. string errjson = "";
  1503. try
  1504. {
  1505. CeErpBill bill_entity = new CeErpBill();
  1506. bill_entity.tid = entity.tid;
  1507. bill_entity.title = GetPostString("title");
  1508. string taxstr = GetPostString("tax");
  1509. taxstr = taxstr.Replace(" ", "");
  1510. bill_entity.tax = taxstr;
  1511. bill_entity.bank = GetPostString("bank");
  1512. string bankacstr = GetPostString("bankac");
  1513. bankacstr = bankacstr.Replace(" ", "");
  1514. bill_entity.bankac = bankacstr;
  1515. bill_entity.address = GetPostString("address");
  1516. bill_entity.phone = GetPostString("phone");
  1517. bill_entity.price = GetPostString("price");
  1518. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1519. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1520. {
  1521. billCount += 1;
  1522. }
  1523. string prebill = "ltb";
  1524. for (int idx = 1; idx <= billCount; idx++)
  1525. {
  1526. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1527. string billoid = prebill + idx + dtstr;
  1528. bill_entity.billOrderId += billoid;
  1529. if (idx < billCount)
  1530. {
  1531. bill_entity.billOrderId += ",";
  1532. }
  1533. }
  1534. bill_entity.productId = GetPostInt("ProductName");
  1535. bill_entity.num = GetPostInt("num");
  1536. bill_entity.unit = GetPostString("unit");
  1537. bill_entity.type = GetPostString("type");
  1538. bill_entity.sendType = GetPostString("SendType");
  1539. bill_entity.email = GetPostString("email");
  1540. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1541. bill_entity.shopName = GetPostString("ShopName");
  1542. bill_entity.applymemo = GetPostString("applyMemo");
  1543. bill_entity.createTime = DateTime.Now;
  1544. bill_entity.state = 0;
  1545. bill_entity.userId = CurrentUser.UserID;
  1546. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1547. bill_entity.Create();
  1548. }
  1549. catch (Exception ex)
  1550. {
  1551. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1552. returnErrorMsg("创建发票出错!");
  1553. return;
  1554. }
  1555. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1556. returnSuccessMsg("发票申请成功!");
  1557. return;
  1558. }
  1559. returnErrorMsg("找不到记录");
  1560. }
  1561. }
  1562. public void ins_erp_neworder()
  1563. {
  1564. if (UrlPostParmsCheck("receiver_name"))
  1565. {
  1566. CeErpTrade entity = new CeErpTrade();
  1567. string plat_form = GetPostString("platform");
  1568. string preStr = "N_";
  1569. if (plat_form == "拼多多")
  1570. {
  1571. preStr = "P_";
  1572. }
  1573. else if (plat_form == "阿里巴巴")
  1574. {
  1575. preStr = "A_";
  1576. }
  1577. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1578. entity.seller_nick = GetPostString("seller_nick");
  1579. entity.buyer_nick = GetPostString("buyer_nick");
  1580. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1581. entity.total_fee = entity.payment;
  1582. entity.pay_time = DateTime.Now;
  1583. entity.status = "NOT_SHIPPED";
  1584. entity.receiver_name = GetPostString("receiver_name");
  1585. entity.receiver_mobile = GetPostString("receiver_mobile");
  1586. entity.receiver_state = GetPostString("receiver_state");
  1587. entity.receiver_city = GetPostString("receiver_city");
  1588. entity.receiver_district = GetPostString("receiver_district");
  1589. entity.receiver_address = GetPostString("receiver_address");
  1590. if (entity.receiver_state == "" || entity.receiver_city == "")
  1591. {
  1592. returnErrorMsg("收件地址不能为空");
  1593. return;
  1594. }
  1595. int shopId = 0;
  1596. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1597. if (nShop != null)
  1598. {
  1599. shopId = nShop.ID;
  1600. }
  1601. if (shopId != 34 && entity.payment == 0)
  1602. {
  1603. returnErrorMsg("公司自用的单金额才能为0");
  1604. return;
  1605. }
  1606. entity.Create();
  1607. CeErpTradeCell entitycell = new CeErpTradeCell();
  1608. entitycell.ctid = entity.tid;
  1609. entitycell.tid = entity.tid;
  1610. entitycell.ShopId = shopId;
  1611. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1612. entitycell.OrderState = 0;
  1613. entitycell.pay_time = entity.pay_time;
  1614. entitycell.IsOffLineOrder = 1;
  1615. entitycell.Create();
  1616. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1617. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1618. return;
  1619. }
  1620. }
  1621. public void ins_erp_neworder2()
  1622. {
  1623. if (UrlPostParmsCheck("receiver_name"))
  1624. {
  1625. //string plat_form = GetPostString("platform");
  1626. string preStr = "X_";
  1627. string memo = GetPostString("memo");
  1628. string productId = GetPostString("productId");
  1629. string primg = GetPostString("proofimg");
  1630. string sellerNick = GetPostString("seller_nick");
  1631. string addFrom = GetPostString("addfrom");
  1632. if (addFrom == "1")
  1633. {
  1634. preStr = "N_";
  1635. }
  1636. int shopId = 0;
  1637. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1638. if (nShop != null)
  1639. {
  1640. shopId = nShop.ID;
  1641. }
  1642. else
  1643. {
  1644. returnErrorMsg("找不到对应店铺");
  1645. return;
  1646. }
  1647. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1648. {
  1649. returnErrorMsg("必须上传付款凭证");
  1650. return;
  1651. }
  1652. CeErpTrade entity = new CeErpTrade();
  1653. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1654. entity.seller_nick = sellerNick;
  1655. entity.buyer_nick = GetPostString("buyer_nick");
  1656. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1657. entity.total_fee = entity.payment;
  1658. entity.pay_time = DateTime.Now;
  1659. entity.status = "NOT_SHIPPED";
  1660. entity.receiver_name = GetPostString("receiver_name");
  1661. entity.receiver_mobile = GetPostString("receiver_mobile");
  1662. entity.receiver_state = GetPostString("receiver_state");
  1663. entity.receiver_city = GetPostString("receiver_city");
  1664. entity.receiver_district = GetPostString("receiver_district");
  1665. entity.receiver_address = GetPostString("receiver_address");
  1666. entity.seller_memo = memo;
  1667. entity.orderFrom = 20;
  1668. entity.orderType = 15;
  1669. if (entity.receiver_state == "" || entity.receiver_city == "")
  1670. {
  1671. returnErrorMsg("收件地址不能为空");
  1672. return;
  1673. }
  1674. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1675. {
  1676. returnErrorMsg("公司自用的单金额才能为0");
  1677. return;
  1678. }
  1679. entity.Create();
  1680. string toWhere = GetPostString("towhere");
  1681. CeErpTradeCell entitycell = new CeErpTradeCell();
  1682. entitycell.ctid = entity.tid;
  1683. //唯一标识
  1684. entitycell.OrderSn = entity.tid;
  1685. string orderSn = dataHelper.getSaleOrderSn();
  1686. if (orderSn != "")
  1687. {
  1688. entitycell.OrderSn = orderSn;
  1689. }
  1690. entitycell.tid = entity.tid;
  1691. //if (preStr == "X_")
  1692. //{
  1693. entitycell.IsOffLineOrder = 1;
  1694. //}
  1695. entitycell.CustomerUserId = CurrentUser.UserID;
  1696. entitycell.PayProofImg = primg;
  1697. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1698. entitycell.ProductId = Convert.ToInt32(productId);
  1699. entitycell.ShopId = shopId;
  1700. entitycell.UpdateTime = DateTime.Now;
  1701. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1702. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1703. {
  1704. entitycell.IsXianHuo = 1;
  1705. }
  1706. entitycell.pay_time = entity.pay_time;
  1707. if (toWhere == "1")
  1708. {
  1709. entitycell.OrderState = 2;
  1710. }
  1711. else
  1712. {
  1713. entitycell.OrderState = 6;
  1714. entitycell.FinishPlaceTime = entitycell.pay_time;
  1715. }
  1716. if (shopId == 94)
  1717. {
  1718. entitycell.OrderState = 4;
  1719. entitycell.WaitDesignTime = entitycell.pay_time;
  1720. entitycell.StartDesignTime = entitycell.pay_time;
  1721. entitycell.DesignUserId = 218;
  1722. }
  1723. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1724. {
  1725. entitycell.OrderState = -1;//修改12-5
  1726. CeWithdraw ceWithdraw = new CeWithdraw();
  1727. ceWithdraw.tid = entity.tid;
  1728. ceWithdraw.providerid = "-1";
  1729. ceWithdraw.status = -1;
  1730. ceWithdraw.creationtime = DateTime.Now;
  1731. ceWithdraw.userid = 1337;
  1732. ceWithdraw.Create();
  1733. }
  1734. entitycell.Create();
  1735. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1736. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1737. {
  1738. addPlaceRegist(entitycell, CurrentUser.UserID);
  1739. }
  1740. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1741. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1742. return;
  1743. }
  1744. }
  1745. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1746. {
  1747. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1748. entity.PlactTime = tradecell.pay_time;
  1749. entity.AddUserId = userid;
  1750. entity.FileName = tradecell.seller_memo;
  1751. entity.Supplier = 24;
  1752. entity.CreateTime = DateTime.Now;
  1753. entity.Did = tradecell.ctid;
  1754. entity.tid = tradecell.tid;
  1755. entity.splitTag = tradecell.SplitTag;
  1756. entity.CurState = "未完成";
  1757. entity.Create();
  1758. }
  1759. public void get_erp_offlinelist()
  1760. {
  1761. DataStruct dStruct = GetPostStruct();
  1762. List<string> lw = new List<string>();
  1763. string tid = GetPostString("ctid");
  1764. string date1 = GetPostString("date1");
  1765. string date2 = GetPostString("date2");
  1766. if (tid.Length > 0 || date1.Length > 0)
  1767. {
  1768. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1769. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1770. if (dw.Length > 0) lw.Add(dw);
  1771. }
  1772. else
  1773. {
  1774. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1775. }
  1776. string shopname = GetPostString("shopname");
  1777. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1778. string buyernick = GetPostString("buyer_nick");
  1779. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1780. string customer = GetPostString("customer");
  1781. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1782. string design = GetPostString("design");
  1783. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1784. string orderState = GetPostString("orderState");
  1785. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1786. string address = GetPostString("address");
  1787. 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));
  1788. string sellermemo = GetPostString("seller_memo");
  1789. if (sellermemo.Length > 0)
  1790. {
  1791. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1792. }
  1793. string price1 = GetPostString("price1");
  1794. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1795. string price2 = GetPostString("price2");
  1796. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1797. //if (PKey != "admin")
  1798. //{
  1799. // string usershop = CurrentUser.User.pemShop;
  1800. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1801. //}
  1802. //if (ex_psize > 0)
  1803. //{
  1804. dStruct.Order = "pay_time desc";
  1805. //}
  1806. //else
  1807. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1808. lw.Add(string.Format("IsOffLineOrder=1"));
  1809. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1810. DataTable dt = null;
  1811. dt = WebCache.GetData("view_erptradecell", dStruct);
  1812. writeGridDataTableJson(dStruct.TotalCount, dt);
  1813. }
  1814. public void get_erp_returncashrecord()
  1815. {
  1816. DataStruct dStruct = GetPostStruct();
  1817. List<string> lw = new List<string>();
  1818. string tid = GetPostString("ctid");
  1819. if (tid.Length > 0)
  1820. {
  1821. lw.Add(string.Format("tid like '%{0}%'", tid));
  1822. dStruct.Order = "id desc";
  1823. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1824. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1825. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1826. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1827. return;
  1828. }
  1829. returnErrorMsg("id数据错误!");
  1830. }
  1831. public void ins_erp_returncashrecord()
  1832. {
  1833. if (UrlPostParmsCheck("tid"))
  1834. {
  1835. string tid = GetPostString("tid");
  1836. string retype = GetPostString("type");
  1837. StringBuilder sql = new StringBuilder();
  1838. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1839. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1840. if (dt.Rows.Count > 0)
  1841. {
  1842. returnErrorMsg("相同返现类型记录已存在");
  1843. return;
  1844. }
  1845. CeErpReturnCash entity = new CeErpReturnCash();
  1846. entity.tid = tid;
  1847. entity.seller_nick = GetPostString("seller_nick");
  1848. string pment = GetPostString("payment");
  1849. if (pment.Length > 0)
  1850. {
  1851. entity.payment = Convert.ToDouble(pment);
  1852. }
  1853. entity.buyer_nick = GetPostString("buyer_nick");
  1854. entity.cashstate = 0;
  1855. entity.rtype = retype;
  1856. string rPrice = GetPostString("returnprice");
  1857. if (rPrice.Length > 0)
  1858. {
  1859. entity.returnprice = Convert.ToDouble(rPrice);
  1860. }
  1861. entity.created = DateTime.Now;
  1862. entity.con = GetPostString("con");
  1863. entity.img = GetPostString("img");
  1864. entity.applyuserid = CurrentUser.UserID;
  1865. entity.Create();
  1866. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1867. returnSuccessMsg("操作成功!");
  1868. return;
  1869. }
  1870. }
  1871. public void set_erp_predelivery()
  1872. {
  1873. if (UrlPostParmsCheck("ctid"))
  1874. {
  1875. string eid = GetPostString("ctid");
  1876. CeErpTradeCell entity = null;
  1877. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1878. if (entity != null)
  1879. {
  1880. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1881. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1882. //{
  1883. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1884. // return;
  1885. //}
  1886. entity.IsPreDelivery = 1;
  1887. entity.Update();
  1888. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1889. returnSuccessMsg("预发货成功!");
  1890. return;
  1891. //string shop = GetPostString("seller_nick");
  1892. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1893. //string comName = GetPostString("comName");
  1894. //string comCode = GetPostString("comCode");
  1895. //string outSid = GetPostString("outSid");//运单号
  1896. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1897. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1898. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1899. //string apires = "";
  1900. //if (deliveryType == "虚拟发货")
  1901. //{
  1902. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1903. //}
  1904. //else
  1905. //{
  1906. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1907. //}
  1908. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1909. ////{
  1910. //if (apires.IndexOf("发货成功") != -1)
  1911. //{
  1912. // if (deliveryType != "虚拟发货")
  1913. // {
  1914. // //还要插入快递信息到 快递信息表
  1915. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1916. // exinfo.tid = eid;
  1917. // exinfo.out_sid = outSid;
  1918. // exinfo.company_code = comCode;
  1919. // exinfo.company_name = comName;
  1920. // exinfo.delivery_memo = deliveryMemo;
  1921. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1922. // exinfo.deliveryType = deliveryType;
  1923. // exinfo.Create();
  1924. // }
  1925. // returnSuccessMsg("发货成功!");
  1926. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1927. //}
  1928. //else
  1929. //{
  1930. // returnErrorMsg("淘宝发货失败!!");
  1931. //}
  1932. //return;
  1933. }
  1934. returnErrorMsg("找不到订单记录");
  1935. }
  1936. }
  1937. public void get_erp_unusuallist()
  1938. {
  1939. DataStruct dStruct = GetPostStruct();
  1940. List<string> lw = new List<string>();
  1941. string tid = GetPostString("ctid");
  1942. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1943. string shopname = GetPostString("shopname");
  1944. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1945. string buyernick = GetPostString("buyer_nick");
  1946. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1947. string ResponsibleMan = GetPostString("responsible");
  1948. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1949. string date1 = GetPostString("date1");
  1950. string date2 = GetPostString("date2");
  1951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1952. if (dw.Length > 0) lw.Add(dw);
  1953. string price1 = GetPostString("price1");
  1954. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1955. string price2 = GetPostString("price2");
  1956. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1957. string orderState = GetPostString("orderState");
  1958. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1959. string sellermemo = GetPostString("seller_memo");
  1960. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1961. lw.Add(string.Format("UnusualTag > 0"));
  1962. lw.Add(string.Format("IsRefund<={0}", 1));
  1963. dStruct.Order = "pay_time desc";
  1964. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1965. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1966. writeGridDataTableJson(dStruct.TotalCount, dt);
  1967. }
  1968. public void set_erp_unusualtonomal()
  1969. {
  1970. if (UrlPostParmsCheck("ctid"))
  1971. {
  1972. string eid = GetPostString("ctid");
  1973. CeErpTradeCell entity = null;
  1974. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1975. if (entity != null)
  1976. {
  1977. entity.UnusualTag = -1;
  1978. entity.Update();
  1979. returnSuccessMsg("忽略成功!");
  1980. return;
  1981. }
  1982. returnErrorMsg("找不到记录");
  1983. }
  1984. }
  1985. public void ins_erp_unusualreason()
  1986. {
  1987. if (UrlPostParmsCheck("ctid"))
  1988. {
  1989. string eid = GetPostString("ctid");
  1990. CeErpTradeCell entity = null;
  1991. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1992. if (entity != null)
  1993. {
  1994. entity.MemoOpt = 4;
  1995. entity.UnusualCon = GetPostString("con");
  1996. entity.Update();
  1997. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1998. if (trade != null)
  1999. {
  2000. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2001. }
  2002. //查货是否超时
  2003. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2004. if (ceErpTradeCellExtend == null)
  2005. {
  2006. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2007. ceErpTradeCellExtend.ctid = entity.ctid;
  2008. }
  2009. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2010. {
  2011. ceErpTradeCellExtend.CheckOut += 1;
  2012. }
  2013. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2014. if (ceErpTradeCellExtend.ID > 0)
  2015. {
  2016. ceErpTradeCellExtend.Update();
  2017. }
  2018. else
  2019. {
  2020. ceErpTradeCellExtend.Create();
  2021. }
  2022. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2023. returnSuccessMsg("操作成功!");
  2024. return;
  2025. }
  2026. returnErrorMsg("找不到记录");
  2027. }
  2028. }
  2029. public void upd_erp_sampleorder()
  2030. {
  2031. if (UrlPostParmsCheck("ctid"))
  2032. {
  2033. string eid = GetPostString("ctid");
  2034. string[] eArr = eid.Split(',');
  2035. if (eArr.Length > 1)
  2036. {
  2037. List<string> eLst = new List<string>();
  2038. for (int i = 0; i < eArr.Length; i++)
  2039. {
  2040. eLst.Add("'" + eArr[i] + "'");
  2041. }
  2042. eid = string.Join(",", eLst.ToArray());
  2043. }
  2044. else
  2045. {
  2046. eid = "'" + eid + "'";
  2047. }
  2048. StringBuilder sql = new StringBuilder();
  2049. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2050. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2051. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2052. if (dt.Rows.Count > 0)
  2053. {
  2054. string errmsg = "";
  2055. foreach (DataRow dr in dt.Rows)
  2056. {
  2057. StringBuilder sqlsb = new StringBuilder();
  2058. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2059. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2060. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2061. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2062. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2063. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2064. {
  2065. continue;
  2066. }
  2067. else
  2068. {
  2069. string emsg = commonHelper.KeepChinese(apires);
  2070. errmsg += emsg;
  2071. }
  2072. }
  2073. if (errmsg.Length > 0)
  2074. {
  2075. returnErrorMsg(errmsg);
  2076. return;
  2077. }
  2078. returnSuccessMsg("操作成功");
  2079. return;
  2080. }
  2081. returnErrorMsg("找不到记录");
  2082. }
  2083. }
  2084. public void upd_erp_transcustomer()
  2085. {
  2086. if (UrlPostParmsCheck("ctid"))
  2087. {
  2088. string eid = GetPostString("ctid");
  2089. int userid = GetPostInt("CustomerUserId");
  2090. CeErpTradeCell entity = null;
  2091. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2092. if (entity != null)
  2093. {
  2094. //string[] mlist = entity.seller_memo.Split('-');
  2095. //string sql = "select * from view_erpuser where id=" + userid;
  2096. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2097. //if (dt != null && dt.Rows.Count > 0)
  2098. //{
  2099. // string nmemo = "";
  2100. // for(int i = 0; i < mlist.Length - 1; i++)
  2101. // {
  2102. // nmemo += mlist[i];
  2103. // nmemo += "-";
  2104. // }
  2105. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2106. // entity.seller_memo = nmemo;
  2107. //}
  2108. entity.CustomerUserId = userid;
  2109. entity.Update();
  2110. returnSuccessMsg("操作成功!");
  2111. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2112. return;
  2113. }
  2114. returnErrorMsg("找不到记录");
  2115. }
  2116. }
  2117. public void upd_erp_transdesigner()
  2118. {
  2119. if (UrlPostParmsCheck("ctid"))
  2120. {
  2121. string eids = GetPostString("ctid");
  2122. string[] ctidList = eids.Split(',');
  2123. int userid = GetPostInt("DesignUserId");
  2124. foreach (string ctid in ctidList)
  2125. {
  2126. CeErpTradeCell entity = null;
  2127. CeErpDesignerBill entitys = null;
  2128. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2129. entitys = CeErpDesignerBill.GetByTid(ctid);
  2130. if (entity != null)
  2131. {
  2132. if (entity.OrderState > 4)
  2133. {
  2134. continue;
  2135. }
  2136. //存在退款不能流转
  2137. if (entity.IsRefund > 0)
  2138. {
  2139. continue;
  2140. }
  2141. entity.DesignUserId = userid;
  2142. entity.WaitDesignTime = DateTime.Now;
  2143. entity.Update();
  2144. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2145. }
  2146. }
  2147. returnSuccessMsg("操作成功!");
  2148. }
  2149. }
  2150. public void upd_erp_distributedesigner()
  2151. {
  2152. if (UrlPostParmsCheck("ctid"))
  2153. {
  2154. string eid = GetPostString("ctid");
  2155. int userid = GetPostInt("DesignUserId");
  2156. string[] idlist = eid.Split(',');
  2157. if (idlist.Length <= 0)
  2158. {
  2159. returnErrorMsg("订单不能为空");
  2160. return;
  2161. }
  2162. foreach (string ctid in idlist)
  2163. {
  2164. CeErpTradeCell entity = null;
  2165. CeErpDesignerBill entitys = null;
  2166. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2167. else continue;
  2168. if (entity != null)
  2169. {
  2170. if (userid == 2125 || userid == 3542)
  2171. { }
  2172. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2173. {
  2174. returnErrorMsg("金额错误的订单无法指派");
  2175. return;
  2176. }
  2177. if (entity.OrderState >= 5)
  2178. {
  2179. returnErrorMsg("已经设计完成无法指派");
  2180. return;
  2181. }
  2182. if (entity.OrderState == -1)
  2183. {
  2184. returnErrorMsg("审核中的订单无法指派");
  2185. return;
  2186. }
  2187. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2188. {
  2189. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2190. return;
  2191. }
  2192. //157赖橙帆 159林晨 73 静之颖
  2193. 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)
  2194. {
  2195. returnErrorMsg("指派设计共创无法再次指派!");
  2196. return;
  2197. }
  2198. entity.OrderState = 3;
  2199. if (entity.SupplierId == 0)
  2200. {
  2201. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2202. entity.SupplierId = suid;
  2203. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2204. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2205. }
  2206. if (userid == 2125 && entity.seller_memo != "")
  2207. {
  2208. apiDesign.API_GetPrintData_CreateOrder(entity);
  2209. }
  2210. if (userid == 3542 && entity.seller_memo != "")
  2211. {
  2212. string userPost = CurrentUser.UserPost.Post.Code;
  2213. if (CurrentUser.UserID == 73)
  2214. {
  2215. userPost = "SysAdmin";
  2216. }
  2217. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2218. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2219. if (response.msg != "设计共创:成功")
  2220. {
  2221. returnErrorMsg(response.msg);
  2222. return;
  2223. }
  2224. entity.DispatchSort = 2;
  2225. }
  2226. else
  2227. {
  2228. if (entity.DispatchSort == 2)
  2229. {
  2230. ApiVo apiVo = new ApiVo();
  2231. apiVo.actionName = "closeDesign";
  2232. apiVo.orderNumber = entity.ctid;
  2233. designHelper.API_WorkCore(apiVo);//closeDesign
  2234. }
  2235. entity.DispatchSort = 0;
  2236. }
  2237. entity.DesignUserId = userid;
  2238. entity.WaitDesignTime = DateTime.Now;
  2239. entity.UpdateTime = DateTime.Now;
  2240. entity.Update();
  2241. string name = commonHelper.getUserNameById(userid);
  2242. commonHelper.UpdateRelationOrder(entity.ctid);
  2243. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2244. }
  2245. }
  2246. returnSuccessMsg("操作成功!");
  2247. return;
  2248. }
  2249. }
  2250. public string getTidByCtid(string ctid)
  2251. {
  2252. string tid = "";
  2253. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2254. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2255. if (dataTable != null && dataTable.Rows.Count > 0)
  2256. {
  2257. tid = dataTable.Rows[0]["tid"].ToString();
  2258. }
  2259. return tid;
  2260. }
  2261. public List<string> getTidByCtidLike(string ctid)
  2262. {
  2263. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2264. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2265. List<string> list = new List<string>();
  2266. if (dataTable != null && dataTable.Rows.Count > 0)
  2267. {
  2268. foreach (DataRow item in dataTable.Rows)
  2269. {
  2270. list.Add("'" + item["tid"].ToString() + "'");
  2271. }
  2272. }
  2273. return list;
  2274. }
  2275. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2276. {
  2277. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2278. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2279. List<string> list = new List<string>();
  2280. if (dataTable != null && dataTable.Rows.Count > 0)
  2281. {
  2282. foreach (DataRow item in dataTable.Rows)
  2283. {
  2284. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2285. {
  2286. continue;
  2287. }
  2288. list.Add("'" + item["receiverId"].ToString() + "'");
  2289. }
  2290. }
  2291. return list;
  2292. }
  2293. public void get_erp_myorderlist()
  2294. {
  2295. DataStruct dStruct = GetPostStruct();
  2296. List<string> lw = new List<string>();
  2297. string tid = GetPostString("ctid");
  2298. if (tid.Length > 0)
  2299. {
  2300. string select_tid = getTidByCtid(tid);
  2301. lw.Add(string.Format("tid='{0}'", select_tid));
  2302. }
  2303. else
  2304. {
  2305. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2306. }
  2307. //12-1 修改
  2308. string urgent = GetPostString("urgent");
  2309. string back = GetPostString("back");
  2310. string offlineSearch = GetPostString("offlineSearch");
  2311. if (!string.IsNullOrWhiteSpace(urgent))
  2312. {
  2313. if (urgent.Equals("true"))
  2314. {
  2315. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2316. }
  2317. }
  2318. if (!string.IsNullOrWhiteSpace(back))
  2319. {
  2320. if (back.Equals("true"))
  2321. {
  2322. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2323. }
  2324. }
  2325. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2326. {
  2327. if (offlineSearch.Equals("true"))
  2328. {
  2329. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2330. }
  2331. }
  2332. //end
  2333. string shopname = GetPostString("shopname");
  2334. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2335. string buyernick = GetPostString("buyer_nick");
  2336. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2337. string design = GetPostString("design");
  2338. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2339. string orderState = GetPostString("orderState");
  2340. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2341. string sellermemo = GetPostString("seller_memo");
  2342. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2343. string date1 = GetPostString("date1");
  2344. string date2 = GetPostString("date2");
  2345. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2346. if (dw.Length > 0) lw.Add(dw);
  2347. string price1 = GetPostString("price1");
  2348. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2349. string price2 = GetPostString("price2");
  2350. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2351. string urgency = GetPostString("urgency");
  2352. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2353. string after = GetPostString("after");
  2354. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2355. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2356. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2357. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2358. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2359. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2360. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2361. if (dt != null && dt.Rows.Count > 0)
  2362. {
  2363. foreach (DataRow dr in dt.Rows)
  2364. {
  2365. try
  2366. {
  2367. // 对象操作
  2368. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2369. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2370. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2371. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2372. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2373. if (dStruct.PageSize != 100000)
  2374. {
  2375. if (dr["DispatchSort"].ToString() == "2")
  2376. {
  2377. dr["gongchuang"] = 200;
  2378. }
  2379. else if ("外协".Equals(dr["ToType"].ToString()))
  2380. {
  2381. dr["gongchuang"] = 200;
  2382. }
  2383. else if ("内部".Equals(dr["ToType"].ToString()))
  2384. {
  2385. dr["gongchuang"] = -1;
  2386. }
  2387. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2388. {
  2389. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2390. dr["gongchuang"] = response.code;
  2391. }
  2392. }
  2393. }
  2394. catch (NullReferenceException ex)
  2395. {
  2396. }
  2397. }
  2398. }
  2399. writeGridDataTableJson(dStruct.TotalCount, dt);
  2400. }
  2401. public void get_erp_myreturnorderlist()
  2402. {
  2403. DataStruct dStruct = GetPostStruct();
  2404. List<string> lw = new List<string>();
  2405. string tid = GetPostString("ctid");
  2406. if (tid.Length > 0)
  2407. {
  2408. string select_tid = getTidByCtid(tid);
  2409. lw.Add(string.Format("tid='{0}'", select_tid));
  2410. }
  2411. else
  2412. {
  2413. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2414. }
  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. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2434. {
  2435. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2436. }
  2437. else
  2438. {
  2439. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2440. }
  2441. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2442. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2443. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2444. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2445. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2446. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2447. if (dt != null && dt.Rows.Count > 0)
  2448. {
  2449. foreach (DataRow dr in dt.Rows)
  2450. {
  2451. try
  2452. {
  2453. // 对象操作
  2454. if (dStruct.PageSize != 100000)
  2455. {
  2456. if (dr["DispatchSort"].ToString() == "2")
  2457. {
  2458. dr["gongchuang"] = 200;
  2459. }
  2460. else if ("外协".Equals(dr["ToType"].ToString()))
  2461. {
  2462. dr["gongchuang"] = 200;
  2463. }
  2464. else if ("内部".Equals(dr["ToType"].ToString()))
  2465. {
  2466. dr["gongchuang"] = -1;
  2467. }
  2468. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2469. {
  2470. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2471. dr["gongchuang"] = response.code;
  2472. }
  2473. }
  2474. }
  2475. catch (NullReferenceException ex)
  2476. {
  2477. // 处理空引用异常
  2478. }
  2479. }
  2480. }
  2481. writeGridDataTableJson(dStruct.TotalCount, dt);
  2482. }
  2483. public void get_erp_myorderlist_pregather()
  2484. {
  2485. string date1 = GetPostString("date1");
  2486. string date2 = GetPostString("date2");
  2487. int userId = CurrentUser.UserID; //客服id
  2488. string orderWhere = "";
  2489. List<string> lw = new List<string>();
  2490. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2491. if (dw.Length > 0) lw.Add(dw);
  2492. lw.Add(string.Format("CustomerUserId={0}", userId));
  2493. lw.Add(string.Format("OrderState<9"));
  2494. orderWhere = string.Join(" and ", lw.ToArray());
  2495. string orderWhere2 = "";
  2496. List<string> lw2 = new List<string>();
  2497. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2498. if (dw2.Length > 0) lw2.Add(dw2);
  2499. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2500. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2501. string sql = string.Format("select *" +
  2502. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2503. "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 " +
  2504. "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 " +
  2505. "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");
  2506. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2507. //writeGridDataTableJson(dt.Rows.Count, dt);
  2508. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2509. }
  2510. public void upd_erp_publishorder()
  2511. {
  2512. if (UrlPostParmsCheck("ctid"))
  2513. {
  2514. string eid = GetPostString("ctid");
  2515. CeErpTradeCell entity = null;
  2516. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2517. if (entity != null)
  2518. {
  2519. entity.OrderState = 0; //发布后,变为待抢单
  2520. entity.Update();
  2521. commonHelper.UpdateRelationOrder(entity.ctid);
  2522. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2523. returnSuccessMsg("发布成功!");
  2524. return;
  2525. }
  2526. returnErrorMsg("找不到记录");
  2527. }
  2528. }
  2529. public void get_erp_my_tiporder()
  2530. {
  2531. StringBuilder sql = new StringBuilder();
  2532. int userId = 0;
  2533. if (CurrentUser != null) userId = CurrentUser.UserID;
  2534. string posCode = CurrentUser.UserPost.Post.Code;
  2535. string isTipedAfterSaleVerify = GetPostString("af");
  2536. DataTable dt = new DataTable();
  2537. if (posCode != "Supplier")
  2538. {
  2539. if (posCode == "CustomerService" || posCode == "Director")
  2540. {
  2541. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2542. }
  2543. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2544. {
  2545. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2546. }
  2547. else
  2548. {
  2549. string teamIds = CurrentUser.User.TeamIds;
  2550. if (teamIds == "")
  2551. {
  2552. teamIds = "0";
  2553. }
  2554. 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);
  2555. }
  2556. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2557. }
  2558. if (dt.Rows.Count <= 0)
  2559. {
  2560. string key = "aftersale_order_" + userId;
  2561. if (RedisHelper.HasKey(key))
  2562. {
  2563. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2564. dt.Columns.Add("ctid", typeof(string));
  2565. dt.Columns.Add("IsReadTag", typeof(int));
  2566. foreach (var i in list)
  2567. {
  2568. DataRow data = dt.NewRow();
  2569. data["ctid"] = i;
  2570. data["IsReadTag"] = 4;
  2571. dt.Rows.Add(data);
  2572. }
  2573. RedisHelper.StringDelete(key);
  2574. }
  2575. }
  2576. if (dt.Rows.Count <= 0)
  2577. {
  2578. sql = new StringBuilder();
  2579. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2580. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2581. }
  2582. if (posCode == "Supplier")
  2583. {
  2584. string ids = CurrentUser.User.pemVend;
  2585. if (ids != null && ids.Length > 0)
  2586. {
  2587. string[] ids_list = ids.Split(',');
  2588. foreach (var item in ids_list)
  2589. {
  2590. string key = "return_order_" + item;
  2591. if (RedisHelper.HasKey(key))
  2592. {
  2593. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2594. dt.Columns.Add("ctid", typeof(string));
  2595. dt.Columns.Add("IsReadTag", typeof(int));
  2596. foreach (var i in list)
  2597. {
  2598. DataRow data = dt.NewRow();
  2599. data["ctid"] = i;
  2600. data["IsReadTag"] = 1;
  2601. dt.Rows.Add(data);
  2602. }
  2603. RedisHelper.StringDelete(key);
  2604. }
  2605. }
  2606. }
  2607. if (dt.Rows.Count <= 0)
  2608. {
  2609. sql = new StringBuilder();
  2610. 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);
  2611. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2612. }
  2613. }
  2614. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2615. }
  2616. public void reset_erp_tiporder()
  2617. {
  2618. string ids = GetPostString("ids");
  2619. string[] ctidList = ids.Split(',');
  2620. foreach (string ctid in ctidList)
  2621. {
  2622. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2623. if (enty != null)
  2624. {
  2625. enty.IsReadTag = 0;
  2626. enty.Update();
  2627. }
  2628. }
  2629. returnSuccessMsg("成功!");
  2630. return;
  2631. }
  2632. public void get_erp_designlist()
  2633. {
  2634. DataStruct dStruct = GetPostStruct();
  2635. List<string> lw = new List<string>();
  2636. string tid = GetPostString("ctid");
  2637. if (tid.Length > 0)
  2638. {
  2639. string select_tid = getTidByCtid(tid);
  2640. lw.Add(string.Format("tid='{0}'", select_tid));
  2641. }
  2642. string shopname = GetPostString("shopname");
  2643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2644. string buyernick = GetPostString("buyer_nick");
  2645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2646. string customer = GetPostString("customer");
  2647. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2648. string design = GetPostString("design");
  2649. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2650. string orderState = GetPostString("orderState");
  2651. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2652. lw.Add(string.Format("OrderState<6"));
  2653. string address = GetPostString("address");
  2654. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2655. string sellermemo = GetPostString("seller_memo");
  2656. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2657. string date1 = GetPostString("date1");
  2658. string date2 = GetPostString("date2");
  2659. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2660. if (dw.Length > 0) lw.Add(dw);
  2661. string apdate1 = GetPostString("apdate1");
  2662. string apdate2 = GetPostString("apdate2");
  2663. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2664. if (dwap.Length > 0) lw.Add(dwap);
  2665. string price1 = GetPostString("price1");
  2666. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2667. string price2 = GetPostString("price2");
  2668. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2669. string designTime = GetPostString("designtime");
  2670. if (designTime.Length > 0)
  2671. {
  2672. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2673. }
  2674. string usershop = CurrentUser.User.pemShop;
  2675. if (usershop.Length > 0)
  2676. {
  2677. lw.Add(string.Format("shopId in ({0})", usershop));
  2678. }
  2679. int myOrgid = CurrentUser.UserPost.OrgID;
  2680. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2681. if (myOrgCode.IndexOf("Designer") != -1)
  2682. {
  2683. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2684. {
  2685. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2686. }
  2687. else
  2688. {
  2689. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2690. }
  2691. }
  2692. else
  2693. {
  2694. string orgId = GetPostString("designerhd");
  2695. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2696. }
  2697. if (tid.Length > 0 || buyernick.Length > 0)
  2698. {
  2699. lw.Add(string.Format("OrderState >= 3"));
  2700. }
  2701. else
  2702. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2703. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2704. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2705. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2706. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2707. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2708. if (dt != null && dt.Rows.Count > 0)
  2709. {
  2710. foreach (DataRow dr in dt.Rows)
  2711. {
  2712. try
  2713. {
  2714. // 对象操作
  2715. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2716. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2717. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2718. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2719. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2720. if (dStruct.PageSize != 100000)
  2721. {
  2722. if (dr["DispatchSort"].ToString() == "2")
  2723. {
  2724. dr["gongchuang"] = 200;
  2725. }
  2726. else if ("外协".Equals(dr["ToType"].ToString()))
  2727. {
  2728. dr["gongchuang"] = 200;
  2729. }
  2730. else if ("内部".Equals(dr["ToType"].ToString()))
  2731. {
  2732. dr["gongchuang"] = -1;
  2733. }
  2734. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2735. {
  2736. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2737. dr["gongchuang"] = response.code;
  2738. }
  2739. }
  2740. }
  2741. catch (NullReferenceException ex)
  2742. {
  2743. }
  2744. }
  2745. }
  2746. writeGridDataTableJson(dStruct.TotalCount, dt);
  2747. }
  2748. public void get_erp_mydesignlist()
  2749. {
  2750. DataStruct dStruct = GetPostStruct();
  2751. List<string> lw = new List<string>();
  2752. string tid = GetPostString("ctid");
  2753. if (tid.Length > 0)
  2754. {
  2755. string select_tid = getTidByCtid(tid);
  2756. lw.Add(string.Format("tid='{0}'", select_tid));
  2757. }
  2758. string shopname = GetPostString("shopname");
  2759. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2760. string buyernick = GetPostString("buyer_nick");
  2761. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2762. string customer = GetPostString("customer");
  2763. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2764. string orderState = GetPostString("orderState");
  2765. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2766. //lw.Add(string.Format("OrderState<6"));
  2767. string date1 = GetPostString("date1");
  2768. string date2 = GetPostString("date2");
  2769. string dw = GetDateWhere("pay_time", date1, date2);
  2770. if (dw.Length > 0) lw.Add(dw);
  2771. string apdate1 = GetPostString("apdate1");
  2772. string apdate2 = GetPostString("apdate2");
  2773. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2774. if (dwap.Length > 0) lw.Add(dwap);
  2775. string price1 = GetPostString("price1");
  2776. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2777. string price2 = GetPostString("price2");
  2778. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2779. string olddownload = GetPostString("olddown");
  2780. if (olddownload == "1")
  2781. {
  2782. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2783. }
  2784. else if (olddownload == "2")
  2785. {
  2786. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2787. }
  2788. string sellermemo = GetPostString("seller_memo");
  2789. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2790. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2791. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2792. {
  2793. if (CurrentUser.User.TeamIds.Length > 0)
  2794. {
  2795. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2796. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2797. else
  2798. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2799. }
  2800. else
  2801. {
  2802. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2803. }
  2804. }
  2805. if (tid.Length <= 0)
  2806. {
  2807. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2808. }
  2809. lw.Add(string.Format("IsReturn!=3"));
  2810. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2811. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2812. string teamids = CurrentUser.User.TeamIds.ToString();
  2813. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2814. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2815. if (dt != null && dt.Rows.Count > 0)
  2816. {
  2817. foreach (DataRow dr in dt.Rows)
  2818. {
  2819. try
  2820. {
  2821. // 对象操作
  2822. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2823. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2824. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2825. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2826. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2827. if (dStruct.PageSize != 100000)
  2828. {
  2829. if (dr["DispatchSort"].ToString() == "2")
  2830. {
  2831. dr["gongchuang"] = 200;
  2832. }
  2833. else if ("外协".Equals(dr["ToType"].ToString()))
  2834. {
  2835. dr["gongchuang"] = 200;
  2836. }
  2837. else if ("内部".Equals(dr["ToType"].ToString()))
  2838. {
  2839. dr["gongchuang"] = -1;
  2840. }
  2841. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2842. {
  2843. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2844. dr["gongchuang"] = response.code;
  2845. }
  2846. }
  2847. }
  2848. catch (NullReferenceException ex)
  2849. {
  2850. }
  2851. }
  2852. }
  2853. writeGridDataTableJson(dStruct.TotalCount, dt);
  2854. }
  2855. public void set_erp_startdesign()
  2856. {
  2857. if (UrlPostParmsCheck("ctid"))
  2858. {
  2859. string eid = GetPostString("ctid");
  2860. CeErpTradeCell entity = null;
  2861. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2862. if (entity != null)
  2863. {
  2864. if (entity.OrderState != 3)
  2865. {
  2866. returnErrorMsg("请刷新,订单已经设计了");
  2867. return;
  2868. }
  2869. entity.StartDesignTime = DateTime.Now;
  2870. entity.OrderState = 4;
  2871. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2872. {
  2873. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2874. entity.SupplierId = suid;
  2875. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2876. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2877. }
  2878. entity.UpdateTime = DateTime.Now;
  2879. //entity.MakeSupplier = suname;
  2880. entity.Update();
  2881. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2883. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2884. commonHelper.getCytPrice(entity);
  2885. returnSuccessMsg("操作成功!");
  2886. return;
  2887. }
  2888. returnErrorMsg("找不到记录");
  2889. }
  2890. }
  2891. public void ins_erp_designselfmemo()
  2892. {
  2893. if (UrlPostParmsCheck("ctid"))
  2894. {
  2895. string eid = GetPostString("ctid");
  2896. string con = GetPostString("con");
  2897. CeErpTradeCell entity = null;
  2898. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2899. if (entity != null)
  2900. {
  2901. entity.DesignSelfMemo = con;
  2902. entity.Update();
  2903. returnSuccessMsg("操作成功!");
  2904. return;
  2905. }
  2906. returnErrorMsg("找不到记录");
  2907. }
  2908. }
  2909. public void ins_erp_designprice()
  2910. {
  2911. if (UrlPostParmsCheck("ctid"))
  2912. {
  2913. string eid = GetPostString("ctid");
  2914. int uid = CurrentUser.UserID;
  2915. string userName = CurrentUser.UserName;
  2916. CeErpTradeCell entity = null;
  2917. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2918. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2919. if (entitys == null)
  2920. {
  2921. entitys = new CeErpDesignerBill();
  2922. }
  2923. if (entity != null)
  2924. {
  2925. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2926. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2927. entity.StartDesignTime = DateTime.Now;
  2928. entity.OrderState = 4;
  2929. string suname = "";
  2930. if (entity.SupplierId == 0)
  2931. {
  2932. int sid = commonHelper.autoDistributeToSupplier(entity);
  2933. entity.SupplierId = sid;
  2934. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2935. }
  2936. entity.Update();
  2937. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2938. if (ceErpUserPost != null)
  2939. {
  2940. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2941. if (ceErpPost != null)
  2942. {
  2943. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2944. {
  2945. entitys.tid = entity.ctid;
  2946. entitys.oid = entity.tid;
  2947. entitys.uid = uid;
  2948. entitys.userName = userName;
  2949. entitys.designerType = 1;
  2950. entitys.designerTypeText = "内部设计师";
  2951. entitys.price = Convert.ToDouble(GetPostString("price"));
  2952. entitys.designNum = GetPostInt("designNum");
  2953. entitys.modifyNum = GetPostInt("modifyNum");
  2954. entitys.designSize = GetPostString("designSize");
  2955. entitys.modifySize = GetPostString("modifySize");
  2956. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2957. {
  2958. entitys.create_time = DateTime.Now;
  2959. entitys.create_u_id = uid;
  2960. entitys.create_u_name = userName;
  2961. entitys.Save();
  2962. }
  2963. else
  2964. {
  2965. entitys.update_time = DateTime.Now;
  2966. entitys.update_u_id = uid;
  2967. entitys.update_u_name = userName;
  2968. entitys.Update();
  2969. }
  2970. }
  2971. }
  2972. }
  2973. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2974. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2975. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2976. if (suname != "")
  2977. {
  2978. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2979. }
  2980. commonHelper.getCytPrice(entity);
  2981. returnSuccessMsg("操作成功!");
  2982. return;
  2983. }
  2984. returnErrorMsg("找不到记录");
  2985. }
  2986. }
  2987. public void upload_erp_filecomplete()
  2988. {
  2989. if (UrlPostParmsCheck("ctid"))
  2990. {
  2991. string eid = GetPostString("ctid");
  2992. CeErpTradeCell entity = null;
  2993. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2994. if (entity != null)
  2995. {
  2996. entity.OrderState = 5; //设计完成
  2997. entity.Update();
  2998. returnSuccessMsg(eid + "上传成功,设计完成!");
  2999. return;
  3000. }
  3001. returnErrorMsg("找不到订单记录");
  3002. }
  3003. }
  3004. public void get_erp_designovertimelist()
  3005. {
  3006. DataStruct dStruct = GetPostStruct();
  3007. List<string> lw = new List<string>();
  3008. string tid = GetPostString("ctid");
  3009. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3010. string shopname = GetPostString("shopname");
  3011. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3012. string buyernick = GetPostString("buyer_nick");
  3013. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3014. string ResponsibleMan = GetPostString("responsible");
  3015. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3016. string date1 = GetPostString("date1");
  3017. string date2 = GetPostString("date2");
  3018. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3019. if (dw.Length > 0) lw.Add(dw);
  3020. string price1 = GetPostString("price1");
  3021. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3022. string price2 = GetPostString("price2");
  3023. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3024. string orderState = GetPostString("orderState");
  3025. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3026. string sellermemo = GetPostString("seller_memo");
  3027. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3028. lw.Add(string.Format("UnusualTag=3"));
  3029. lw.Add(string.Format("IsRefund<={0}", 1));
  3030. dStruct.Order = "WaitDesignTime desc";
  3031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3032. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3033. writeGridDataTableJson(dStruct.TotalCount, dt);
  3034. }
  3035. //设计管理 获取抢单大厅列表
  3036. public void get_erp_grabinglist()
  3037. {
  3038. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3039. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3040. bool oldOrder = false;
  3041. if (org != null)
  3042. {
  3043. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3044. }
  3045. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3046. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3047. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3048. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3049. //先处理订单数据
  3050. if (dt.Rows.Count > 0)
  3051. {
  3052. Dictionary<string, int> design = null;
  3053. int count = 0;
  3054. foreach (DataRow row in dt.Rows)
  3055. {
  3056. if (map.ContainsKey(row["ShopId"].ToString()))
  3057. {
  3058. map.TryGetValue(row["ShopId"].ToString(), out design);
  3059. }
  3060. else
  3061. {
  3062. design = new Dictionary<string, int>();
  3063. }
  3064. if (design.ContainsKey(row["ProductId"].ToString()))
  3065. {
  3066. design.TryGetValue(row["ProductId"].ToString(), out count);
  3067. }
  3068. count++;
  3069. design[row["ProductId"].ToString()] = count;
  3070. map[row["ShopId"].ToString()] = design;
  3071. }
  3072. }
  3073. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3074. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3075. //把店铺排序和技能排序分类
  3076. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3077. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3078. if (design_dt.Rows.Count > 0)
  3079. {
  3080. Dictionary<string, string> design = null;
  3081. List<string> shopIds = null;
  3082. foreach (DataRow row in design_dt.Rows)
  3083. {
  3084. if ("0".Equals(row["designId"].ToString()))
  3085. {
  3086. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3087. {
  3088. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3089. }
  3090. else
  3091. {
  3092. shopIds = new List<string>();
  3093. }
  3094. shopIds.Add(row["shopId"].ToString());
  3095. shop_orders[row["orders"].ToString()] = shopIds;
  3096. }
  3097. else
  3098. {
  3099. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3100. {
  3101. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3102. }
  3103. else
  3104. {
  3105. design = new Dictionary<string, string>();
  3106. }
  3107. design[row["orders"].ToString()] = row["designId"].ToString();
  3108. design_orders[row["shopId"].ToString()] = design;
  3109. }
  3110. }
  3111. //处理成key value后根据key排序
  3112. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3113. foreach (List<string> val in shop_orders.Values)
  3114. {
  3115. if (val != null)
  3116. {
  3117. foreach (string key in val)
  3118. {
  3119. if (design_orders.ContainsKey(key.ToString()))
  3120. {
  3121. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3122. }
  3123. }
  3124. }
  3125. }
  3126. }
  3127. //校验哪个优先级有订单
  3128. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3129. foreach (string key in shop_orders.Keys)
  3130. {
  3131. List<string> ids = null;
  3132. shop_orders.TryGetValue(key, out ids);
  3133. //id为shopid
  3134. foreach (string id in ids)
  3135. {
  3136. Dictionary<string, int> list = null;
  3137. Dictionary<string, string> desing = null;
  3138. map.TryGetValue(id, out list);
  3139. design_orders.TryGetValue(id, out desing);
  3140. if (list != null && desing != null)
  3141. {
  3142. foreach (var item in desing)
  3143. {
  3144. int count = 0;
  3145. if (list.ContainsKey(item.Value))
  3146. {
  3147. list.TryGetValue(item.Value, out count);
  3148. if (count > 0)
  3149. {
  3150. designIds[id] = item.Value;
  3151. break;
  3152. }
  3153. }
  3154. }
  3155. }
  3156. }
  3157. if (designIds.Count > 0)
  3158. {
  3159. break;
  3160. }
  3161. }
  3162. DataTable table = new DataTable();
  3163. table.Columns.Add("tid", typeof(string));
  3164. table.Columns.Add("ctid", typeof(string));
  3165. table.Columns.Add("seller_nick", typeof(string));
  3166. table.Columns.Add("productName", typeof(string));
  3167. table.Columns.Add("pay_time", typeof(string));
  3168. table.Columns.Add("seller_memo", typeof(string));
  3169. if (designIds.Count > 0)
  3170. {
  3171. string shopId = "";
  3172. string productId = "";
  3173. foreach (var designInfo in designIds)
  3174. {
  3175. shopId = designInfo.Key;
  3176. productId = designInfo.Value;
  3177. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3178. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3179. if (dt.Rows.Count > 0)
  3180. {
  3181. foreach (DataRow row in dt.Rows)
  3182. {
  3183. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3184. {
  3185. DataRow data = table.NewRow();
  3186. data["ctid"] = row["ctid"].ToString();
  3187. data["tid"] = row["tid"].ToString();
  3188. data["seller_nick"] = ceErpShop.ShopName;
  3189. data["pay_time"] = row["pay_time"].ToString();
  3190. data["seller_memo"] = row["seller_memo"].ToString();
  3191. data["productName"] = ceErpProduct.PType;
  3192. table.Rows.Add(data);
  3193. }
  3194. }
  3195. }
  3196. }
  3197. }
  3198. writeGridDataTableJson(table.Rows.Count, table);
  3199. }
  3200. private object rushLockObject = new object();
  3201. public void set_erp_grabingorder()
  3202. {
  3203. if (UrlPostParmsCheck("ctid"))
  3204. {
  3205. int total = CurrentUser.User.Person.Total;
  3206. int userId = CurrentUser.User.ID;
  3207. int noFinish = CurrentUser.User.Person.NoFinish;
  3208. int finalization = CurrentUser.User.Person.Finalization;
  3209. string eids = GetPostString("ctid");
  3210. string key = "RushKey_" + userId;
  3211. int count = 0;
  3212. if (erpRedis.RedisHelper.KeyExists(key))
  3213. {
  3214. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3215. if (redisCount != null)
  3216. {
  3217. count = Convert.ToInt32(redisCount);
  3218. }
  3219. }
  3220. if (count >= total)
  3221. {
  3222. returnErrorMsg("半小时内已经抢" + total + "单");
  3223. return;
  3224. }
  3225. string[] ctidlist = eids.Split(',');
  3226. if (count + ctidlist.Length > total)
  3227. {
  3228. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3229. return;
  3230. }
  3231. int itag = 0;
  3232. lock (rushLockObject)
  3233. {
  3234. if (ctidlist.Length > 0)
  3235. {
  3236. string[] dtList = new string[ctidlist.Length];
  3237. for (int i = 0; i < ctidlist.Length; i++)
  3238. {
  3239. dtList[i] = "'" + ctidlist[i] + "'";
  3240. }
  3241. 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"));
  3242. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3243. if (dt_user.Rows.Count > 0)
  3244. {
  3245. int doing = 0;//未定稿
  3246. int finish = 0;//已完成
  3247. foreach (DataRow dr in dt_user.Rows)
  3248. {
  3249. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3250. {
  3251. doing++;
  3252. }
  3253. else
  3254. {
  3255. finish++;
  3256. }
  3257. }
  3258. if (doing >= noFinish)
  3259. {
  3260. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3261. return;
  3262. }
  3263. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3264. {
  3265. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3266. return;
  3267. }
  3268. }
  3269. //校验选择单子状态
  3270. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3271. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3272. if (dt.Rows.Count > 0)
  3273. {
  3274. List<string> list = new List<string>();
  3275. foreach (DataRow dr in dt.Rows)
  3276. {
  3277. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3278. {
  3279. list.Add(dr["ctid"].ToString());
  3280. }
  3281. }
  3282. if (list.Count > 0)
  3283. {
  3284. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3285. return;
  3286. }
  3287. }
  3288. foreach (string ctid in ctidlist)
  3289. {
  3290. CeErpTradeCell entity = null;
  3291. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3292. if (entity != null)
  3293. {
  3294. entity.OrderState = 3;
  3295. entity.DesignUserId = CurrentUser.UserID;
  3296. entity.WaitDesignTime = DateTime.Now;
  3297. entity.StartDesignTime = DateTime.Now;
  3298. entity.Update();
  3299. commonHelper.UpdateRelationOrder(entity.ctid);
  3300. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3301. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3302. itag++;
  3303. }
  3304. }
  3305. }
  3306. }
  3307. count += ctidlist.Length;
  3308. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3309. if (itag == 0)
  3310. returnErrorMsg("没有找到相关订单");
  3311. else
  3312. returnSuccessMsg("抢单成功!");
  3313. return;
  3314. }
  3315. }
  3316. public void get_erp_waitorderlist()
  3317. {
  3318. DataStruct dStruct = GetPostStruct();
  3319. List<string> lw = new List<string>();
  3320. string tid = GetPostString("ctid");
  3321. if (tid.Length > 0)
  3322. {
  3323. string select_tid = getTidByCtid(tid);
  3324. lw.Add(string.Format("tid='{0}'", select_tid));
  3325. }
  3326. string shopname = GetPostString("shopname");
  3327. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3328. string buyernick = GetPostString("buyer_nick");
  3329. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3330. string customer = GetPostString("customer");
  3331. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3332. string design = GetPostString("design");
  3333. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3334. string orderState = GetPostString("orderState");
  3335. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3336. string supplier = GetPostString("supplier");
  3337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3338. string sellermemo = GetPostString("seller_memo");
  3339. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3340. string otherMemo = GetPostString("otherMemo");
  3341. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3342. string address = GetPostString("address");
  3343. 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));
  3344. string date1 = GetPostString("date1");
  3345. string date2 = GetPostString("date2");
  3346. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3347. if (dw.Length > 0) lw.Add(dw);
  3348. string price1 = GetPostString("price1");
  3349. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3350. string price2 = GetPostString("price2");
  3351. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3352. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3353. lw.Add(string.Format("IsSample != 2 "));
  3354. lw.Add(string.Format("OrderState = 5 "));
  3355. lw.Add(string.Format("IsRefund<={0}", 1));
  3356. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3357. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3358. string pagesize = GetPostString("pagesize");
  3359. if (pagesize != null)
  3360. {
  3361. dStruct.PageSize = 200;
  3362. }
  3363. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3364. if (dt != null)
  3365. {
  3366. foreach (DataRow dr in dt.Rows)
  3367. {
  3368. 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();
  3369. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3370. {
  3371. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3372. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3373. entity.SupplierId = suid;
  3374. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3375. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3376. entity.Update();
  3377. }
  3378. }
  3379. }
  3380. writeGridDataTableJson(dStruct.TotalCount, dt);
  3381. }
  3382. public void get_erp_supplierwaitorderlist()
  3383. {
  3384. DataStruct dStruct = GetPostStruct();
  3385. List<string> lw = new List<string>();
  3386. string tid = GetPostString("ctid");
  3387. if (tid.Length > 0)
  3388. {
  3389. string select_tid = getTidByCtid(tid);
  3390. lw.Add(string.Format("tid='{0}'", select_tid));
  3391. }
  3392. string shopname = GetPostString("shopname");
  3393. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3394. string sellermemo = GetPostString("seller_memo");
  3395. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3396. string date1 = GetPostString("date1");
  3397. string date2 = GetPostString("date2");
  3398. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3399. if (dw.Length > 0) lw.Add(dw);
  3400. lw.Add(string.Format("OrderState = 5 "));
  3401. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3402. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3403. {
  3404. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3405. }
  3406. string supplier = GetPostString("supplier");
  3407. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3408. {
  3409. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3410. }
  3411. lw.Add(string.Format("IsRefund<={0}", 1));
  3412. dStruct.Order = "FinishDesignTime desc";
  3413. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3414. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3415. if (dt != null)
  3416. {
  3417. foreach (DataRow dr in dt.Rows)
  3418. {
  3419. 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();
  3420. }
  3421. }
  3422. writeGridDataTableJson(dStruct.TotalCount, dt);
  3423. }
  3424. public void upd_erp_verifytosupplier()
  3425. {
  3426. if (UrlPostParmsCheck("ctid"))
  3427. {
  3428. string eids = GetPostString("ctid");
  3429. CeErpTradeCell entity = null;
  3430. string[] eidsList = eids.Split(',');
  3431. if (eidsList.Length <= 0)
  3432. {
  3433. returnErrorMsg("订单号不能空");
  3434. return;
  3435. }
  3436. List<string> tLst = new List<string>();
  3437. foreach (string ctidstr in eidsList)
  3438. {
  3439. tLst.Add("'" + ctidstr + "'");
  3440. CeErpDataSendOrderInfo.createObject(ctidstr);
  3441. }
  3442. string needtids = string.Join(",", tLst.ToArray());
  3443. StringBuilder sql = new StringBuilder();
  3444. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3445. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3446. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3447. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3448. returnSuccessMsg("操作成功!");
  3449. return;
  3450. /**foreach (string ctidstr in eidsList)
  3451. {
  3452. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3453. if (entity != null)
  3454. {
  3455. if (entity.SupplierId == 0)
  3456. {
  3457. continue;
  3458. }
  3459. entity.IsVerifyToSupplier = true;
  3460. if (entity.IsReturn == 1) //1是供应商打回
  3461. {
  3462. entity.IsReturn = 0;
  3463. }
  3464. entity.FinishPlaceTime = DateTime.Now;
  3465. entity.PlaceUserId = CurrentUser.UserID;
  3466. entity.Update();
  3467. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3468. }
  3469. }
  3470. returnSuccessMsg("操作成功!");
  3471. return;**/
  3472. }
  3473. }
  3474. public void upd_erp_supplierback()
  3475. {
  3476. if (UrlPostParmsCheck("ctid"))
  3477. {
  3478. string eid = GetPostString("ctid");
  3479. string reason = GetPostString("returnreason");
  3480. CeErpTradeCell entity = null;
  3481. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3482. if (entity != null)
  3483. {
  3484. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3485. {
  3486. string key = "return_order_" + entity.SupplierId;
  3487. List<string> list = new List<string>();
  3488. if (RedisHelper.HasKey(key))
  3489. {
  3490. object data = RedisHelper.StringGet(key);
  3491. list = Convert.ToString(data).Split(',').ToList();
  3492. }
  3493. list.Add(eid);
  3494. RedisHelper.StringSet(key, string.Join(",", list));
  3495. }
  3496. entity.IsVerifyToSupplier = false;
  3497. entity.IsReturn = 1;
  3498. entity.ReturnTime = DateTime.Now;
  3499. entity.ReturnReason = reason;
  3500. if (entity.OrderState == 6)
  3501. {
  3502. entity.OrderState = 5;
  3503. }
  3504. entity.Update();
  3505. CeErpSukuraData.createInfo(entity.ctid, 5);
  3506. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3507. returnSuccessMsg("操作成功!");
  3508. return;
  3509. }
  3510. returnErrorMsg("找不到订单记录");
  3511. }
  3512. }
  3513. public void upd_erp_toaftersaleorder()
  3514. {
  3515. if (UrlPostParmsCheck("ctid"))
  3516. {
  3517. string eid = GetPostString("ctid");
  3518. string reason = GetPostString("returnreason");
  3519. CeErpTradeCell entity = null;
  3520. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3521. if (entity != null)
  3522. {
  3523. if (entity.isAfterSaleOrder != 1)
  3524. {
  3525. returnErrorMsg("带S的售后单才能打回给售后");
  3526. return;
  3527. }
  3528. if (entity.OrderState >= 5)
  3529. {
  3530. returnErrorMsg("已经设计完成了不能打回给售后");
  3531. return;
  3532. }
  3533. entity.OrderState = 0;
  3534. entity.IsReturn = 3;
  3535. entity.ReturnTime = DateTime.Now;
  3536. entity.UpdateTime = DateTime.Now;
  3537. entity.ReturnReason = reason;
  3538. entity.Update();
  3539. CeErpSukuraData.createInfo(entity.ctid, 5);
  3540. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3541. returnSuccessMsg("操作成功!");
  3542. return;
  3543. }
  3544. returnErrorMsg("找不到订单记录");
  3545. }
  3546. }
  3547. public void upd_erp_aftersaletodesign()
  3548. {
  3549. if (UrlPostParmsCheck("ctid"))
  3550. {
  3551. string eid = GetPostString("ctid");
  3552. CeErpTradeCell entity = null;
  3553. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3554. if (entity != null)
  3555. {
  3556. entity.OrderState = 3;
  3557. entity.IsReturn = 0;
  3558. entity.UpdateTime = DateTime.Now;
  3559. entity.Update();
  3560. CeErpSukuraData.createInfo(entity.ctid, 5);
  3561. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3562. returnSuccessMsg("操作成功!");
  3563. return;
  3564. }
  3565. returnErrorMsg("找不到订单记录");
  3566. }
  3567. }
  3568. public void assign_erp_supplier()
  3569. {
  3570. if (UrlPostParmsCheck("ctid"))
  3571. {
  3572. string eids = GetPostString("ctid");
  3573. int sid = GetPostInt("SupplierName");
  3574. string fromTag = GetPostString("tag");
  3575. string[] eidList = eids.Split(',');
  3576. if (eidList.Length <= 0)
  3577. {
  3578. returnErrorMsg("指派不能为空");
  3579. return;
  3580. }
  3581. string errMsg = "";
  3582. string suname = commonHelper.getSupplierNameById(sid);
  3583. foreach (string ctid in eidList)
  3584. {
  3585. CeErpTradeCell entity = null;
  3586. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3587. if (entity != null)
  3588. {
  3589. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3590. {
  3591. errMsg += (ctid + "指派失败!!!");
  3592. continue;
  3593. }
  3594. entity.SupplierId = sid;
  3595. entity.Update();
  3596. commonHelper.UpdateRelationOrder(entity.ctid);
  3597. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3598. if (entity.OrderState >= 6)
  3599. {
  3600. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3601. //{
  3602. // string msl = entity.MakeSupplier;
  3603. // string[] mslist = msl.Split(',');
  3604. // 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);
  3605. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3606. //}
  3607. //else
  3608. //{
  3609. StringBuilder sql = new StringBuilder();
  3610. 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);
  3611. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3612. //}
  3613. }
  3614. }
  3615. else
  3616. {
  3617. continue;
  3618. }
  3619. }
  3620. if (errMsg.Length > 0)
  3621. {
  3622. returnErrorMsg(errMsg);
  3623. return;
  3624. }
  3625. returnSuccessMsg("操作成功!");
  3626. return;
  3627. }
  3628. }
  3629. public void assign_erp_makesupplier()
  3630. {
  3631. if (UrlPostParmsCheck("ctid"))
  3632. {
  3633. string eids = GetPostString("ctid");
  3634. string sname = GetPostString("SupplierName");
  3635. string[] eidList = eids.Split(',');
  3636. if (eidList.Length <= 0)
  3637. {
  3638. returnErrorMsg("指派不能为空");
  3639. return;
  3640. }
  3641. List<string> tLst = new List<string>();
  3642. foreach (string ctid in eidList)
  3643. {
  3644. CeErpTradeCell entity = null;
  3645. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3646. if (entity != null)
  3647. {
  3648. entity.MakeSupplier = sname;
  3649. entity.Update();
  3650. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3651. tLst.Add("'" + ctid + "'");
  3652. }
  3653. else
  3654. {
  3655. continue;
  3656. }
  3657. }
  3658. string ctids = string.Join(",", tLst.ToArray());
  3659. StringBuilder sql2 = new StringBuilder();
  3660. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3661. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3662. returnSuccessMsg("操作成功!");
  3663. return;
  3664. }
  3665. }
  3666. public void ins_erp_returnreason()
  3667. {
  3668. if (UrlPostParmsCheck("ctid"))
  3669. {
  3670. string eid = GetPostString("ctid");
  3671. CeErpTradeCell entity = null;
  3672. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3673. string userpost = CurrentUser.UserPost.Post.Code;
  3674. if (entity != null)
  3675. {
  3676. bool isPlace = false;
  3677. if (entity.OrderState > 6)
  3678. {
  3679. returnErrorMsg("已发货无法打回!");
  3680. return;
  3681. }
  3682. if (entity.OrderState == 6)
  3683. {
  3684. isPlace = true;
  3685. }
  3686. bool isNeedUpdateCell2 = false;
  3687. if (entity.OrderState >= 6)
  3688. {
  3689. isNeedUpdateCell2 = true;
  3690. }
  3691. int returnTag = 2;
  3692. if (userpost == "Supplier")
  3693. {
  3694. returnTag = 1;
  3695. }
  3696. int toType = GetPostInt("totype");
  3697. string fromType = "3";
  3698. if (entity.OrderState < 5)
  3699. {
  3700. fromType = "3";
  3701. }
  3702. else
  3703. {
  3704. fromType = "4";
  3705. }
  3706. if (entity.IsXianHuo == 0)
  3707. {
  3708. if (returnTag == 2)
  3709. {
  3710. if (toType == 1)
  3711. {
  3712. entity.OrderState = 0;
  3713. entity.ReturnUserType = 1;
  3714. string clearman = GetPostString("clearman");
  3715. if (!string.IsNullOrEmpty(clearman))
  3716. {
  3717. entity.DesignUserId = 0;
  3718. }
  3719. }
  3720. else
  3721. {
  3722. entity.OrderState = 3;
  3723. entity.ReturnUserType = 2;
  3724. }
  3725. entity.IsReadTag = 1;
  3726. }
  3727. else if (returnTag == 1)
  3728. {
  3729. entity.OrderState = 5;
  3730. }
  3731. entity.IsVerifyToSupplier = false;
  3732. }
  3733. if (entity.IsXianHuo == 1)
  3734. {
  3735. entity.OrderState = 5;
  3736. }
  3737. entity.UnusualTag = 0;
  3738. entity.UnusualTime = null;
  3739. entity.UnusualCon = "";
  3740. entity.IsReturn = returnTag;
  3741. entity.ReturnTime = DateTime.Now;
  3742. entity.UpdateTime = DateTime.Now;
  3743. entity.ReturnReason = GetPostString("returnreason");
  3744. entity.Update();
  3745. if (entity.OrderState == 3)
  3746. {
  3747. ApiVo apiVo = new ApiVo();
  3748. apiVo.orderNumber = entity.ctid;
  3749. apiVo.actionName = "rebutDesign";
  3750. apiVo.orderRemarks = entity.ReturnReason;
  3751. designHelper.API_WorkCore(apiVo);//rebutDesign
  3752. }
  3753. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3754. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3755. {
  3756. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3757. }
  3758. CeErpSukuraData.createInfo(entity.ctid, 5);
  3759. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3760. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3761. if (isPlace)
  3762. {
  3763. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3764. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3765. if (dth != null && dth.Rows.Count > 0)
  3766. {
  3767. dataSendOrderBean dataSendOrderBean = null;
  3768. foreach (DataRow item in dth.Rows)
  3769. {
  3770. try
  3771. {
  3772. dataSendOrderBean = new dataSendOrderBean();
  3773. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3774. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3775. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3776. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3777. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3778. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3779. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3780. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3781. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3782. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3783. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3784. dataSendOrderBean.Radio1723534706288 = "打回";
  3785. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3786. if (result != null)
  3787. {
  3788. if ("0".Equals(result.errcode))
  3789. {
  3790. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3791. }
  3792. else
  3793. {
  3794. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3795. }
  3796. }
  3797. }
  3798. catch (Exception ex)
  3799. {
  3800. }
  3801. }
  3802. }
  3803. }
  3804. if (isNeedUpdateCell2)
  3805. {
  3806. if (entity.MakeSupplier.IndexOf(",") != -1)
  3807. {
  3808. StringBuilder sql2 = new StringBuilder();
  3809. 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);
  3810. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3811. }
  3812. else
  3813. {
  3814. StringBuilder sql2 = new StringBuilder();
  3815. 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);
  3816. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3817. }
  3818. }
  3819. returnSuccessMsg("操作成功!");
  3820. return;
  3821. }
  3822. returnErrorMsg("找不到订单记录");
  3823. }
  3824. }
  3825. public void cyt_erp_returnreason()
  3826. {
  3827. if (UrlPostParmsCheck("ctid"))
  3828. {
  3829. string eid = GetPostString("ctid");
  3830. CeErpTradeCell entity = null;
  3831. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3832. string userpost = CurrentUser.UserPost.Post.Code;
  3833. if (entity != null)
  3834. {
  3835. if (entity.OrderState > 6)
  3836. {
  3837. returnErrorMsg("已发货无法打回!");
  3838. return;
  3839. }
  3840. JObject jsonObject = new JObject
  3841. {
  3842. { "Userid", "77886" },
  3843. { "Pwd", "lt666888" },
  3844. { "LTOrderId",eid }
  3845. };
  3846. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3847. JObject jsonObjects = JObject.Parse(response);
  3848. string msg = (string)jsonObjects["msg"];
  3849. if (msg != "取消成功")
  3850. {
  3851. returnErrorMsg(msg);
  3852. return;
  3853. }
  3854. bool isNeedUpdateCell2 = false;
  3855. if (entity.OrderState >= 6)
  3856. {
  3857. isNeedUpdateCell2 = true;
  3858. }
  3859. int returnTag = 2;
  3860. if (userpost == "Supplier")
  3861. {
  3862. returnTag = 1;
  3863. }
  3864. if (entity.IsXianHuo == 0)
  3865. {
  3866. if (returnTag == 2)
  3867. {
  3868. int toType = GetPostInt("totype");
  3869. if (toType == 1)
  3870. {
  3871. entity.OrderState = 0;
  3872. entity.ReturnUserType = 1;
  3873. }
  3874. else
  3875. {
  3876. entity.OrderState = 4;
  3877. entity.ReturnUserType = 2;
  3878. }
  3879. entity.IsReadTag = 1;
  3880. }
  3881. else if (returnTag == 1)
  3882. {
  3883. entity.OrderState = 5;
  3884. }
  3885. entity.IsVerifyToSupplier = false;
  3886. }
  3887. entity.UnusualTag = 0;
  3888. entity.UnusualTime = null;
  3889. entity.UnusualCon = "";
  3890. entity.IsReturn = returnTag;
  3891. entity.ReturnTime = DateTime.Now;
  3892. entity.ReturnReason = GetPostString("returnreason");
  3893. entity.Update();
  3894. if (entity.OrderState == 4)
  3895. {
  3896. ApiVo apiVo = new ApiVo();
  3897. apiVo.orderNumber = entity.ctid;
  3898. apiVo.actionName = "rebutDesign";
  3899. apiVo.orderRemarks = entity.ReturnReason;
  3900. designHelper.API_WorkCore(apiVo);//rebutDesign
  3901. }
  3902. CeErpSukuraData.createInfo(entity.ctid, 5);
  3903. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3904. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3905. if (isNeedUpdateCell2)
  3906. {
  3907. if (entity.MakeSupplier.IndexOf(",") != -1)
  3908. {
  3909. StringBuilder sql2 = new StringBuilder();
  3910. 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);
  3911. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3912. }
  3913. else
  3914. {
  3915. StringBuilder sql2 = new StringBuilder();
  3916. 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);
  3917. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3918. }
  3919. }
  3920. returnSuccessMsg("操作成功!");
  3921. return;
  3922. }
  3923. returnErrorMsg("找不到订单记录");
  3924. }
  3925. }
  3926. public void upd_erp_xianhuoreturntag()
  3927. {
  3928. if (UrlPostParmsCheck("ctid"))
  3929. {
  3930. string eids = GetPostString("ctid");
  3931. string[] ctids = eids.Split(',');
  3932. foreach (string ctid in ctids)
  3933. {
  3934. CeErpTradeCell entity = null;
  3935. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3936. if (entity != null)
  3937. {
  3938. entity.IsReturn = 0;
  3939. entity.Update();
  3940. CeErpSukuraData.createInfo(entity.ctid, 5);
  3941. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3942. }
  3943. }
  3944. returnSuccessMsg("操作成功!");
  3945. return;
  3946. }
  3947. }
  3948. public void get_erp_waitdeliverylist()
  3949. {
  3950. DataStruct dStruct = GetPostStruct();
  3951. List<string> lw = new List<string>();
  3952. string tid = GetPostString("ctid");
  3953. if (tid.Length > 0)
  3954. {
  3955. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3956. if (tid.Length > 5)
  3957. {
  3958. List<string> tids = getTidByCtidLike(tid);
  3959. if (tids.Count > 0 && tids.Count < 10)
  3960. {
  3961. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3962. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  3963. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  3964. {
  3965. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  3966. }
  3967. }
  3968. }
  3969. lw.Add(tid_sql);
  3970. }
  3971. string shopname = GetPostString("shopname");
  3972. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3973. string buyernick = GetPostString("buyer_nick");
  3974. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3975. //if (tid.Length == 0 && buyernick.Length == 0)
  3976. //{
  3977. // lw.Add(string.Format("IsRefund<={0}", 1));
  3978. //}
  3979. string customer = GetPostString("customer");
  3980. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3981. string design = GetPostString("design");
  3982. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3983. string orderState = GetPostString("orderState");
  3984. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3985. string address = GetPostString("address");
  3986. 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));
  3987. string sellermemo = GetPostString("seller_memo");
  3988. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3989. string supplier = GetPostString("supplier");
  3990. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3991. string OrderArea = GetPostString("order_area");
  3992. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3993. string placedate1 = GetPostString("placedate1");
  3994. string placedate2 = GetPostString("placedate2");
  3995. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3996. if (fdw.Length > 0) lw.Add(fdw);
  3997. string price1 = GetPostString("price1");
  3998. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3999. string price2 = GetPostString("price2");
  4000. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4001. string unusualCon = GetPostString("unusualcon");
  4002. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4003. string otherMemo = GetPostString("otherMemo");
  4004. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4005. string posTag = CurrentUser.UserPost.Post.Code;
  4006. if (posTag == "Supplier")
  4007. {
  4008. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4009. }
  4010. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4011. lw.Add(string.Format("type != 'PDD' "));
  4012. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4013. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4016. writeGridDataTableJson(dStruct.TotalCount, dt);
  4017. }
  4018. public void get_erp_changedeliverylist()
  4019. {
  4020. DataStruct dStruct = GetPostStruct();
  4021. List<string> lw = new List<string>();
  4022. string tid = GetPostString("ctid");
  4023. if (tid.Length > 0)
  4024. {
  4025. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4026. if (tid.Length > 5)
  4027. {
  4028. List<string> tids = getTidByCtidLike(tid);
  4029. if (tids.Count > 0 && tids.Count < 10)
  4030. {
  4031. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4032. }
  4033. }
  4034. lw.Add(tid_sql);
  4035. }
  4036. string shopname = GetPostString("shopname");
  4037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4038. string buyernick = GetPostString("buyer_nick");
  4039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4040. //if (tid.Length == 0 && buyernick.Length == 0)
  4041. //{
  4042. // lw.Add(string.Format("IsRefund<={0}", 1));
  4043. //}
  4044. string customer = GetPostString("customer");
  4045. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4046. string design = GetPostString("design");
  4047. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4048. string orderState = GetPostString("orderState");
  4049. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4050. string address = GetPostString("address");
  4051. 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));
  4052. string sellermemo = GetPostString("seller_memo");
  4053. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4054. string supplier = GetPostString("supplier");
  4055. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4056. string OrderArea = GetPostString("order_area");
  4057. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4058. string placedate1 = GetPostString("placedate1");
  4059. string placedate2 = GetPostString("placedate2");
  4060. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4061. if (fdw.Length > 0) lw.Add(fdw);
  4062. string price1 = GetPostString("price1");
  4063. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4064. string price2 = GetPostString("price2");
  4065. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4066. string unusualCon = GetPostString("unusualcon");
  4067. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4068. string otherMemo = GetPostString("otherMemo");
  4069. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4070. string posTag = CurrentUser.UserPost.Post.Code;
  4071. if (posTag == "Supplier")
  4072. {
  4073. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4074. }
  4075. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4076. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4077. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4078. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4079. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4080. /*if (tid.Length > 0)
  4081. {
  4082. List<string> tids = new List<string>();
  4083. if (dt != null && dt.Rows.Count > 0)
  4084. {
  4085. foreach (DataRow item in dt.Rows)
  4086. {
  4087. tids.Add("'" + item["tid"] + "'");
  4088. }
  4089. }
  4090. if (tids.Count > 0)
  4091. {
  4092. lw.RemoveAt(0);
  4093. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4094. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4095. dt = WebCache.GetData("view_erptradecell", dStruct);
  4096. }
  4097. }*/
  4098. writeGridDataTableJson(dStruct.TotalCount, dt);
  4099. }
  4100. public void get_erp_pddderiving()
  4101. {
  4102. DataStruct dStruct = GetPostStruct();
  4103. List<string> lw = new List<string>();
  4104. string tid = GetPostString("ctid");
  4105. if (tid.Length > 0)
  4106. {
  4107. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4108. if (tid.Length > 5)
  4109. {
  4110. List<string> tids = getTidByCtidLike(tid);
  4111. if (tids.Count > 0 && tids.Count < 10)
  4112. {
  4113. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4114. List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4115. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4116. {
  4117. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4118. }
  4119. }
  4120. }
  4121. lw.Add(tid_sql);
  4122. }
  4123. string shopname = GetPostString("shopname");
  4124. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4125. string buyernick = GetPostString("buyer_nick");
  4126. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4127. //if (tid.Length == 0 && buyernick.Length == 0)
  4128. //{
  4129. // lw.Add(string.Format("IsRefund<={0}", 1));
  4130. //}
  4131. string customer = GetPostString("customer");
  4132. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4133. string design = GetPostString("design");
  4134. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4135. string orderState = GetPostString("orderState");
  4136. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4137. string address = GetPostString("address");
  4138. if (address.Length > 0) lw.Add(string.Format("(receiver_address like '%{0}%' or receiver_state like '%{0}%' or receiver_city like '%{0}%' or receiver_name like '%{0}%' or receiver_mobile like '%{0}%')", address));
  4139. string sellermemo = GetPostString("seller_memo");
  4140. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4141. string supplier = GetPostString("supplier");
  4142. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4143. string OrderArea = GetPostString("order_area");
  4144. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4145. string placedate1 = GetPostString("placedate1");
  4146. string placedate2 = GetPostString("placedate2");
  4147. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4148. if (fdw.Length > 0) lw.Add(fdw);
  4149. string price1 = GetPostString("price1");
  4150. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4151. string price2 = GetPostString("price2");
  4152. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4153. string unusualCon = GetPostString("unusualcon");
  4154. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4155. string posTag = CurrentUser.UserPost.Post.Code;
  4156. if (posTag == "Supplier")
  4157. {
  4158. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4159. }
  4160. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4161. lw.Add(string.Format("type = 'PDD' "));
  4162. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4163. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4164. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4165. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4166. /*if (tid.Length > 0)
  4167. {
  4168. List<string> tids = new List<string>();
  4169. if (dt != null && dt.Rows.Count > 0)
  4170. {
  4171. foreach (DataRow item in dt.Rows)
  4172. {
  4173. tids.Add("'" + item["tid"] + "'");
  4174. }
  4175. }
  4176. if (tids.Count > 0)
  4177. {
  4178. lw.RemoveAt(0);
  4179. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4180. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4181. dt = WebCache.GetData("view_erptradecell", dStruct);
  4182. }
  4183. }*/
  4184. writeGridDataTableJson(dStruct.TotalCount, dt);
  4185. }
  4186. public void get_erp_jdderiving()
  4187. {
  4188. DataStruct dStruct = GetPostStruct();
  4189. List<string> lw = new List<string>();
  4190. string tid = GetPostString("ctid");
  4191. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4192. string shopname = GetPostString("shopname");
  4193. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4194. string buyernick = GetPostString("buyer_nick");
  4195. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4196. //if (tid.Length == 0 && buyernick.Length == 0)
  4197. //{
  4198. // lw.Add(string.Format("IsRefund<={0}", 1));
  4199. //}
  4200. string customer = GetPostString("customer");
  4201. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4202. string design = GetPostString("design");
  4203. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4204. string orderState = GetPostString("orderState");
  4205. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4206. string address = GetPostString("address");
  4207. 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));
  4208. string sellermemo = GetPostString("seller_memo");
  4209. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4210. string supplier = GetPostString("supplier");
  4211. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4212. string OrderArea = GetPostString("order_area");
  4213. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4214. string placedate1 = GetPostString("placedate1");
  4215. string placedate2 = GetPostString("placedate2");
  4216. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4217. if (fdw.Length > 0) lw.Add(fdw);
  4218. string price1 = GetPostString("price1");
  4219. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4220. string price2 = GetPostString("price2");
  4221. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4222. string unusualCon = GetPostString("unusualcon");
  4223. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4224. string posTag = CurrentUser.UserPost.Post.Code;
  4225. if (posTag == "Supplier")
  4226. {
  4227. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4228. }
  4229. lw.Add(string.Format("OrderState = 6 "));
  4230. lw.Add(string.Format("type = 'JD' "));
  4231. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4232. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4234. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4235. writeGridDataTableJson(dStruct.TotalCount, dt);
  4236. }
  4237. public void get_erp_demoorderlist()
  4238. {
  4239. DataStruct dStruct = GetPostStruct();
  4240. List<string> lw = new List<string>();
  4241. string tid = GetPostString("ctid");
  4242. if (tid.Length > 0)
  4243. {
  4244. string select_tid = getTidByCtid(tid);
  4245. lw.Add(string.Format("tid='{0}'", select_tid));
  4246. }
  4247. string shopname = GetPostString("shopname");
  4248. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4249. string buyernick = GetPostString("buyer_nick");
  4250. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  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("address 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 date1 = GetPostString("date1");
  4266. string date2 = GetPostString("date2");
  4267. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4268. if (dw.Length > 0) lw.Add(dw);
  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 posTag = CurrentUser.UserPost.Post.Code;
  4274. if (posTag == "Supplier")
  4275. {
  4276. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4277. }
  4278. //lw.Add(string.Format("OrderState = 6 "));
  4279. lw.Add(string.Format("IsSample={0}", 3));
  4280. lw.Add(string.Format("IsRefund<={0}", 1));
  4281. dStruct.Order = "pay_time desc";
  4282. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4283. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4284. writeGridDataTableJson(dStruct.TotalCount, dt);
  4285. }
  4286. public void save_erp_checkmemo()
  4287. {
  4288. if (UrlPostParmsCheck("ctid"))
  4289. {
  4290. string ctid = GetPostString("ctid");
  4291. CeErpTradeCell entity = null;
  4292. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4293. if (entity != null)
  4294. {
  4295. entity.CheckMemo = GetPostString("CheckMemo");
  4296. entity.Update();
  4297. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4298. if (trade != null)
  4299. {
  4300. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4301. }
  4302. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4303. returnSuccessMsg("保存成功!");
  4304. return;
  4305. }
  4306. returnErrorMsg("找不到记录");
  4307. }
  4308. }
  4309. public void get_erp_returnlist()
  4310. {
  4311. DataStruct dStruct = GetPostStruct();
  4312. List<string> lw = new List<string>();
  4313. string tid = GetPostString("ctid");
  4314. if (tid.Length > 0)
  4315. {
  4316. string select_tid = getTidByCtid(tid);
  4317. lw.Add(string.Format("tid='{0}'", select_tid));
  4318. }
  4319. string shopname = GetPostString("shopname");
  4320. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4321. string buyernick = GetPostString("buyer_nick");
  4322. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4323. string customer = GetPostString("customer");
  4324. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4325. string design = GetPostString("design");
  4326. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4327. string orderState = GetPostString("orderState");
  4328. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4329. string address = GetPostString("address");
  4330. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4331. string sellermemo = GetPostString("seller_memo");
  4332. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4333. string supplier = GetPostString("supplier");
  4334. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4335. string date1 = GetPostString("date1");
  4336. string date2 = GetPostString("date2");
  4337. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4338. if (dw.Length > 0) lw.Add(dw);
  4339. string bdate1 = GetPostString("backdate1");
  4340. string bdate2 = GetPostString("backdate2");
  4341. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4342. if (dw_back.Length > 0) lw.Add(dw_back);
  4343. string price1 = GetPostString("price1");
  4344. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4345. string price2 = GetPostString("price2");
  4346. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4347. lw.Add(string.Format("IsReturn>0"));
  4348. lw.Add(string.Format("IsXianHuo=0"));
  4349. lw.Add(string.Format("IsReturn!=3"));
  4350. string backtype = GetPostString("backtype");
  4351. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4352. dStruct.Order = "FinishDesignTime 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_today_sumreturn()
  4358. {
  4359. DataStruct dStruct = GetPostStruct();
  4360. List<string> lw = new List<string>();
  4361. string bdate1 = GetPostString("returnTimeS");
  4362. string bdate2 = GetPostString("returnTimeE");
  4363. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4364. if (dw_back.Length > 0) lw.Add(dw_back);
  4365. lw.Add(string.Format("IsReturn=0"));
  4366. lw.Add(string.Format("IsXianHuo=0"));
  4367. string mainWhere = string.Join(" and ", lw.ToArray());
  4368. string sql = "";
  4369. if (dw_back.Length > 0)
  4370. {
  4371. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4372. }
  4373. else
  4374. {
  4375. 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 + "'";
  4376. }
  4377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4378. decimal total = 0, today_finish = 0;
  4379. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4380. {
  4381. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4382. }
  4383. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4384. {
  4385. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4386. }
  4387. var res = new
  4388. {
  4389. data = total,
  4390. data1 = today_finish,
  4391. };
  4392. string ro_jsond = JsonConvert.SerializeObject(res);
  4393. returnSuccess(ro_jsond);
  4394. return;
  4395. }
  4396. public void get_erp_allreturnlist()
  4397. {
  4398. DataStruct dStruct = GetPostStruct();
  4399. List<string> lw = new List<string>();
  4400. string tid = GetPostString("ctid");
  4401. if (tid.Length > 0)
  4402. {
  4403. string select_tid = getTidByCtid(tid);
  4404. lw.Add(string.Format("tid='{0}'", select_tid));
  4405. }
  4406. string shopname = GetPostString("shopname");
  4407. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4408. string buyernick = GetPostString("buyer_nick");
  4409. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4410. string customer = GetPostString("customer");
  4411. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4412. string design = GetPostString("design");
  4413. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4414. string orderState = GetPostString("orderState");
  4415. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4416. string address = GetPostString("address");
  4417. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4418. string sellermemo = GetPostString("seller_memo");
  4419. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4420. string supplier = GetPostString("supplier");
  4421. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4422. string date1 = GetPostString("date1");
  4423. string date2 = GetPostString("date2");
  4424. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4425. if (dw.Length > 0) lw.Add(dw);
  4426. string bdate1 = GetPostString("backdate1");
  4427. string bdate2 = GetPostString("backdate2");
  4428. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4429. if (dw_back.Length > 0) lw.Add(dw_back);
  4430. string price1 = GetPostString("price1");
  4431. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4432. string price2 = GetPostString("price2");
  4433. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4434. string backreason = GetPostString("backreason");
  4435. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4436. lw.Add(string.Format("IsXianHuo=0"));
  4437. lw.Add(string.Format("ReturnTime != ''"));
  4438. string backtype = GetPostString("backtype");
  4439. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4440. dStruct.Order = "FinishDesignTime desc";
  4441. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4442. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4443. writeGridDataTableJson(dStruct.TotalCount, dt);
  4444. }
  4445. public void get_erp_aftersalereturnlist()
  4446. {
  4447. DataStruct dStruct = GetPostStruct();
  4448. List<string> lw = new List<string>();
  4449. string tid = GetPostString("ctid");
  4450. if (tid.Length > 0)
  4451. {
  4452. string select_tid = getTidByCtid(tid);
  4453. lw.Add(string.Format("tid='{0}'", select_tid));
  4454. }
  4455. string shopname = GetPostString("shopname");
  4456. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4457. string buyernick = GetPostString("buyer_nick");
  4458. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4459. string customer = GetPostString("customer");
  4460. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4461. string design = GetPostString("design");
  4462. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4463. string orderState = GetPostString("orderState");
  4464. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4465. string address = GetPostString("address");
  4466. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4467. string sellermemo = GetPostString("seller_memo");
  4468. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4469. string supplier = GetPostString("supplier");
  4470. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4471. string date1 = GetPostString("date1");
  4472. string date2 = GetPostString("date2");
  4473. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4474. if (dw.Length > 0) lw.Add(dw);
  4475. string bdate1 = GetPostString("backdate1");
  4476. string bdate2 = GetPostString("backdate2");
  4477. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4478. if (dw_back.Length > 0) lw.Add(dw_back);
  4479. string price1 = GetPostString("price1");
  4480. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4481. string price2 = GetPostString("price2");
  4482. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4483. lw.Add(string.Format("IsReturn=3"));
  4484. string backtype = GetPostString("backtype");
  4485. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4486. string backreason = GetPostString("backreason");
  4487. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4488. dStruct.Order = "ReturnTime desc";
  4489. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4490. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4491. writeGridDataTableJson(dStruct.TotalCount, dt);
  4492. }
  4493. public void get_erp_xianhuoreturnlist()
  4494. {
  4495. DataStruct dStruct = GetPostStruct();
  4496. List<string> lw = new List<string>();
  4497. string tid = GetPostString("ctid");
  4498. if (tid.Length > 0)
  4499. {
  4500. string select_tid = getTidByCtid(tid);
  4501. lw.Add(string.Format("tid='{0}'", select_tid));
  4502. }
  4503. string shopname = GetPostString("shopname");
  4504. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4505. string buyernick = GetPostString("buyer_nick");
  4506. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4507. string customer = GetPostString("customer");
  4508. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4509. string design = GetPostString("design");
  4510. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4511. string orderState = GetPostString("orderState");
  4512. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4513. string address = GetPostString("address");
  4514. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4515. string sellermemo = GetPostString("seller_memo");
  4516. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4517. string supplier = GetPostString("supplier");
  4518. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4519. string OrderArea = GetPostString("order_area");
  4520. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4521. string date1 = GetPostString("date1");
  4522. string date2 = GetPostString("date2");
  4523. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4524. if (dw.Length > 0) lw.Add(dw);
  4525. string price1 = GetPostString("price1");
  4526. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4527. string price2 = GetPostString("price2");
  4528. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4529. string posTag = CurrentUser.UserPost.Post.Code;
  4530. if (posTag == "Supplier")
  4531. {
  4532. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4533. }
  4534. lw.Add(string.Format("OrderState=6 "));
  4535. lw.Add(string.Format("IsXianHuo=1 "));
  4536. lw.Add(string.Format("IsReturn>0 "));
  4537. lw.Add(string.Format("IsReturn!=3"));
  4538. lw.Add(string.Format("IsRefund<={0}", 1));
  4539. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4540. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4541. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4542. writeGridDataTableJson(dStruct.TotalCount, dt);
  4543. }
  4544. public void set_erp_orderdelivery()
  4545. {
  4546. if (UrlPostParmsCheck("ctid"))
  4547. {
  4548. string eid = GetPostString("ctid");
  4549. CeErpTradeCell entity = null;
  4550. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4551. if (entity != null)
  4552. {
  4553. if (entity.OrderState >= 7)
  4554. {
  4555. returnErrorMsg("此单已发货,无需重复发货");
  4556. return;
  4557. }
  4558. if (entity.OrderState != 6)
  4559. {
  4560. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4561. return;
  4562. }
  4563. string shop = GetPostString("seller_nick");
  4564. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4565. string comName = GetPostString("comName");
  4566. string comCode = GetPostString("comCode");
  4567. string outSid = GetPostString("outSid");
  4568. string deliveryType = GetPostString("deliveryType");
  4569. string deliveryMemo = GetPostString("deliveryMemo");
  4570. outSid = outSid.Trim();
  4571. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4572. if (mainEn == null)
  4573. {
  4574. returnErrorMsg("找不到原始订单记录");
  4575. return;
  4576. }
  4577. bool isInitOrderDeliv = false;
  4578. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4579. {
  4580. isInitOrderDeliv = true;
  4581. }
  4582. string apires = "";
  4583. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4584. 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)
  4585. {
  4586. apires = "发货成功true";
  4587. }
  4588. else
  4589. {
  4590. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4591. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4592. }
  4593. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4594. {
  4595. entity.OrderState = 7;//发货后订单已发货
  4596. entity.OutSid = outSid;
  4597. entity.MemoOpt = 0;
  4598. entity.UpdateTime = DateTime.Now;
  4599. entity.FinishDeliveryTime = DateTime.Now;
  4600. entity.Update();
  4601. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4602. commonHelper.UpdateRelationOrder(entity.ctid);
  4603. //还要插入快递信息到 快递信息表
  4604. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4605. exinfo.tid = eid;
  4606. exinfo.out_sid = outSid;
  4607. exinfo.company_code = comCode;
  4608. exinfo.company_name = comName;
  4609. exinfo.delivery_memo = deliveryMemo;
  4610. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4611. exinfo.deliveryType = deliveryType;
  4612. exinfo.Create();
  4613. returnSuccessMsg("发货操作成功!");
  4614. commonHelper.UpdateRelationOrder(entity.ctid);
  4615. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4616. CeErpSukuraData.createInfo(entity.ctid, 4);
  4617. if (entity.SupplierId == 64)
  4618. {
  4619. commonHelper.sendCytExpress(exinfo);
  4620. }
  4621. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4622. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4623. }
  4624. else
  4625. {
  4626. string errmsg = commonHelper.KeepChinese(apires);
  4627. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4628. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4629. }
  4630. return;
  4631. }
  4632. returnErrorMsg("找不到订单记录");
  4633. }
  4634. }
  4635. public void set_erp_multidelivery()
  4636. {
  4637. string eids = GetPostString("tids");
  4638. string[] eidList = eids.Split(',');
  4639. if (eidList.Length <= 0)
  4640. {
  4641. returnErrorMsg("发货不能为空");
  4642. return;
  4643. }
  4644. foreach (string ctid in eidList)
  4645. {
  4646. if (ctid.Length <= 0) continue;
  4647. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4648. if (expInfo != null)
  4649. {
  4650. StringBuilder sql = new StringBuilder();
  4651. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4652. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4653. if (dt.Rows.Count > 0)
  4654. {
  4655. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4656. {
  4657. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4658. expInfo.state = "异常";
  4659. expInfo.isMultiDelivery = 1;
  4660. expInfo.Update();
  4661. continue;
  4662. }
  4663. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4664. {
  4665. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4666. expInfo.state = "异常";
  4667. expInfo.Update();
  4668. continue;
  4669. }
  4670. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4671. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4672. bool isInitOrderDeliv = false;
  4673. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4674. {
  4675. isInitOrderDeliv = true;
  4676. expInfo.isMultiDelivery = 1;
  4677. }
  4678. if (ctid.IndexOf("N") != -1)
  4679. {
  4680. StringBuilder sqlbucha = new StringBuilder();
  4681. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4682. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4683. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4684. commonHelper.UpdateRelationOrder(ctid);
  4685. expInfo.delivery_memo = "发货成功";
  4686. expInfo.state = "发货成功";
  4687. expInfo.isMultiDelivery = 1;
  4688. expInfo.Update();
  4689. }
  4690. else
  4691. {
  4692. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4693. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4694. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4695. {
  4696. expInfo.delivery_memo = "发货成功";
  4697. expInfo.state = "发货成功";
  4698. expInfo.isMultiDelivery = 1;
  4699. expInfo.Update();
  4700. commonHelper.UpdateRelationOrder(ctid);
  4701. CeErpSukuraData.createInfo(ctid, 4);
  4702. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4703. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4704. }
  4705. else
  4706. {
  4707. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4708. expInfo.state = "异常";
  4709. expInfo.Update();
  4710. }
  4711. }
  4712. }
  4713. }
  4714. }
  4715. returnSuccessMsg("操作完成");
  4716. }
  4717. public void reset_erp_memoopt()
  4718. {
  4719. if (UrlPostParmsCheck("ctid"))
  4720. {
  4721. string eid = GetPostString("ctid");
  4722. CeErpTradeCell entity = null;
  4723. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4724. if (entity != null)
  4725. {
  4726. string stropt = "";
  4727. if (entity.MemoOpt == 1)
  4728. {
  4729. stropt = "“改稿”";
  4730. }
  4731. else if (entity.MemoOpt == 2)
  4732. {
  4733. stropt = "“定稿”";
  4734. }
  4735. else if (entity.MemoOpt == 3)
  4736. {
  4737. stropt = "“完成查货”";
  4738. CeErpSukuraData.createInfo(entity.ctid, 6);
  4739. }
  4740. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4741. entity.UpdateTime = DateTime.Now;
  4742. entity.MemoOpt = 0;
  4743. entity.Update();
  4744. returnSuccessMsg("操作成功!");
  4745. return;
  4746. }
  4747. returnErrorMsg("找不到记录");
  4748. }
  4749. }
  4750. public void get_erp_deliveryunusual()
  4751. {
  4752. DataStruct dStruct = GetPostStruct();
  4753. List<string> lw = new List<string>();
  4754. string tid = GetPostString("ctid");
  4755. if (tid.Length > 0)
  4756. {
  4757. string select_tid = getTidByCtid(tid);
  4758. lw.Add(string.Format("tid='{0}'", select_tid));
  4759. }
  4760. string shopname = GetPostString("shopname");
  4761. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4762. string buyernick = GetPostString("buyer_nick");
  4763. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4764. string customer = GetPostString("customer");
  4765. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4766. string design = GetPostString("design");
  4767. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4768. string sellermemo = GetPostString("seller_memo");
  4769. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4770. string supplier = GetPostString("supplier");
  4771. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4772. string date1 = GetPostString("date1");
  4773. string date2 = GetPostString("date2");
  4774. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4775. if (dw.Length > 0) lw.Add(dw);
  4776. string placedate1 = GetPostString("placedate1");
  4777. string placedate2 = GetPostString("placedate2");
  4778. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4779. if (dw_place.Length > 0) lw.Add(dw_place);
  4780. string price1 = GetPostString("price1");
  4781. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4782. string price2 = GetPostString("price2");
  4783. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4784. string unusualCon = GetPostString("unusualcon");
  4785. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4786. string posTag = CurrentUser.UserPost.Post.Code;
  4787. if (posTag == "Supplier")
  4788. {
  4789. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4790. }
  4791. lw.Add(string.Format("OrderState = 6"));
  4792. lw.Add(string.Format("UnusualTag = 5"));
  4793. lw.Add(string.Format("IsRefund<={0}", 1));
  4794. dStruct.Order = "FinishPlaceTime desc";
  4795. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4796. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4797. writeGridDataTableJson(dStruct.TotalCount, dt);
  4798. }
  4799. public void get_erp_deliveryedlist()
  4800. {
  4801. DataStruct dStruct = GetPostStruct();
  4802. List<string> lw = new List<string>();
  4803. string tid = GetPostString("ctid");
  4804. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4805. string shopname = GetPostString("shopname");
  4806. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4807. string buyernick = GetPostString("buyer_nick");
  4808. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4809. string customer = GetPostString("customer");
  4810. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4811. string design = GetPostString("design");
  4812. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4813. string sellermemo = GetPostString("seller_memo");
  4814. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4815. string logistics = GetPostString("logistics");
  4816. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4817. string date1 = GetPostString("date1");
  4818. string date2 = GetPostString("date2");
  4819. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4820. //if (dw.Length > 0) lw.Add(dw);
  4821. string placedate1 = GetPostString("placedate1");
  4822. string placedate2 = GetPostString("placedate2");
  4823. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4824. if (fdw.Length > 0) lw.Add(fdw);
  4825. string devdate1 = GetPostString("deliverydate1");
  4826. string devdate2 = GetPostString("deliverydate2");
  4827. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4828. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4829. string price1 = GetPostString("price1");
  4830. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4831. string price2 = GetPostString("price2");
  4832. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4833. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4834. {
  4835. if (tid.Length > 0)
  4836. {
  4837. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4838. if (tid.Length > 5)
  4839. {
  4840. List<string> tids = getTidByCtidLike(tid);
  4841. if (tids.Count > 0 && tids.Count < 10)
  4842. {
  4843. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4844. }
  4845. }
  4846. lw.Add(tid_sql);
  4847. }
  4848. if (buyernick.Length > 0)
  4849. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4850. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4851. if (dw.Length > 0) lw.Add(dw);
  4852. }
  4853. else
  4854. {
  4855. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4856. }
  4857. string posTag = CurrentUser.UserPost.Post.Code;
  4858. if (posTag == "Supplier")
  4859. {
  4860. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4861. }
  4862. else
  4863. {
  4864. string supplier = GetPostString("supplier");
  4865. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4866. }
  4867. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4868. lw.Add(string.Format("type != 'PDD' "));
  4869. lw.Add(string.Format("IsRefund!={0}", 2));
  4870. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4871. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4872. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4873. /*if (tid.Length > 0)
  4874. {
  4875. List<string> tids = new List<string>();
  4876. if (dt != null && dt.Rows.Count > 0)
  4877. {
  4878. foreach (DataRow item in dt.Rows)
  4879. {
  4880. tids.Add("'" + item["tid"] + "'");
  4881. }
  4882. }
  4883. if (tids.Count > 0)
  4884. {
  4885. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4886. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4887. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4888. dt = WebCache.GetData("view_erptradecell", dStruct);
  4889. }
  4890. }*/
  4891. if (dt != null)
  4892. {
  4893. foreach (DataRow dr in dt.Rows)
  4894. {
  4895. 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();
  4896. }
  4897. }
  4898. writeGridDataTableJson(dStruct.TotalCount, dt);
  4899. }
  4900. public void get_erp_pdddeliveryed()
  4901. {
  4902. DataStruct dStruct = GetPostStruct();
  4903. List<string> lw = new List<string>();
  4904. string tid = GetPostString("ctid");
  4905. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4906. string shopname = GetPostString("shopname");
  4907. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4908. string buyernick = GetPostString("buyer_nick");
  4909. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4910. string customer = GetPostString("customer");
  4911. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4912. string design = GetPostString("design");
  4913. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4914. string sellermemo = GetPostString("seller_memo");
  4915. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4916. string logistics = GetPostString("logistics");
  4917. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4918. string date1 = GetPostString("date1");
  4919. string date2 = GetPostString("date2");
  4920. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4921. //if (dw.Length > 0) lw.Add(dw);
  4922. string placedate1 = GetPostString("placedate1");
  4923. string placedate2 = GetPostString("placedate2");
  4924. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4925. if (fdw.Length > 0) lw.Add(fdw);
  4926. string devdate1 = GetPostString("deliverydate1");
  4927. string devdate2 = GetPostString("deliverydate2");
  4928. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4929. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4930. string price1 = GetPostString("price1");
  4931. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4932. string price2 = GetPostString("price2");
  4933. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4934. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4935. {
  4936. if (tid.Length > 0)
  4937. {
  4938. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4939. if (tid.Length > 5)
  4940. {
  4941. List<string> tids = getTidByCtidLike(tid);
  4942. if (tids.Count > 0 && tids.Count < 10)
  4943. {
  4944. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4945. }
  4946. }
  4947. lw.Add(tid_sql);
  4948. }
  4949. if (buyernick.Length > 0)
  4950. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4951. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4952. if (dw.Length > 0) lw.Add(dw);
  4953. }
  4954. else
  4955. {
  4956. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4957. }
  4958. string posTag = CurrentUser.UserPost.Post.Code;
  4959. if (posTag == "Supplier")
  4960. {
  4961. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4962. }
  4963. else
  4964. {
  4965. string supplier = GetPostString("supplier");
  4966. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4967. }
  4968. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4969. lw.Add(string.Format("type = 'PDD' "));
  4970. lw.Add(string.Format("IsRefund!={0}", 2));
  4971. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4972. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4973. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4974. /* if (tid.Length > 0)
  4975. {
  4976. List<string> tids = new List<string>();
  4977. if (dt != null && dt.Rows.Count > 0)
  4978. {
  4979. foreach (DataRow item in dt.Rows)
  4980. {
  4981. tids.Add("'" + item["tid"] + "'");
  4982. }
  4983. }
  4984. if (tids.Count > 0)
  4985. {
  4986. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4987. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4988. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4989. dt = WebCache.GetData("view_erptradecell", dStruct);
  4990. }
  4991. }*/
  4992. foreach (DataRow dr in dt.Rows)
  4993. {
  4994. 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();
  4995. }
  4996. writeGridDataTableJson(dStruct.TotalCount, dt);
  4997. }
  4998. public void get_erp_jddeliveryed()
  4999. {
  5000. DataStruct dStruct = GetPostStruct();
  5001. List<string> lw = new List<string>();
  5002. string tid = GetPostString("ctid");
  5003. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5004. string shopname = GetPostString("shopname");
  5005. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5006. string buyernick = GetPostString("buyer_nick");
  5007. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5008. string customer = GetPostString("customer");
  5009. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5010. string design = GetPostString("design");
  5011. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5012. string sellermemo = GetPostString("seller_memo");
  5013. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5014. string date1 = GetPostString("date1");
  5015. string date2 = GetPostString("date2");
  5016. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5017. //if (dw.Length > 0) lw.Add(dw);
  5018. string placedate1 = GetPostString("placedate1");
  5019. string placedate2 = GetPostString("placedate2");
  5020. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5021. if (fdw.Length > 0) lw.Add(fdw);
  5022. string devdate1 = GetPostString("deliverydate1");
  5023. string devdate2 = GetPostString("deliverydate2");
  5024. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5025. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5026. string price1 = GetPostString("price1");
  5027. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5028. string price2 = GetPostString("price2");
  5029. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5030. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5031. {
  5032. if (tid.Length > 0)
  5033. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5034. if (buyernick.Length > 0)
  5035. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5036. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5037. if (dw.Length > 0) lw.Add(dw);
  5038. }
  5039. else
  5040. {
  5041. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5042. }
  5043. string posTag = CurrentUser.UserPost.Post.Code;
  5044. if (posTag == "Supplier")
  5045. {
  5046. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5047. }
  5048. else
  5049. {
  5050. string supplier = GetPostString("supplier");
  5051. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5052. }
  5053. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5054. lw.Add(string.Format("type = 'JD' "));
  5055. lw.Add(string.Format("IsRefund!={0}", 2));
  5056. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5057. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5058. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5059. foreach (DataRow dr in dt.Rows)
  5060. {
  5061. 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();
  5062. }
  5063. writeGridDataTableJson(dStruct.TotalCount, dt);
  5064. }
  5065. public void get_erp_allplacelist()
  5066. {
  5067. DataStruct dStruct = GetPostStruct();
  5068. List<string> lw = new List<string>();
  5069. string tid = GetPostString("ctid");
  5070. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5071. string shopname = GetPostString("shopname");
  5072. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5073. string buyernick = GetPostString("buyer_nick");
  5074. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5075. string customer = GetPostString("customer");
  5076. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5077. string design = GetPostString("design");
  5078. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5079. string sellermemo = GetPostString("seller_memo");
  5080. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5081. string supplier = GetPostString("supplier");
  5082. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5083. string date1 = GetPostString("date1");
  5084. string date2 = GetPostString("date2");
  5085. string pldate1 = GetPostString("placedate1");
  5086. string pldate2 = GetPostString("placedate2");
  5087. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5088. //if (dw.Length > 0) lw.Add(dw);
  5089. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5090. {
  5091. if (tid.Length > 0)
  5092. {
  5093. string select_tid = getTidByCtid(tid);
  5094. lw.Add(string.Format("tid='{0}'", select_tid));
  5095. }
  5096. if (buyernick.Length > 0)
  5097. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5098. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5099. if (dw.Length > 0) lw.Add(dw);
  5100. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5101. if (dw_place.Length > 0) lw.Add(dw_place);
  5102. }
  5103. else
  5104. {
  5105. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5106. {
  5107. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5108. }
  5109. }
  5110. string price1 = GetPostString("price1");
  5111. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5112. string price2 = GetPostString("price2");
  5113. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5114. string posTag = CurrentUser.UserPost.Post.Code;
  5115. if (posTag == "Supplier")
  5116. {
  5117. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5118. }
  5119. lw.Add(string.Format("OrderState >= 6"));
  5120. lw.Add(string.Format("IsSample != 2 "));
  5121. //lw.Add(string.Format("isDianziOrder = 0 "));
  5122. lw.Add(string.Format("SupplierId > 0 "));
  5123. //lw.Add(string.Format("IsRefund<={0}", 1));
  5124. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5125. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5126. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5127. foreach (DataRow dr in dt.Rows)
  5128. {
  5129. 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();
  5130. }
  5131. writeGridDataTableJson(dStruct.TotalCount, dt);
  5132. }
  5133. public void get_erp_financeallplacelist()
  5134. {
  5135. DataStruct dStruct = GetPostStruct();
  5136. List<string> lw = new List<string>();
  5137. string tid = GetPostString("ctid");
  5138. string shopname = GetPostString("shopname");
  5139. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5140. string buyernick = GetPostString("buyer_nick");
  5141. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5142. string customer = GetPostString("customer");
  5143. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5144. string design = GetPostString("design");
  5145. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5146. string sellermemo = GetPostString("seller_memo");
  5147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5148. string supplier = GetPostString("supplier");
  5149. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5150. string date1 = GetPostString("date1");
  5151. string date2 = GetPostString("date2");
  5152. string pldate1 = GetPostString("placedate1");
  5153. string pldate2 = GetPostString("placedate2");
  5154. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5155. {
  5156. if (tid.Length > 0)
  5157. {
  5158. string select_tid = getTidByCtid(tid);
  5159. lw.Add(string.Format("tid='{0}'", select_tid));
  5160. }
  5161. if (buyernick.Length > 0)
  5162. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5163. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5164. if (dw.Length > 0) lw.Add(dw);
  5165. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5166. if (dw_place.Length > 0) lw.Add(dw_place);
  5167. }
  5168. else
  5169. {
  5170. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5171. {
  5172. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5173. }
  5174. }
  5175. string price1 = GetPostString("price1");
  5176. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5177. string price2 = GetPostString("price2");
  5178. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5179. string posTag = CurrentUser.UserPost.Post.Code;
  5180. if (posTag == "Supplier")
  5181. {
  5182. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5183. }
  5184. //lw.Add(string.Format("OrderState >= 6"));
  5185. lw.Add(string.Format("IsSample != 2 "));
  5186. lw.Add(string.Format("isDianziOrder = 0 "));
  5187. //lw.Add(string.Format("IsRefund<={0}", 1));
  5188. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5190. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5191. foreach (DataRow dr in dt.Rows)
  5192. {
  5193. 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();
  5194. }
  5195. writeGridDataTableJson(dStruct.TotalCount, dt);
  5196. }
  5197. public void get_erp_expresslist()
  5198. {
  5199. int listtype = GetInt("ltype");
  5200. DataStruct dStruct = GetPostStruct();
  5201. List<string> lw = new List<string>();
  5202. string tid = GetPostString("tid");
  5203. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5204. string outsid = GetPostString("out_sid");
  5205. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5206. string importer = GetPostString("ImportUserName");
  5207. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5208. string file = GetPostString("import_file");
  5209. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5210. string printman = GetPostString("printman");
  5211. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5212. string date1 = GetPostString("date1");
  5213. string date2 = GetPostString("date2");
  5214. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5215. if (dw.Length > 0) lw.Add(dw);
  5216. string fdate1 = GetPostString("finishdate1");
  5217. string fdate2 = GetPostString("finishdate2");
  5218. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5219. if (fdw.Length > 0) lw.Add(fdw);
  5220. string supplierId = GetPostString("supplierId");
  5221. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5222. if (listtype == 1)
  5223. {
  5224. lw.Add(string.Format("importUserId !=0"));
  5225. }
  5226. string posTag = CurrentUser.UserPost.Post.Code;
  5227. if (posTag == "Supplier")
  5228. {
  5229. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5230. }
  5231. if (dStruct.PageSize != 100000)
  5232. {
  5233. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5234. }
  5235. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5236. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5237. writeGridDataTableJson(dStruct.TotalCount, dt);
  5238. }
  5239. public void set_erp_buchaorderdelivery()
  5240. {
  5241. if (UrlPostParmsCheck("ctid"))
  5242. {
  5243. string eid = GetPostString("ctid");
  5244. CeErpTradeCell entity = null;
  5245. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5246. if (entity != null)
  5247. {
  5248. if (entity.IsSample != 2)
  5249. {
  5250. returnErrorMsg("补差价单才能标记为已发货");
  5251. return;
  5252. }
  5253. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5254. entity.OrderState = 7;
  5255. entity.Update();
  5256. returnSuccessMsg("操作成功!");
  5257. return;
  5258. }
  5259. returnErrorMsg("找不到记录");
  5260. }
  5261. }
  5262. public void get_stdtemplates()
  5263. {
  5264. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5265. //string res = taobaoHelper.test();
  5266. string res = apiHelper.API_PrintTemplate();
  5267. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5268. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5269. {
  5270. int sidx = res.IndexOf("error_code");
  5271. int eidx = res.IndexOf("success");
  5272. string msg = res.Substring(sidx, eidx - sidx);
  5273. returnErrorMsg(msg);
  5274. return;
  5275. }
  5276. if (res.Length <= 0)
  5277. {
  5278. returnErrorMsg("模板数据为空!");
  5279. return;
  5280. }
  5281. ReturnSuccess(res);
  5282. }
  5283. public void cancel_print_order()
  5284. {
  5285. if (UrlPostParmsCheck("ctid"))
  5286. {
  5287. string ctid = GetPostString("ctid");
  5288. CeErpTradeCell entity = null;
  5289. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5290. if (entity != null)
  5291. {
  5292. string res = "";
  5293. string code = entity.LastBillWaybillCode;
  5294. if (code == "")
  5295. {
  5296. code = entity.OutSid;
  5297. }
  5298. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5299. XLog.SaveLog(0, "取消面单" + res);
  5300. }
  5301. }
  5302. }
  5303. public void set_erp_printwaybill()
  5304. {
  5305. if (UrlPostParmsCheck("ctid"))
  5306. {
  5307. string ctid = GetPostString("ctid");
  5308. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5309. string cpName = GetPostString("cpname");
  5310. string isTogether = GetPostString("together");
  5311. //var res_obj = new
  5312. //{
  5313. // restype = 1,
  5314. // 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\"}"
  5315. //};
  5316. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5317. //ReturnSuccess(ro_json);
  5318. //return;
  5319. bool isUseLastWayBillCode = false;
  5320. CeErpTradeCell entity = null;
  5321. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5322. if (entity != null)
  5323. {
  5324. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5325. {
  5326. isUseLastWayBillCode = true;
  5327. }
  5328. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5329. {
  5330. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5331. return;
  5332. }
  5333. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5334. {
  5335. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5336. return;
  5337. }
  5338. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5339. {
  5340. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5341. return;
  5342. }
  5343. }
  5344. string res = "";
  5345. Api_waybill_code_response_Obj fullObj = null;
  5346. string pData_str = "";
  5347. string curUseWayBillCode = "";
  5348. if (isUseLastWayBillCode == false)
  5349. {
  5350. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5351. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5352. if (res.IndexOf("failure") != -1)
  5353. {
  5354. //int idx = res.IndexOf("sub_message");
  5355. //int idx2 = res.IndexOf("flag");
  5356. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5357. string errMsgNeed = commonHelper.KeepChinese(res);
  5358. var res_objd = new
  5359. {
  5360. restype = 0,
  5361. data = "获取面单失败" + errMsgNeed
  5362. };
  5363. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5364. returnSuccess(ro_jsond);
  5365. if (res.IndexOf("停发") != -1)
  5366. {
  5367. entity.UnusualCon = "物流停发";
  5368. entity.Update();
  5369. }
  5370. //returnErrorMsg("获取面单失败,"+emsg);
  5371. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5372. return;
  5373. }
  5374. else if (res.IndexOf("errorMsg") != -1)
  5375. {
  5376. //int idx = res.IndexOf("errorMsg");
  5377. //int idx2 = res.IndexOf("}]}");
  5378. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5379. string errMsgNeed = commonHelper.KeepChinese(res);
  5380. var res_objf = new
  5381. {
  5382. restype = 0,
  5383. data = "获取面单失败2" + errMsgNeed
  5384. };
  5385. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5386. if (res.IndexOf("停发") != -1)
  5387. {
  5388. entity.UnusualCon = "物流停发";
  5389. entity.Update();
  5390. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5391. if (trade != null)
  5392. {
  5393. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5394. }
  5395. }
  5396. returnSuccess(ro_jsonf);
  5397. //returnErrorMsg("获取面单失败," + emsg);
  5398. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5399. return;
  5400. }
  5401. try
  5402. {
  5403. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5404. //res = res.Replace(" ", "");
  5405. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5406. }
  5407. catch (Exception ex)
  5408. {
  5409. XLog.SaveLog(0, "生成fullObj" + res);
  5410. var res_objf = new
  5411. {
  5412. restype = 0,
  5413. data = "生成fullObj发生错误" + ex.Message
  5414. };
  5415. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5416. returnSuccess(ro_jsonf);
  5417. return;
  5418. }
  5419. if (fullObj.response.data.content.Count > 0)
  5420. {
  5421. ContentItem codeObj = fullObj.response.data.content[0];
  5422. if (cpCode.IndexOf("SFFQ-") != -1)
  5423. {
  5424. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5425. }
  5426. else
  5427. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5428. curUseWayBillCode = codeObj.waybillCode;
  5429. }
  5430. else
  5431. {
  5432. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5433. var res_objf = new
  5434. {
  5435. restype = 0,
  5436. data = "生成fullObj找不到快递单号waybillCode"
  5437. };
  5438. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5439. returnSuccess(ro_jsonf);
  5440. return;
  5441. }
  5442. }
  5443. else
  5444. {
  5445. //使用上次打印的快递单号
  5446. if (cpCode == "SFFQ-LY")
  5447. {
  5448. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5449. }
  5450. else
  5451. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5452. curUseWayBillCode = entity.LastBillWaybillCode;
  5453. }
  5454. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5455. {
  5456. var res_obje = new
  5457. {
  5458. restype = 0,
  5459. data = "获取加密打印数据失败"
  5460. };
  5461. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5462. returnSuccess(ro_jsone);
  5463. entity.LastBillCpCode = cpCode;
  5464. entity.LastBillWaybillCode = curUseWayBillCode;
  5465. entity.Update();
  5466. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5467. //returnErrorMsg("获取加密打印数据失败");
  5468. return;
  5469. }
  5470. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5471. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5472. string btnType = "";
  5473. string errorMsg = "";
  5474. if (entity != null)
  5475. {
  5476. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5477. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5478. //cpcode是 YTO-CAINIAO
  5479. //string comCode = cpCode.Split('-')[0].ToString();
  5480. string apires = "";
  5481. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5482. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5483. {
  5484. if (ctid.IndexOf("N") != -1)
  5485. {
  5486. apires = "发货成功";
  5487. }
  5488. else
  5489. {
  5490. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5491. }
  5492. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5493. //打单后发货
  5494. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5495. {
  5496. try
  5497. {
  5498. btnType = "待发货";
  5499. entity.OutSid = curUseWayBillCode;
  5500. entity.OrderState = 7;
  5501. entity.IsUrgency = false;
  5502. entity.LastBillCpCode = "";
  5503. entity.LastBillWaybillCode = "";
  5504. entity.FinishDeliveryTime = DateTime.Now;
  5505. entity.IsReturn = 0;
  5506. entity.MemoOpt = 0;
  5507. entity.UpdateTime = DateTime.Now;
  5508. entity.Update();
  5509. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5510. //还要插入快递信息到 快递信息表
  5511. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5512. exinfo.tid = entity.ctid;
  5513. exinfo.out_sid = curUseWayBillCode;
  5514. exinfo.company_code = cpCode;
  5515. exinfo.company_name = cpName;
  5516. exinfo.supplierUserName = supplierName;
  5517. exinfo.deliveryType = "发货成功";
  5518. exinfo.print_time = DateTime.Now;
  5519. exinfo.printUser = CurrentUser.UserName;
  5520. exinfo.postData = pData_str;
  5521. exinfo.Create();
  5522. commonHelper.UpdateRelationOrder(entity.ctid);
  5523. CeErpSukuraData.createInfo(ctid, 4);
  5524. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5525. if (entity.SupplierId == 64)
  5526. {
  5527. commonHelper.sendCytExpress(exinfo);
  5528. }
  5529. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5530. if (!string.IsNullOrEmpty(isTogether))
  5531. {
  5532. if (Convert.ToInt32(isTogether) > 0)
  5533. {
  5534. StringBuilder sqlsb = new StringBuilder();
  5535. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5536. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5537. }
  5538. }
  5539. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5540. }
  5541. catch (Exception ex)
  5542. {
  5543. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5544. }
  5545. }
  5546. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5547. {
  5548. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5549. if (entity.OrderState == 6)
  5550. {
  5551. entity.OrderState = 7;
  5552. }
  5553. entity.UpdateTime = DateTime.Now;
  5554. entity.FinishDeliveryTime = DateTime.Now;
  5555. btnType = "已发货";
  5556. entity.Update();
  5557. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5558. exinfo.tid = entity.ctid;
  5559. exinfo.out_sid = curUseWayBillCode;
  5560. exinfo.company_code = cpCode;
  5561. exinfo.company_name = cpName;
  5562. exinfo.supplierUserName = supplierName;
  5563. exinfo.deliveryType = "发货成功";
  5564. exinfo.print_time = DateTime.Now;
  5565. exinfo.printUser = CurrentUser.UserName;
  5566. exinfo.postData = pData_str;
  5567. exinfo.Create();
  5568. commonHelper.UpdateRelationOrder(entity.ctid);
  5569. CeErpSukuraData.createInfo(entity.ctid, 4);
  5570. if (entity.SupplierId == 64)
  5571. {
  5572. commonHelper.sendCytExpress(exinfo);
  5573. }
  5574. if (!string.IsNullOrEmpty(isTogether))
  5575. {
  5576. if (Convert.ToInt32(isTogether) > 0)
  5577. {
  5578. StringBuilder sqlsb = new StringBuilder();
  5579. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE() where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5580. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5581. }
  5582. }
  5583. //不处理
  5584. }
  5585. else
  5586. {
  5587. entity.UpdateTime = DateTime.Now;
  5588. entity.LastBillCpCode = cpCode;
  5589. entity.LastBillWaybillCode = curUseWayBillCode;
  5590. entity.Update();
  5591. string errmsg = commonHelper.KeepChinese(apires);
  5592. var res_objz = new
  5593. {
  5594. restype = 0,
  5595. data = "打单后发货失败"
  5596. };
  5597. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5598. returnSuccess(ro_jsonz);
  5599. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5600. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5601. return;
  5602. }
  5603. }
  5604. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5605. {
  5606. StringBuilder allSql = new StringBuilder();
  5607. allSql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,tid from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  5608. if (string.IsNullOrEmpty(mainEn.receiverId))
  5609. {
  5610. allSql.AppendFormat(" and (tid='{0}');", entity.tid);
  5611. }
  5612. else
  5613. {
  5614. //查询同车间同状态下的收货地址相同的单子
  5615. allSql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}') );", entity.tid, mainEn.receiverId, entity.IsSF);
  5616. }
  5617. DataTable dt = DbHelper.DbConn.ExecuteDataset(allSql.ToString()).Tables[0];
  5618. List<string> list = new List<string>();
  5619. List<string> send_list = new List<string>();
  5620. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5621. CeErpTrade ceErpTrade = new CeErpTrade();
  5622. foreach (DataRow row in dt.Rows)
  5623. {
  5624. list.Add("'" + row["ctid"] + "'");
  5625. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5626. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5627. if (ctid.IndexOf("N") != -1)
  5628. {
  5629. apires = "发货成功";
  5630. }
  5631. else
  5632. {
  5633. if (!send_list.Contains(ceErpTrade.tid))
  5634. {
  5635. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5636. }
  5637. else
  5638. {
  5639. apires = "发货成功";
  5640. }
  5641. }
  5642. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5643. {
  5644. send_list.Add(ceErpTrade.tid);
  5645. try
  5646. {
  5647. btnType = "待发货";
  5648. ceErpTradeCell.OutSid = curUseWayBillCode;
  5649. ceErpTradeCell.OrderState = 7;
  5650. ceErpTradeCell.IsUrgency = false;
  5651. ceErpTradeCell.LastBillCpCode = "";
  5652. ceErpTradeCell.LastBillWaybillCode = "";
  5653. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5654. ceErpTradeCell.IsReturn = 0;
  5655. ceErpTradeCell.MemoOpt = 0;
  5656. ceErpTradeCell.UpdateTime = DateTime.Now;
  5657. ceErpTradeCell.Update();
  5658. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5659. //还要插入快递信息到 快递信息表
  5660. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5661. exinfo.tid = ceErpTradeCell.ctid;
  5662. exinfo.out_sid = curUseWayBillCode;
  5663. exinfo.company_code = cpCode;
  5664. exinfo.company_name = cpName;
  5665. exinfo.supplierUserName = supplierName;
  5666. exinfo.deliveryType = "发货成功";
  5667. exinfo.print_time = DateTime.Now;
  5668. exinfo.printUser = CurrentUser.UserName;
  5669. exinfo.postData = pData_str;
  5670. exinfo.Create();
  5671. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5672. CeErpSukuraData.createInfo(ctid, 4);
  5673. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5674. if (ceErpTradeCell.SupplierId == 64)
  5675. {
  5676. commonHelper.sendCytExpress(exinfo);
  5677. }
  5678. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5679. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5680. }
  5681. catch (Exception ex)
  5682. {
  5683. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5684. }
  5685. }
  5686. else
  5687. {
  5688. ceErpTradeCell.UpdateTime = DateTime.Now;
  5689. ceErpTradeCell.LastBillCpCode = cpCode;
  5690. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5691. ceErpTradeCell.Update();
  5692. string errmsg = commonHelper.KeepChinese(apires);
  5693. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5694. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5695. }
  5696. }
  5697. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5698. }
  5699. }
  5700. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5701. var res_obj = new
  5702. {
  5703. restype = 1,
  5704. data = pData_str,
  5705. errorMsg
  5706. };
  5707. string ro_json = JsonConvert.SerializeObject(res_obj);
  5708. ReturnSuccess(ro_json);
  5709. return;
  5710. }
  5711. }
  5712. private string GetUTF8String(byte[] vs)
  5713. {
  5714. throw new NotImplementedException();
  5715. }
  5716. public void set_erp_printwaybill_cn()
  5717. {
  5718. if (UrlPostParmsCheck("ctid"))
  5719. {
  5720. string ctid = GetPostString("ctid");
  5721. string cpCode = GetPostString("cpcode");
  5722. string cpName = GetPostString("cpname");
  5723. string tempUrl = GetPostString("tempurl");
  5724. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5725. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5726. //string res = taobaoHelper.test();
  5727. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5728. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5729. {
  5730. int sidx = res.IndexOf("errorMsg");
  5731. int eidx = res.IndexOf("}");
  5732. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5733. var res_objzxx = new
  5734. {
  5735. restype = 0,
  5736. data = msg
  5737. };
  5738. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5739. returnSuccess(ro_jsonzxx);
  5740. //returnErrorMsg(msg);
  5741. return;
  5742. }
  5743. int idx = res.IndexOf("waybillCode");
  5744. int idx2 = res.IndexOf("printData");
  5745. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5746. string eid = GetPostString("ctid");
  5747. CeErpTradeCell entity = null;
  5748. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5749. if (entity != null)
  5750. {
  5751. string osid = entity.OutSid;
  5752. entity.OutSid = osid + "," + outsid;
  5753. entity.FinishDeliveryTime = DateTime.Now;
  5754. entity.OrderState = 7;
  5755. entity.UpdateTime = DateTime.Now;
  5756. entity.IsReturn = 0;
  5757. entity.Update();
  5758. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5759. exinfo.tid = entity.ctid;
  5760. exinfo.out_sid = outsid;
  5761. exinfo.company_code = cpCode;
  5762. exinfo.company_name = cpName;
  5763. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5764. exinfo.deliveryType = "发货成功";
  5765. exinfo.print_time = DateTime.Now;
  5766. exinfo.printUser = CurrentUser.UserName;
  5767. exinfo.Create();
  5768. if (entity.SupplierId == 64)
  5769. {
  5770. commonHelper.sendCytExpress(exinfo);
  5771. }
  5772. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5773. }
  5774. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5775. var res_objz = new
  5776. {
  5777. restype = 1,
  5778. data = res
  5779. };
  5780. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5781. returnSuccess(ro_jsonz);
  5782. //ReturnSuccess(res);
  5783. }
  5784. }
  5785. ////打单,打印面单 获取面单号
  5786. //public void set_erp_printwaybill()
  5787. //{
  5788. // if (UrlPostParmsCheck("ctid"))
  5789. // {
  5790. // string ctid = GetPostString("ctid");
  5791. // string cpCode = GetPostString("cpcode");
  5792. // string tempUrl = GetPostString("tempurl");
  5793. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5794. // //string res = taobaoHelper.test();
  5795. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5796. // if (res.IndexOf("error_response") != -1)
  5797. // {
  5798. // int sidx = res.IndexOf("sub_msg");
  5799. // int eidx = res.IndexOf("request_id");
  5800. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5801. // returnErrorMsg(msg);
  5802. // return;
  5803. // }
  5804. // int idx = res.IndexOf("waybill_code");
  5805. // int idx2 = res.IndexOf("}]}");
  5806. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5807. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5808. // ReturnSuccess(res);
  5809. // }
  5810. //}
  5811. public void cancel_erp_aftersale()
  5812. {
  5813. if (UrlPostParmsCheck("ctid"))
  5814. {
  5815. string eid = GetPostString("ctid");
  5816. CeErpTradeCell entity = null;
  5817. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5818. if (entity != null)
  5819. {
  5820. //有过处理的售后,取消也不能删除 售 字,保留
  5821. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5822. {
  5823. entity.AfterSaleState = 4;
  5824. }
  5825. else
  5826. entity.AfterSaleState = 0;
  5827. entity.UpdateTime = DateTime.Now;
  5828. entity.Update();
  5829. returnSuccessMsg("操作成功!");
  5830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5831. return;
  5832. }
  5833. returnErrorMsg("找不到订单记录");
  5834. }
  5835. }
  5836. public void get_erp_aftersalelist()
  5837. {
  5838. DataStruct dStruct = GetPostStruct();
  5839. List<string> lw = new List<string>();
  5840. int st = GetInt("st");
  5841. string tid = GetPostString("ctid");
  5842. if (st == 3)
  5843. {
  5844. if (tid.Length > 0)
  5845. {
  5846. string select_tid = getTidByCtid(tid);
  5847. lw.Add(string.Format("tid='{0}'", select_tid));
  5848. }
  5849. }
  5850. else
  5851. {
  5852. if (tid.Length > 0)
  5853. {
  5854. string select_tid = getTidByCtid(tid);
  5855. lw.Add(string.Format("tid='{0}'", select_tid));
  5856. }
  5857. }
  5858. string shopname = GetPostString("shopname");
  5859. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5860. string buyernick = GetPostString("buyer_nick");
  5861. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5862. string sellermemo = GetPostString("seller_memo");
  5863. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5864. string orderState = GetPostString("orderState");
  5865. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5866. string afterState = GetPostString("afterstate");
  5867. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5868. string date1 = GetPostString("date1");
  5869. string date2 = GetPostString("date2");
  5870. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5871. if (dw.Length > 0) lw.Add(dw);
  5872. string price1 = GetPostString("price1");
  5873. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5874. string price2 = GetPostString("price2");
  5875. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5876. //lw.Add(string.Format("IsRefund!={0}", 1));
  5877. string reason = GetPostString("reason");
  5878. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5879. string method = GetPostString("method");
  5880. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5881. string handler = GetPostString("handler");
  5882. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5883. string handledate1 = GetPostString("handledate1");
  5884. string handledate2 = GetPostString("handledate2");
  5885. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5886. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5887. string finish1 = GetPostString("finishdate1");
  5888. string finish2 = GetPostString("finishdate2");
  5889. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5890. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5891. string afterdate1 = GetPostString("afterdate1");
  5892. string afterdate2 = GetPostString("afterdate2");
  5893. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5894. if (afterDate.Length > 0) lw.Add(afterDate);
  5895. string supplier = GetPostString("supplier");
  5896. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5897. string responsible = GetPostString("responsibleman");
  5898. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5899. string customer = GetPostString("customer");
  5900. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5901. string design = GetPostString("design");
  5902. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5903. string afterMemoType = GetPostString("aftermemotype");
  5904. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5905. string posCode = CurrentUser.UserPost.Post.Code;
  5906. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5907. //{
  5908. // string vstate = GetPostString("vstate");
  5909. // if (vstate.Length > 0)
  5910. // {
  5911. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5912. // }
  5913. // if (posCode == "Supplier")
  5914. // {
  5915. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5916. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5917. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5918. // }
  5919. // else
  5920. // {
  5921. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5922. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5923. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5924. // {
  5925. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5926. // }
  5927. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5928. // {
  5929. // int orgid = CurrentUser.UserPost.OrgID;
  5930. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5931. // }
  5932. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5933. // {
  5934. // string shopid = CurrentUser.User.pemShop;
  5935. // lw.Add(string.Format("shopId in ({0})", shopid));
  5936. // }
  5937. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5938. // //{
  5939. // // int org_id = CurrentUser.UserPost.OrgID;
  5940. // // lw.Add(string.Format("OrgID={0}", org_id));
  5941. // //}
  5942. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5943. // }
  5944. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5945. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5946. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5947. //}
  5948. if (st == 5)
  5949. {
  5950. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5951. {
  5952. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5953. {
  5954. string shopid = CurrentUser.User.pemShop;
  5955. lw.Add(string.Format("shopId in ({0})", shopid));
  5956. }
  5957. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5958. {
  5959. int mrOrgid = CurrentUser.UserPost.OrgID;
  5960. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5961. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5962. }
  5963. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5964. //{
  5965. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5966. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5967. //}
  5968. else
  5969. {
  5970. string userIdStr = "";
  5971. if (posCode == "CustomerService")
  5972. {
  5973. userIdStr = CurrentUser.UserID + "_k";
  5974. }
  5975. else if (posCode == "Designer" || posCode == "wxDesigner")
  5976. {
  5977. userIdStr = CurrentUser.UserID + "_s";
  5978. }
  5979. else if (posCode == "Place")
  5980. {
  5981. userIdStr = CurrentUser.UserID + "_x";
  5982. }
  5983. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5984. }
  5985. }
  5986. string placedate1 = GetPostString("placedate1");
  5987. string placedate2 = GetPostString("placedate2");
  5988. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5989. if (dwplace.Length > 0) lw.Add(dwplace);
  5990. string supState = GetPostString("supState");
  5991. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5992. string searchType = GetPostString("searchType");
  5993. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5994. {
  5995. lw.Add(string.Format("BackNum>1"));
  5996. }
  5997. lw.Add(string.Format("AfterSaleState>0"));
  5998. if (ex_psize > 0)
  5999. {
  6000. if (CurrentUser.UserPost.Post.Code == "Finance")
  6001. dStruct.Order = "pay_time desc";
  6002. else
  6003. dStruct.Order = "HandleTime desc";
  6004. }
  6005. else
  6006. dStruct.Order = "HandleTime desc";
  6007. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6008. DataTable dt = WebCache.GetData("view_test", dStruct);
  6009. writeGridDataTableJson(dStruct.TotalCount, dt);
  6010. }
  6011. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6012. //{
  6013. // lw.Add(string.Format("AfterSaleState=4"));
  6014. // string code = CurrentUser.UserPost.Post.Code;
  6015. // if (code == "CustomerService")
  6016. // {
  6017. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6018. // }
  6019. // else if (code == "Designer" || code == "DesignerMr")
  6020. // {
  6021. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6022. // }
  6023. // else if (code == "Place" || code == "PlaceMr")
  6024. // {
  6025. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6026. // }
  6027. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6028. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6029. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6030. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6031. //}
  6032. //else //处理中的售后,待处理和处理中合并
  6033. //{
  6034. // if (afterState.Length <= 0)
  6035. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6036. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6037. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6038. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6039. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6040. //}
  6041. }
  6042. public void get_erp_disagreeftersalelist()
  6043. {
  6044. DataStruct dStruct = GetPostStruct();
  6045. List<string> lw = new List<string>();
  6046. int st = 2;
  6047. string tid = GetPostString("ctid");
  6048. if (tid.Length > 0)
  6049. {
  6050. string select_tid = getTidByCtid(tid);
  6051. lw.Add(string.Format("tid='{0}'", select_tid));
  6052. }
  6053. string shopname = GetPostString("shopname");
  6054. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6055. string buyernick = GetPostString("buyer_nick");
  6056. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6057. string sellermemo = GetPostString("seller_memo");
  6058. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6059. string orderState = GetPostString("orderState");
  6060. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6061. string afterState = GetPostString("afterstate");
  6062. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6063. string date1 = GetPostString("date1");
  6064. string date2 = GetPostString("date2");
  6065. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6066. if (dw.Length > 0) lw.Add(dw);
  6067. string price1 = GetPostString("price1");
  6068. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6069. string price2 = GetPostString("price2");
  6070. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6071. //lw.Add(string.Format("IsRefund!={0}", 1));
  6072. string reason = GetPostString("reason");
  6073. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6074. string method = GetPostString("method");
  6075. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6076. string handler = GetPostString("handler");
  6077. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6078. string handledate1 = GetPostString("handledate1");
  6079. string handledate2 = GetPostString("handledate2");
  6080. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6081. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6082. string afterdate1 = GetPostString("afterdate1");
  6083. string afterdate2 = GetPostString("afterdate2");
  6084. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6085. if (afterDate.Length > 0) lw.Add(afterDate);
  6086. string backdate1 = GetPostString("backdate1");
  6087. string backdate2 = GetPostString("backdate2");
  6088. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6089. if (backDate.Length > 0) lw.Add(backDate);
  6090. string supplier = GetPostString("supplier");
  6091. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6092. string responsible = GetPostString("responsibleman");
  6093. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6094. string customer = GetPostString("customer");
  6095. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6096. string design = GetPostString("design");
  6097. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6098. string afterSaleMemo = GetPostString("afterSaleMemo");
  6099. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6100. string afterMemoType = GetPostString("aftermemotype");
  6101. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6102. string aftersakereason = GetPostString("aftersakereason");
  6103. if (aftersakereason.Length > 0)
  6104. {
  6105. if (aftersakereason == "1")
  6106. {
  6107. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6108. }
  6109. if (aftersakereason == "2")
  6110. {
  6111. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6112. }
  6113. }
  6114. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6115. string poscode = CurrentUser.UserPost.Post.Code;
  6116. if (poscode != "SysAdmin")
  6117. {
  6118. string shopid = CurrentUser.User.pemShop;
  6119. lw.Add(string.Format("shopId in ({0})", shopid));
  6120. }
  6121. string searchType = GetPostString("searchType");
  6122. if (searchType == "wait")
  6123. {
  6124. lw.Add(string.Format("HandleTime is null"));
  6125. }
  6126. if (searchType == "handling")
  6127. {
  6128. lw.Add(string.Format("HandleTime is not null "));
  6129. }
  6130. if (searchType == "back" || searchType == "puBack")
  6131. {
  6132. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6133. }
  6134. if (searchType == "reBack")
  6135. {
  6136. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6137. }
  6138. if (searchType == "moreBack")
  6139. {
  6140. lw.Add(string.Format("backNum > 1"));
  6141. }
  6142. lw.Add(string.Format("(AfterSaleState=5)"));
  6143. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6144. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6145. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6146. writeGridDataTableJson(dStruct.TotalCount, dt);
  6147. }
  6148. public void get_erp_handlingaftersalelist()
  6149. {
  6150. DataStruct dStruct = GetPostStruct();
  6151. List<string> lw = new List<string>();
  6152. int st = 2;
  6153. string tid = GetPostString("ctid");
  6154. if (tid.Length > 0)
  6155. {
  6156. string select_tid = getTidByCtid(tid);
  6157. lw.Add(string.Format("tid='{0}'", select_tid));
  6158. }
  6159. string shopname = GetPostString("shopname");
  6160. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6161. string buyernick = GetPostString("buyer_nick");
  6162. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6163. string sellermemo = GetPostString("seller_memo");
  6164. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6165. string orderState = GetPostString("orderState");
  6166. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6167. string afterState = GetPostString("afterstate");
  6168. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6169. string date1 = GetPostString("date1");
  6170. string date2 = GetPostString("date2");
  6171. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6172. if (dw.Length > 0) lw.Add(dw);
  6173. string price1 = GetPostString("price1");
  6174. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6175. string price2 = GetPostString("price2");
  6176. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6177. //lw.Add(string.Format("IsRefund!={0}", 1));
  6178. string reason = GetPostString("reason");
  6179. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6180. string method = GetPostString("method");
  6181. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6182. string handler = GetPostString("handler");
  6183. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6184. string handledate1 = GetPostString("handledate1");
  6185. string handledate2 = GetPostString("handledate2");
  6186. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6187. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6188. string afterdate1 = GetPostString("afterdate1");
  6189. string afterdate2 = GetPostString("afterdate2");
  6190. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6191. if (afterDate.Length > 0) lw.Add(afterDate);
  6192. string supplier = GetPostString("supplier");
  6193. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6194. string responsible = GetPostString("responsibleman");
  6195. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6196. string customer = GetPostString("customer");
  6197. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6198. string design = GetPostString("design");
  6199. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6200. string afterSaleMemo = GetPostString("afterSaleMemo");
  6201. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6202. string afterMemoType = GetPostString("aftermemotype");
  6203. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6204. string afterresult = GetPostString("afterresult");
  6205. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6206. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6207. string poscode = CurrentUser.UserPost.Post.Code;
  6208. if (poscode != "SysAdmin")
  6209. {
  6210. string shopid = CurrentUser.User.pemShop;
  6211. lw.Add(string.Format("shopId in ({0})", shopid));
  6212. }
  6213. string searchType = GetPostString("searchType");
  6214. if (searchType == "wait")
  6215. {
  6216. lw.Add(string.Format("HandleTime is null"));
  6217. }
  6218. if (searchType == "documentary")
  6219. {
  6220. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6221. }
  6222. if (searchType == "handling")
  6223. {
  6224. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6225. }
  6226. if (searchType == "back" || searchType == "puBack")
  6227. {
  6228. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6229. }
  6230. if (searchType == "reBack")
  6231. {
  6232. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6233. }
  6234. if (afterState.Length <= 0)
  6235. {
  6236. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6237. }
  6238. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6239. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6240. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6241. writeGridDataTableJson(dStruct.TotalCount, dt);
  6242. }
  6243. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6244. //public void get_erp_back_handlingaftersalelist()
  6245. //{
  6246. // DataStruct dStruct = GetPostStruct();
  6247. // List<string> lw = new List<string>();
  6248. // string tid = GetPostString("ctid");
  6249. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6250. // string shopname = GetPostString("shopname");
  6251. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6252. // string buyernick = GetPostString("buyer_nick");
  6253. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6254. // string sellermemo = GetPostString("seller_memo");
  6255. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6256. // string orderState = GetPostString("orderState");
  6257. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6258. // string afterState = GetPostString("afterstate");
  6259. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6260. // string date1 = GetPostString("date1");
  6261. // string date2 = GetPostString("date2");
  6262. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6263. // if (dw.Length > 0) lw.Add(dw);
  6264. // string price1 = GetPostString("price1");
  6265. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6266. // string price2 = GetPostString("price2");
  6267. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6268. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6269. // string reason = GetPostString("reason");
  6270. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6271. // string method = GetPostString("method");
  6272. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6273. // string handler = GetPostString("handler");
  6274. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6275. // string handledate1 = GetPostString("handledate1");
  6276. // string handledate2 = GetPostString("handledate2");
  6277. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6278. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6279. // string afterdate1 = GetPostString("afterdate1");
  6280. // string afterdate2 = GetPostString("afterdate2");
  6281. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6282. // if (afterDate.Length > 0) lw.Add(afterDate);
  6283. // string supplier = GetPostString("supplier");
  6284. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6285. // string responsible = GetPostString("responsibleman");
  6286. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6287. // string customer = GetPostString("customer");
  6288. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6289. // string design = GetPostString("design");
  6290. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6291. // string afterMemoType = GetPostString("aftermemotype");
  6292. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6293. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6294. // if (afterState.Length <= 0)
  6295. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6296. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6297. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6298. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6299. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6300. //}
  6301. public void get_erp_aftersaleverifylist()
  6302. {
  6303. DataStruct dStruct = GetPostStruct();
  6304. List<string> lw = new List<string>();
  6305. string tid = GetPostString("ctid");
  6306. if (tid.Length > 0)
  6307. {
  6308. string select_tid = getTidByCtid(tid);
  6309. lw.Add(string.Format("tid='{0}'", select_tid));
  6310. }
  6311. string shopname = GetPostString("shopname");
  6312. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6313. string buyernick = GetPostString("buyer_nick");
  6314. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6315. string sellermemo = GetPostString("seller_memo");
  6316. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6317. string orderState = GetPostString("orderState");
  6318. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6319. //lw.Add(string.Format("IsRefund!={0}", 1));
  6320. string reason = GetPostString("reason");
  6321. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6322. string method = GetPostString("method");
  6323. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6324. string handler = GetPostString("handler");
  6325. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6326. string handledate1 = GetPostString("handledate1");
  6327. string handledate2 = GetPostString("handledate2");
  6328. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6329. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6330. string finish1 = GetPostString("finishdate1");
  6331. string finish2 = GetPostString("finishdate2");
  6332. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6333. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6334. string supplier = GetPostString("supplier");
  6335. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6336. string responsible = GetPostString("responsibleman");
  6337. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6338. string posCode = CurrentUser.UserPost.Post.Code;
  6339. string vstate = GetPostString("vstate");
  6340. if (vstate.Length > 0)
  6341. {
  6342. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6343. }
  6344. if (posCode == "Supplier")
  6345. {
  6346. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6347. lw.Add(string.Format("VerifyState = 0"));
  6348. lw.Add("type = 1");
  6349. lw.Add(string.Format("AfterSaleState={0}", 3));
  6350. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6351. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6352. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6353. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6354. writeGridDataTableJson(dStruct.TotalCount, dt);
  6355. }
  6356. else if (posCode == "logistics")
  6357. {
  6358. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6359. lw.Add(string.Format("VerifyState = 0"));
  6360. lw.Add("type = 2");
  6361. lw.Add(string.Format("AfterSaleState={0}", 3));
  6362. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6363. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6364. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6365. writeGridDataTableJson(dStruct.TotalCount, dt);
  6366. }
  6367. else
  6368. {
  6369. lw.Add(string.Format("(AfterSaleState = 3)"));
  6370. string reasonState = GetPostString("reasonState");
  6371. lw.Add("type = 0");
  6372. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6373. || posCode == "Summarize" || posCode == "Finance")
  6374. {
  6375. if (reasonState == "2")
  6376. {
  6377. lw.Add("VerifyState = 3");
  6378. }
  6379. else if (reasonState == "1")
  6380. {
  6381. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6382. }
  6383. else
  6384. {
  6385. lw.Add("VerifyState in (0,3)");
  6386. }
  6387. //不加条件,可以看全部
  6388. }
  6389. 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")
  6390. {
  6391. int orgid = CurrentUser.UserPost.OrgID;
  6392. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6393. if (string.IsNullOrEmpty(manageOrgId))
  6394. {
  6395. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6396. }
  6397. else
  6398. {
  6399. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6400. }
  6401. if (reasonState == "1")
  6402. {
  6403. lw.Add("VerifyState = 3");
  6404. }
  6405. else if (reasonState == "2")
  6406. {
  6407. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6408. }
  6409. else
  6410. {
  6411. }
  6412. }
  6413. else
  6414. {
  6415. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6416. }
  6417. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6418. //{
  6419. // int org_id = CurrentUser.UserPost.OrgID;
  6420. // lw.Add(string.Format("OrgID={0}", org_id));
  6421. //}
  6422. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6423. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6424. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6425. writeGridDataTableJson(dStruct.TotalCount, dt);
  6426. }
  6427. }
  6428. public void get_erp_finishaftersalelist()
  6429. {
  6430. DataStruct dStruct = GetPostStruct();
  6431. List<string> lw = new List<string>();
  6432. int st = 4;
  6433. string tid = GetPostString("ctid");
  6434. if (tid.Length > 0)
  6435. {
  6436. string select_tid = getTidByCtid(tid);
  6437. lw.Add(string.Format("tid='{0}'", select_tid));
  6438. }
  6439. string shopname = GetPostString("shopname");
  6440. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6441. //lw.Add(string.Format("IsRefund!={0}", 1));
  6442. string reason = GetPostString("reason");
  6443. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6444. string method = GetPostString("method");
  6445. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6446. string buyernick = GetPostString("buyer_nick");
  6447. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6448. string handler = GetPostString("handler");
  6449. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6450. string handledate1 = GetPostString("handledate1");
  6451. string handledate2 = GetPostString("handledate2");
  6452. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6453. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6454. string finish1 = GetPostString("finishdate1");
  6455. string finish2 = GetPostString("finishdate2");
  6456. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6457. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6458. string supplier = GetPostString("supplier");
  6459. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6460. string responsible = GetPostString("responsibleman");
  6461. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6462. string vstate = GetPostString("vstate");
  6463. if (vstate.Length > 0)
  6464. {
  6465. if ("3".Equals(vstate))
  6466. {
  6467. lw.Add(string.Format("IsTem=1"));
  6468. }
  6469. else
  6470. {
  6471. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6472. }
  6473. }
  6474. lw.Add(string.Format("AfterSaleState=4"));
  6475. string code = CurrentUser.UserPost.Post.Code;
  6476. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6477. {
  6478. //不加条件,可以看全部
  6479. }
  6480. else if (code == "Supplier")
  6481. {
  6482. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6483. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6484. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6485. }
  6486. else if (code == "logistics")
  6487. {
  6488. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6489. lw.Add("type = 2");
  6490. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6491. }
  6492. 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")
  6493. {
  6494. int orgid = CurrentUser.UserPost.OrgID;
  6495. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6496. if (string.IsNullOrEmpty(manageOrgIds))
  6497. {
  6498. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6499. }
  6500. else
  6501. {
  6502. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6503. }
  6504. }
  6505. else
  6506. {
  6507. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6508. }
  6509. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6510. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6511. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6512. writeGridDataTableJson(dStruct.TotalCount, dt);
  6513. }
  6514. public void handle_erp_aftersale()
  6515. {
  6516. if (UrlPostParmsCheck("ctid"))
  6517. {
  6518. string eid = GetPostString("ctid");
  6519. string responStr = GetPostString("AfterSaleResponsible");
  6520. if (responStr.Length <= 0)
  6521. {
  6522. returnErrorMsg("售后责任人不能为空");
  6523. return;
  6524. }
  6525. bool isDesign = false;
  6526. double designFree = 0.00;
  6527. int responsibleId = 0;
  6528. CeErpTradeCell entity = null;
  6529. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6530. if (entity != null)
  6531. {
  6532. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6533. string afterMethod = GetPostString("AfterSaleMethod");
  6534. if (isNeedNewOrder == 1)
  6535. {
  6536. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6537. bool ishav = true;
  6538. if (newentity == null)
  6539. {
  6540. newentity = entity.Clone() as CeErpTradeCell;
  6541. ishav = false;
  6542. newentity.ctid = "S_" + entity.ctid;
  6543. newentity.OrderState = 0;
  6544. //唯一标识
  6545. newentity.OrderSn = newentity.ctid;
  6546. string orderSn = dataHelper.getSaleOrderSn();
  6547. if (orderSn != "")
  6548. {
  6549. newentity.OrderSn = orderSn;
  6550. }
  6551. }
  6552. newentity.UpdateTime = DateTime.Now;
  6553. newentity.AfterSaleState = 0;
  6554. newentity.AfterSaleMethod = afterMethod;
  6555. if (!ishav)
  6556. {
  6557. string memo_str = newentity.seller_memo;
  6558. memo_str = memo_str.Replace("(", "(");
  6559. memo_str = memo_str.Replace(")", ")");
  6560. int sIndex = memo_str.IndexOf("(");
  6561. int eIndex = memo_str.IndexOf(")");
  6562. if (sIndex == -1 || eIndex == -1)
  6563. {
  6564. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6565. return;
  6566. }
  6567. string first = memo_str.Substring(0, sIndex + 1);
  6568. string memoCtid = newentity.OrderSn;
  6569. //if (memoCtid.IndexOf("C") != -1)
  6570. //{
  6571. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6572. //if (CIdx.IndexOf("+") != -1)
  6573. //{
  6574. //CIdx = "C" + CIdx.Split('+')[1];
  6575. //}
  6576. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6577. //}
  6578. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6579. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6580. string newMemo = first + memoCtid + last;
  6581. newentity.seller_memo = newMemo;
  6582. newentity.FinishPlaceTime = null;
  6583. newentity.UnusualTag = 0;
  6584. newentity.UnusualCon = "";
  6585. newentity.UnusualTime = null;
  6586. newentity.AfterSaleMemo = "";
  6587. newentity.AfterSaleMethod = afterMethod;
  6588. newentity.AfterSalePreTime = null;
  6589. newentity.AfterSaleReason = "";
  6590. newentity.AfterSaleResponsible = "";
  6591. newentity.AfterSaleState = 0;
  6592. newentity.AfterSaleTime = null;
  6593. newentity.AfterSaleUserId = 0;
  6594. newentity.AfterSaleSupplierState = 0;
  6595. newentity.LastBillWaybillCode = "";
  6596. newentity.LastBillCpCode = "";
  6597. newentity.FinishAfterSaleTime = null;
  6598. newentity.HandleTime = null;
  6599. newentity.IsSF = 0;
  6600. newentity.IsOldCustomer = 0;
  6601. newentity.UrgencyTime = null;
  6602. newentity.ResponsibleUserId = "";
  6603. newentity.IsVerifyToSupplier = false;
  6604. newentity.payment = 0;
  6605. newentity.CheckMemo = "";
  6606. newentity.OutSid = "";
  6607. newentity.CheckOrderTime = null;
  6608. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6609. }
  6610. newentity.isAfterSaleOrder = 1;
  6611. newentity.IsRefund = 0;
  6612. string receiveMobile = GetPostString("receiver_mobile");
  6613. if (receiveMobile.Length > 0)
  6614. {
  6615. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6616. if (trade != null)
  6617. {
  6618. trade.receiver_name = GetPostString("receiver_name");
  6619. trade.receiver_mobile = receiveMobile;
  6620. trade.receiver_state = GetPostString("receiver_state");
  6621. trade.receiver_city = GetPostString("receiver_city");
  6622. trade.receiver_district = GetPostString("receiver_district");
  6623. trade.receiver_address = GetPostString("receiver_address");
  6624. newentity.IsOffLineOrder = 1;
  6625. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6626. }
  6627. }
  6628. string st = GetPostString("ToState");
  6629. if (st.Length > 0)
  6630. {
  6631. if (newentity.OrderState <= 3)
  6632. {
  6633. newentity.WaitDesignTime = DateTime.Now;
  6634. newentity.StartDesignTime = null;
  6635. newentity.FinishDesignTime = null;
  6636. newentity.OrderState = 3;
  6637. if (st == "下单员")
  6638. {
  6639. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6640. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6641. {
  6642. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6643. }
  6644. }
  6645. else
  6646. {
  6647. newentity.WaitDesignTime = DateTime.Now;
  6648. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6649. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6650. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6651. {
  6652. DataRow user = dt1.Rows[0];
  6653. //找主管
  6654. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6655. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6656. if (dt != null && dt.Rows.Count > 0)
  6657. {
  6658. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6659. newentity.DesignUserId = designMr;
  6660. string key = "aftersale_order_" + designMr;
  6661. if (RedisHelper.HasKey(key))
  6662. {
  6663. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6664. list.Add(newentity.ctid);
  6665. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6666. }
  6667. }
  6668. //账号正常
  6669. if (user["State"].ToString() == "0")
  6670. {
  6671. newentity.DesignUserId = entity.DesignUserId;
  6672. string key = "aftersale_order_" + entity.DesignUserId;
  6673. if (RedisHelper.HasKey(key))
  6674. {
  6675. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6676. list.Add(newentity.ctid);
  6677. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6678. }
  6679. }
  6680. }
  6681. }
  6682. }
  6683. if (entity.IsXianHuo == 1)
  6684. {
  6685. newentity.OrderState = 6;
  6686. entity.FinishPlaceTime = DateTime.Now;
  6687. }
  6688. }
  6689. if (ishav)
  6690. {
  6691. newentity.Update();
  6692. }
  6693. else
  6694. {
  6695. newentity.Create();
  6696. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6697. newCellExtend.ctid = newentity.ctid;
  6698. newCellExtend.orderFrom = 20;
  6699. newCellExtend.orderType = 30;
  6700. if (st == "下单员")
  6701. {
  6702. }
  6703. else
  6704. {
  6705. newCellExtend.ReprintTime = DateTime.Now;
  6706. }
  6707. newCellExtend.Create();
  6708. }
  6709. if (st != "下单员")
  6710. {
  6711. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(newentity);
  6712. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  6713. }
  6714. }
  6715. //处理售后扩展
  6716. string resIdStr = GetPostString("ResponsibleUserId");
  6717. string refundFees = GetPostString("refundFrees");
  6718. int IsComplain = GetPostInt("isComplain");
  6719. int IsBad = GetPostInt("isBad");
  6720. string IsOriginal = GetPostString("isOriginal");
  6721. double diffResultPrice = GetPostDouble("diffResultPrice");
  6722. string textResult = GetPostString("textResult");
  6723. string supplierResponsible = GetPostString("supplierResponsible");
  6724. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6725. if (ceErpTradeAfterSaleExtend == null)
  6726. {
  6727. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6728. ceErpTradeAfterSaleExtend.tid = eid;
  6729. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6730. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6731. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6732. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6733. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6734. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6735. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6736. ceErpTradeAfterSaleExtend.Create();
  6737. }
  6738. else
  6739. {
  6740. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6741. {
  6742. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6743. }
  6744. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6745. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6746. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6747. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6748. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6749. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6750. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6751. ceErpTradeAfterSaleExtend.Update();
  6752. }
  6753. int gysid = GetPostInt("ResponsibleSupId");
  6754. if (entity.AfterSaleUserId == 0)
  6755. {
  6756. entity.AfterSaleUserId = CurrentUser.UserID;
  6757. }
  6758. entity.ResponsibleUserId = resIdStr;
  6759. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6760. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6761. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6762. {
  6763. CeErpTradeResponsible.DelByTid(eid, -1);
  6764. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6765. int backNum = 0;
  6766. if (number != null)
  6767. {
  6768. backNum = number.BackNum;
  6769. }
  6770. char[] separator = { ',' };
  6771. string[] sArray = resIdStr.Split(separator);
  6772. string[] refundFreeList = { };
  6773. if (refundFees.Length > 0)
  6774. {
  6775. refundFreeList = refundFees.Split(separator);
  6776. }
  6777. int index = -1;
  6778. foreach (string i in sArray)
  6779. {
  6780. index++;
  6781. if (i.Length <= 0) continue;
  6782. char[] separator2 = { '_' };
  6783. string idstr = i.Split(separator2)[0];
  6784. string idtype = i.Split(separator2)[1];
  6785. double refudFree = 0;
  6786. if (refundFreeList.Length > 0)
  6787. {
  6788. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6789. }
  6790. if (idtype == "s")
  6791. {
  6792. isDesign = true;
  6793. designFree = refudFree;
  6794. }
  6795. int userId = Convert.ToInt32(idstr);
  6796. int type = 0;
  6797. if (idtype == "g")
  6798. {
  6799. type = 1;
  6800. }
  6801. if (idtype == "w")
  6802. {
  6803. type = 2;
  6804. }
  6805. if (idtype == "t")
  6806. {
  6807. type = 3;
  6808. }
  6809. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6810. if (ceErpTradeResponsible == null)
  6811. {
  6812. ceErpTradeResponsible = new CeErpTradeResponsible();
  6813. ceErpTradeResponsible.tid = eid;
  6814. ceErpTradeResponsible.UserId = userId;
  6815. ceErpTradeResponsible.createdTime = DateTime.Now;
  6816. ceErpTradeResponsible.type = type;
  6817. if (type == 1)
  6818. {
  6819. ceErpTradeResponsible.IsSup = 1;
  6820. }
  6821. if (type == 2)
  6822. {
  6823. ceErpTradeResponsible.IsFlow = 1;
  6824. }
  6825. }
  6826. ceErpTradeResponsible.RefundFee = refudFree;
  6827. ceErpTradeResponsible.VerifyState = 0;
  6828. if (userId == 2125 || idtype == "w")
  6829. {
  6830. ceErpTradeResponsible.VerifyState = 1;
  6831. }
  6832. if (idtype == "w" && userId == 101)
  6833. {
  6834. ceErpTradeResponsible.VerifyState = 0;
  6835. }
  6836. if (ceErpTradeResponsible.ID > 0)
  6837. {
  6838. ceErpTradeResponsible.Update();
  6839. }
  6840. else
  6841. {
  6842. ceErpTradeResponsible.Create();
  6843. }
  6844. if (isDesign)
  6845. {
  6846. responsibleId = ceErpTradeResponsible.ID;
  6847. }
  6848. }
  6849. CeErpTradeResponsible.NumByTid(backNum, eid);
  6850. }
  6851. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6852. if (ceErpTradeCellExtend != null)
  6853. {
  6854. ceErpTradeCellExtend.returnVisit = 0;
  6855. ceErpTradeCellExtend.Update();
  6856. }
  6857. if (entity.HandleTime != null)
  6858. {
  6859. if (entity.AfterSaleState == 1)
  6860. {
  6861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6862. }
  6863. else
  6864. {
  6865. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6866. }
  6867. }
  6868. else
  6869. {
  6870. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6871. entity.HandleTime = DateTime.Now;
  6872. }
  6873. bool isCompale = false;
  6874. if (entity.AfterSaleState == 5)
  6875. {
  6876. isCompale = true;
  6877. entity.AfterSaleState = 3;
  6878. }
  6879. entity.AfterSaleSupplierState = 0;
  6880. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6881. {
  6882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6883. }
  6884. string sImgs = GetPostString("img");
  6885. entity.AfterSaleSupplierImg = sImgs;
  6886. entity.supRefundType = GetPostString("supRefundType");
  6887. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6888. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6889. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6890. entity.AfterSaleMemoType = GetPostString("MemoType");
  6891. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6892. {
  6893. //entity.AfterSaleSupplierState = 2;
  6894. }
  6895. string df = GetPostString("DeductFee");
  6896. if (df == "")
  6897. {
  6898. df = "0";
  6899. }
  6900. string rf = GetPostString("RefundFee");
  6901. if (rf == "")
  6902. {
  6903. rf = "0";
  6904. }
  6905. string pm = GetPostString("AfterSalePayment");
  6906. if (pm == "")
  6907. {
  6908. pm = "0";
  6909. }
  6910. entity.AfterSalePayment = Convert.ToDouble(pm);
  6911. entity.DeductFee = Convert.ToDouble(df);
  6912. entity.RefundFee = Convert.ToDouble(rf);
  6913. entity.UpdateTime = DateTime.Now;
  6914. entity.Update();
  6915. string toState = GetPostString("ToState");
  6916. string original = GetPostString("isOriginal");
  6917. ApiVo apiVo = new ApiVo();
  6918. apiVo.orderNumber = entity.ctid;
  6919. apiVo.actionName = "afterDesign";
  6920. apiVo.orderRemarks = entity.AfterSaleMethod;
  6921. apiVo.reasonRemarks = entity.AfterSaleReason;
  6922. apiVo.isDesign = isDesign;
  6923. apiVo.designFree = designFree;
  6924. apiVo.responsibleId = responsibleId;
  6925. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6926. if (toState == "设计师")
  6927. {
  6928. apiVo.isOriginal = Convert.ToBoolean(original);
  6929. }
  6930. designHelper.API_WorkCore(apiVo);//afterDesign
  6931. CeErpMethod methodSql = new CeErpMethod();
  6932. methodSql.con = entity.AfterSaleMethod;
  6933. methodSql.addTime = DateTime.Now;
  6934. methodSql.Create();
  6935. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6936. CeErpMethod.ExecuteNonQuery(delsql);
  6937. if (isCompale)
  6938. {
  6939. aftersale_data_change(entity.ctid);
  6940. }
  6941. returnSuccessMsg("操作成功!");
  6942. return;
  6943. }
  6944. returnErrorMsg("找不到订单记录");
  6945. }
  6946. }
  6947. public void ins_erp_toresponsible()
  6948. {
  6949. if (UrlPostParmsCheck("ctid"))
  6950. {
  6951. string eid = GetPostString("ctid");
  6952. CeErpTradeCell entity = null;
  6953. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6954. if (entity != null)
  6955. {
  6956. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6957. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6958. {
  6959. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6960. return;
  6961. }
  6962. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6963. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6964. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6965. if (entity.AfterSalePreTime == null)
  6966. {
  6967. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6968. {
  6969. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6970. }
  6971. }
  6972. entity.AfterSalePreTime = DateTime.Now;
  6973. //预完成给售后主管审核客户问题直接完成
  6974. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6975. {
  6976. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6977. {
  6978. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6979. }
  6980. }
  6981. ceErpTradeAfterSaleExtend.Update();
  6982. entity.AfterSaleState = 2;
  6983. entity.UpdateTime = DateTime.Now;
  6984. entity.Update();
  6985. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6986. aftersale_data_change(entity.ctid);
  6987. returnSuccessMsg("操作成功!");
  6988. return;
  6989. }
  6990. returnErrorMsg("找不到订单记录");
  6991. }
  6992. }
  6993. public void cancel_erp_aftersaleanddelnew()
  6994. {
  6995. if (UrlPostParmsCheck("ctid"))
  6996. {
  6997. string eid = GetPostString("ctid");
  6998. CeErpTradeCell entity = null;
  6999. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7000. if (entity != null)
  7001. {
  7002. entity.AfterSaleState = 0;
  7003. entity.AfterSaleReason = "";
  7004. entity.AfterSaleMethod = "";
  7005. entity.AfterSaleMemo = "";
  7006. entity.AfterSaleResponsible = "";
  7007. entity.ResponsibleUserId = "";
  7008. entity.DeductFee = 0;
  7009. entity.RefundFee = 0;
  7010. entity.IsArbitrate = 0;
  7011. CeErpTradeResponsible.DelByTid(eid, -1);
  7012. entity.Update();
  7013. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7014. if (after != null)
  7015. {
  7016. if (after.OrderState < 5)
  7017. CeErpTradeCell.DelByCtid("S_" + eid);
  7018. }
  7019. returnSuccessMsg("操作成功!");
  7020. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7021. return;
  7022. }
  7023. returnErrorMsg("找不到订单记录");
  7024. }
  7025. }
  7026. public void get_erp_aftersale_pregather()
  7027. {
  7028. List<string> lw = new List<string>();
  7029. int st = GetInt("st");
  7030. string tid = GetPostString("ctid");
  7031. if (tid.Length > 0)
  7032. {
  7033. string select_tid = getTidByCtid(tid);
  7034. lw.Add(string.Format("tid='{0}'", select_tid));
  7035. }
  7036. string shopname = GetPostString("shopname");
  7037. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7038. string buyernick = GetPostString("buyer_nick");
  7039. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7040. string sellermemo = GetPostString("seller_memo");
  7041. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7042. string orderState = GetPostString("orderState");
  7043. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7044. string reason = GetPostString("reason");
  7045. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7046. string method = GetPostString("method");
  7047. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7048. string handler = GetPostString("handler");
  7049. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7050. string handledate1 = GetPostString("handledate1");
  7051. string handledate2 = GetPostString("handledate2");
  7052. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7053. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7054. string supplier = GetPostString("supplier");
  7055. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7056. string responsible = GetPostString("responsibleman");
  7057. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7058. string customer = GetPostString("customer");
  7059. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7060. string design = GetPostString("design");
  7061. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7062. string afterMemoType = GetPostString("aftermemotype");
  7063. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7064. string afterSaleMemo = GetPostString("afterSaleMemo");
  7065. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7066. string afterresult = GetPostString("afterresult");
  7067. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7068. string poscode = CurrentUser.UserPost.Post.Code;
  7069. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7070. {
  7071. string shopid = CurrentUser.User.pemShop;
  7072. lw.Add(string.Format("shopId in ({0})", shopid));
  7073. }
  7074. var mainwhere = string.Join(" and ", lw.ToArray());
  7075. string ro_json = "";
  7076. string type = GetPostString("gather_type");
  7077. int number = 0;
  7078. if (poscode == "AfterSale")
  7079. {
  7080. //处理中
  7081. if (type == "Handling")
  7082. {
  7083. 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) : ""));
  7084. DataTable dt = null;
  7085. try
  7086. {
  7087. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7088. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7089. }
  7090. catch (Exception e)
  7091. {
  7092. dt = new DataTable();
  7093. }
  7094. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7095. return;
  7096. }
  7097. if (type == "Wait")
  7098. {
  7099. //待处理
  7100. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7101. DataTable dt1 = null;
  7102. try
  7103. {
  7104. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7105. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7106. }
  7107. catch (Exception e)
  7108. {
  7109. dt1 = new DataTable();
  7110. }
  7111. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7112. return;
  7113. }
  7114. if (type == "back")
  7115. {
  7116. //打回
  7117. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7118. DataTable dt2 = null;
  7119. try
  7120. {
  7121. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7122. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7123. }
  7124. catch (Exception e)
  7125. {
  7126. dt2 = new DataTable();
  7127. }
  7128. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7129. return;
  7130. }
  7131. if (type == "preCompletion")
  7132. {
  7133. //预完成
  7134. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7135. DataTable dt3 = null;
  7136. try
  7137. {
  7138. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7139. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7140. }
  7141. catch (Exception e)
  7142. {
  7143. dt3 = new DataTable();
  7144. }
  7145. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7146. return;
  7147. }
  7148. if (type == "documentary")
  7149. {
  7150. //跟单中
  7151. 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) : ""));
  7152. DataTable dt4 = null;
  7153. try
  7154. {
  7155. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7156. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7157. }
  7158. catch (Exception e)
  7159. {
  7160. dt4 = new DataTable();
  7161. }
  7162. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7163. return;
  7164. }
  7165. if (type == "reBack")
  7166. {
  7167. //被打回
  7168. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7169. DataTable dt1 = null;
  7170. try
  7171. {
  7172. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7173. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7174. }
  7175. catch (Exception e)
  7176. {
  7177. dt1 = new DataTable();
  7178. }
  7179. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7180. return;
  7181. }
  7182. }
  7183. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7184. {
  7185. if (type == "puBack")
  7186. {
  7187. //退回
  7188. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7189. DataTable dt = null;
  7190. try
  7191. {
  7192. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7193. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7194. }
  7195. catch (Exception e)
  7196. {
  7197. dt = new DataTable();
  7198. }
  7199. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7200. return;
  7201. }
  7202. if (type == "reBack")
  7203. {
  7204. //打回
  7205. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7206. DataTable dt1 = null;
  7207. try
  7208. {
  7209. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7210. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7211. }
  7212. catch (Exception e)
  7213. {
  7214. dt1 = new DataTable();
  7215. }
  7216. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7217. return;
  7218. }
  7219. if (type == "examEd")
  7220. {
  7221. //已审核
  7222. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7223. DataTable dt2 = null;
  7224. try
  7225. {
  7226. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7227. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7228. }
  7229. catch (Exception e)
  7230. {
  7231. dt2 = new DataTable();
  7232. }
  7233. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7234. return;
  7235. }
  7236. if (type == "waitExam")
  7237. {
  7238. //待审核
  7239. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7240. DataTable dt3 = null;
  7241. try
  7242. {
  7243. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7244. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7245. }
  7246. catch (Exception e)
  7247. {
  7248. dt3 = new DataTable();
  7249. }
  7250. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7251. return;
  7252. }
  7253. if (type == "Handling")
  7254. {
  7255. //处理中
  7256. 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) : ""));
  7257. DataTable dt4 = null;
  7258. try
  7259. {
  7260. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7261. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7262. }
  7263. catch (Exception e)
  7264. {
  7265. dt4 = new DataTable();
  7266. }
  7267. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7268. return;
  7269. }
  7270. if (type == "Wait")
  7271. {
  7272. //待处理
  7273. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7274. DataTable dt5 = null;
  7275. try
  7276. {
  7277. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7278. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7279. }
  7280. catch (Exception e)
  7281. {
  7282. dt5 = new DataTable();
  7283. }
  7284. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7285. return;
  7286. }
  7287. if (type == "documentary")
  7288. {
  7289. //跟单中
  7290. 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) : ""));
  7291. DataTable dt6 = null;
  7292. try
  7293. {
  7294. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7295. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7296. }
  7297. catch (Exception e)
  7298. {
  7299. dt6 = new DataTable();
  7300. }
  7301. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7302. return;
  7303. }
  7304. }
  7305. returnSuccess(ro_json);
  7306. }
  7307. public void end_erp_aftersale()
  7308. {
  7309. if (UrlPostParmsCheck("ctid"))
  7310. {
  7311. string eid = GetPostString("ctid");
  7312. CeErpTradeCell entity = null;
  7313. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7314. if (entity != null)
  7315. {
  7316. string stype = GetPostString("stype");
  7317. string typeStr = stype;
  7318. entity.AfterSaleState = 4;
  7319. entity.FinishAfterSaleTime = DateTime.Now;
  7320. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7321. entity.Update();
  7322. ApiVo apiVo = new ApiVo();
  7323. apiVo.orderNumber = entity.ctid;
  7324. apiVo.actionName = "afterOver";
  7325. designHelper.API_WorkCore(apiVo); //afterOver
  7326. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7327. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7328. CeErpSukuraData.createInfo(entity.ctid, 8);
  7329. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7330. returnSuccessMsg("操作成功!");
  7331. return;
  7332. }
  7333. returnErrorMsg("找不到订单记录");
  7334. }
  7335. }
  7336. public void ins_erp_finishaftersale()
  7337. {
  7338. if (UrlPostParmsCheck("id"))
  7339. {
  7340. string eid = GetPostString("id");
  7341. CeErpTradeResponsible entity = null;
  7342. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7343. if (entity != null)
  7344. {
  7345. entity.VerifyState = 1;
  7346. entity.VerifyTime = DateTime.Now;
  7347. entity.Update();
  7348. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7349. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7350. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7351. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7352. if (dt.Rows.Count <= 0)
  7353. {
  7354. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7355. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7356. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7357. CeErpSukuraData.createInfo(entity.tid, 8);
  7358. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7359. {
  7360. CeErpDesignerBill.Del(entity.tid);
  7361. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7362. }
  7363. }
  7364. returnSuccessMsg("操作成功!");
  7365. return;
  7366. }
  7367. returnErrorMsg("找不到订单记录");
  7368. }
  7369. }
  7370. public void upd_erp_arbitrateaftersale()
  7371. {
  7372. if (UrlPostParmsCheck("id"))
  7373. {
  7374. string eid = GetPostString("id");
  7375. CeErpTradeResponsible entity = null;
  7376. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7377. if (entity != null)
  7378. {
  7379. entity.IsArbitrate = 1;
  7380. entity.ArbitradeMemo = GetPostString("reason");
  7381. entity.VerifyState = 2;
  7382. entity.Update();
  7383. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7384. if (tradecell != null)
  7385. {
  7386. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7387. tradecell.IsArbitrate = 1;
  7388. tradecell.Update();
  7389. }
  7390. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7391. returnSuccessMsg("操作成功!");
  7392. return;
  7393. }
  7394. returnErrorMsg("找不到订单记录");
  7395. }
  7396. }
  7397. public void upd_erp_backaftersale()
  7398. {
  7399. if (UrlPostParmsCheck("tid"))
  7400. {
  7401. string eid = GetPostString("tid");
  7402. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7403. int backNum = 0;
  7404. if (number != null)
  7405. {
  7406. backNum = number.BackNum;
  7407. }
  7408. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7409. CeErpTradeCell entity = null;
  7410. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7411. if (entity != null)
  7412. {
  7413. entity.AfterSaleBackReason = GetPostString("backreason");
  7414. entity.AfterSaleState = 1;
  7415. entity.AfterSaleSupplierState = 0;
  7416. entity.UpdateTime = DateTime.Now;
  7417. entity.Update();
  7418. returnSuccessMsg("操作成功!");
  7419. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7420. return;
  7421. }
  7422. returnErrorMsg("找不到订单记录");
  7423. }
  7424. }
  7425. public void get_erp_supplieraftersalelist()
  7426. {
  7427. DataStruct dStruct = GetPostStruct();
  7428. List<string> lw = new List<string>();
  7429. string tid = GetPostString("ctid");
  7430. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7431. string shopname = GetPostString("shopname");
  7432. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7433. string buyernick = GetPostString("buyer_nick");
  7434. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7435. string sellermemo = GetPostString("seller_memo");
  7436. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7437. string orderState = GetPostString("orderState");
  7438. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7439. string afterState = GetPostString("afterstate");
  7440. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7441. string date1 = GetPostString("date1");
  7442. string date2 = GetPostString("date2");
  7443. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7444. if (dw.Length > 0) lw.Add(dw);
  7445. string price1 = GetPostString("price1");
  7446. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7447. string price2 = GetPostString("price2");
  7448. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7449. string reason = GetPostString("reason");
  7450. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7451. string method = GetPostString("method");
  7452. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7453. string handledate1 = GetPostString("handledate1");
  7454. string handledate2 = GetPostString("handledate2");
  7455. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7456. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7457. string handler = GetPostString("handler");
  7458. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7459. string afterdate1 = GetPostString("afterdate1");
  7460. string afterdate2 = GetPostString("afterdate2");
  7461. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7462. if (afterDate.Length > 0) lw.Add(afterDate);
  7463. string customer = GetPostString("customer");
  7464. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7465. string design = GetPostString("design");
  7466. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7467. string afterMemoType = GetPostString("aftermemotype");
  7468. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7469. string vstate = GetPostString("vstate");
  7470. if (vstate.Length > 0)
  7471. {
  7472. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7473. }
  7474. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7475. string supplier = GetPostString("supplier");
  7476. int supid = commonHelper.getSupplierIDByName(supplier);
  7477. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7478. string posCode = CurrentUser.UserPost.Post.Code;
  7479. if (posCode == "Supplier")
  7480. {
  7481. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7482. }
  7483. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7484. {
  7485. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7486. }
  7487. else
  7488. {
  7489. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7490. }
  7491. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7492. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7493. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7494. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7495. writeGridDataTableJson(dStruct.TotalCount, dt);
  7496. }
  7497. public void upd_erp_supverifyaftersale()
  7498. {
  7499. if (UrlPostParmsCheck("id"))
  7500. {
  7501. string id = GetPostString("id");
  7502. int st = GetPostInt("afterstate");
  7503. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7504. CeErpTradeCell entity = null;
  7505. if (ceErpTradeResponsible != null)
  7506. {
  7507. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7508. }
  7509. string afmemo = GetPostString("supmemo");
  7510. string image = GetPostString("image");
  7511. if (entity != null)
  7512. {
  7513. entity.AfterSaleSupplierState = st;
  7514. entity.AfterSaleSupplierMemo = afmemo;
  7515. if (st == 1)
  7516. {
  7517. ceErpTradeResponsible.VerifyState = 1;
  7518. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7519. ceErpTradeResponsible.Update();
  7520. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7521. if (isAll)
  7522. {
  7523. entity.AfterSaleState = 4;
  7524. entity.FinishAfterSaleTime = DateTime.Now;
  7525. }
  7526. }
  7527. else
  7528. {
  7529. CeErpTradeResponsible.dateByTid(entity.ctid);
  7530. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7531. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7532. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7533. if (num <= 1)
  7534. {
  7535. entity.AfterSaleState = 1;
  7536. }
  7537. else
  7538. {
  7539. entity.AfterSaleState = 5;
  7540. }
  7541. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7542. if (ceErpTradeAfterSaleExtend != null)
  7543. {
  7544. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7545. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7546. ceErpTradeAfterSaleExtend.Update();
  7547. }
  7548. else
  7549. {
  7550. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7551. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7552. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7553. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7554. ceErpTradeAfterSaleExtend.Create();
  7555. }
  7556. }
  7557. if (entity.AfterSaleState == 4)
  7558. {
  7559. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7560. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7561. {
  7562. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7563. }
  7564. ApiVo apiVo = new ApiVo();
  7565. apiVo.orderNumber = entity.ctid;
  7566. apiVo.actionName = "afterOver";
  7567. designHelper.API_WorkCore(apiVo); //afterOver
  7568. }
  7569. entity.UpdateTime = DateTime.Now;
  7570. entity.Update();
  7571. returnSuccessMsg("操作成功!");
  7572. CeErpSukuraData.createInfo(entity.ctid, 8);
  7573. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7574. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7575. return;
  7576. }
  7577. returnErrorMsg("找不到订单记录");
  7578. }
  7579. }
  7580. public void upd_erp_masteraftersale()
  7581. {
  7582. if (UrlPostParmsCheck("id"))
  7583. {
  7584. string id = GetPostString("id");
  7585. int st = GetPostInt("afterstate");
  7586. string afmemo = GetPostString("supmemo");
  7587. string image = GetPostString("image");
  7588. string textResult = GetPostString("textResult");
  7589. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7590. if (ceErpTradeResponsible != null)
  7591. {
  7592. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7593. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7594. ceErpTradeResponsible.Update();
  7595. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7596. if (entity != null)
  7597. {
  7598. entity.AfterSaleSupplierState = st;
  7599. entity.AfterSaleSupplierMemo = afmemo;
  7600. if (st == 1)
  7601. {
  7602. }
  7603. else
  7604. {
  7605. CeErpTradeResponsible.dateByTid(entity.ctid);
  7606. //退回到售后
  7607. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7608. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7609. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7610. if (num <= 1)
  7611. {
  7612. entity.AfterSaleState = 1;
  7613. }
  7614. else
  7615. {
  7616. entity.AfterSaleState = 5;
  7617. }
  7618. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7619. if (ceErpTradeAfterSaleExtend != null)
  7620. {
  7621. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7622. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7623. ceErpTradeAfterSaleExtend.Update();
  7624. }
  7625. else
  7626. {
  7627. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7628. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7629. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7630. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7631. ceErpTradeAfterSaleExtend.Create();
  7632. }
  7633. }
  7634. entity.UpdateTime = DateTime.Now;
  7635. entity.Update();
  7636. returnSuccessMsg("操作成功!");
  7637. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7638. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7639. return;
  7640. }
  7641. }
  7642. returnErrorMsg("找不到订单记录");
  7643. }
  7644. }
  7645. public void upd_erp_personaftersale()
  7646. {
  7647. if (UrlPostParmsCheck("id"))
  7648. {
  7649. //林小连
  7650. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7651. {
  7652. upd_erp_masteraftersale();
  7653. return;
  7654. }
  7655. string id = GetPostString("id");
  7656. int st = GetPostInt("afterstate");
  7657. string afmemo = GetPostString("supmemo");
  7658. string image = GetPostString("image");
  7659. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7660. if (ceErpTradeResponsible != null)
  7661. {
  7662. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7663. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7664. ceErpTradeResponsible.Update();
  7665. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7666. if (entity != null)
  7667. {
  7668. entity.AfterSaleSupplierMemo = afmemo;
  7669. entity.AfterSaleSupplierState = st;
  7670. if (st == 1)
  7671. {
  7672. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7673. if (isAll)
  7674. {
  7675. entity.AfterSaleState = 4;
  7676. entity.FinishAfterSaleTime = DateTime.Now;
  7677. }
  7678. }
  7679. else
  7680. {
  7681. CeErpTradeResponsible.dateByTid(entity.ctid);
  7682. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7683. if (ceErpTradeAfterSaleExtend != null)
  7684. {
  7685. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7686. ceErpTradeAfterSaleExtend.Update();
  7687. }
  7688. else
  7689. {
  7690. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7691. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7692. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7693. ceErpTradeAfterSaleExtend.Create();
  7694. }
  7695. //退回到主管
  7696. //entity.AfterSaleState = 2;
  7697. }
  7698. if (entity.AfterSaleState == 4)
  7699. {
  7700. ApiVo apiVo = new ApiVo();
  7701. apiVo.orderNumber = entity.ctid;
  7702. apiVo.actionName = "afterOver";
  7703. designHelper.API_WorkCore(apiVo); //afterOver
  7704. }
  7705. entity.UpdateTime = DateTime.Now;
  7706. entity.Update();
  7707. returnSuccessMsg("操作成功!");
  7708. CeErpSukuraData.createInfo(entity.ctid, 8);
  7709. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7710. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7711. return;
  7712. }
  7713. }
  7714. returnErrorMsg("找不到订单记录");
  7715. }
  7716. }
  7717. public void set_erp_supplierrefundtag()
  7718. {
  7719. if (UrlPostParmsCheck("ctid"))
  7720. {
  7721. string eid = GetPostString("ctid");
  7722. CeErpTradeCell entity = null;
  7723. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7724. if (entity != null)
  7725. {
  7726. entity.IsSupplierRefund = GetPostInt("tag");
  7727. entity.Update();
  7728. returnSuccessMsg("操作成功!");
  7729. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7730. return;
  7731. }
  7732. returnErrorMsg("找不到订单记录");
  7733. }
  7734. }
  7735. public void get_erp_refundlist()
  7736. {
  7737. DataStruct dStruct = GetPostStruct();
  7738. List<string> lw = new List<string>();
  7739. string tid = GetPostString("tid");
  7740. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7741. //string rid = GetPostString("refund_id");
  7742. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7743. string shopname = GetPostString("shopname");
  7744. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7745. string buyernick = GetPostString("buyer_nick");
  7746. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7747. string customer = GetPostString("customer");
  7748. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7749. string design = GetPostString("design");
  7750. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7751. string sellermemo = GetPostString("seller_memo");
  7752. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7753. //string date1 = GetPostString("date1");
  7754. //string date2 = GetPostString("date2");
  7755. //string dateType = GetPostString("dateType");
  7756. //if (dateType.Length > 0)
  7757. //{
  7758. // if (dateType == "1001") dateType = "0";
  7759. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7760. // if (searchDT.Count == 2)
  7761. // {
  7762. // date1 = searchDT[0].ToString();
  7763. // date2 = searchDT[1].ToString();
  7764. // }
  7765. //}
  7766. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7767. //if (dw.Length > 0) lw.Add(dw);
  7768. string redate1 = GetPostString("refunddate1");
  7769. string redate2 = GetPostString("refunddate2");
  7770. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7771. if (dwdate.Length > 0) lw.Add(dwdate);
  7772. string price1 = GetPostString("price1");
  7773. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7774. string price2 = GetPostString("price2");
  7775. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7776. string ispartrefund = GetPostString("ispartrefund");
  7777. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7778. string refundState = GetPostString("refundvstate");
  7779. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7780. int st = GetInt("st");
  7781. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7782. {
  7783. string responsible = GetPostString("responsibleman");
  7784. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7785. lw.Add(string.Format("RefundState>={0}", st));
  7786. string code = CurrentUser.UserPost.Post.Code;
  7787. if (code == "CustomerService")
  7788. {
  7789. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7790. }
  7791. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7792. {
  7793. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7794. }
  7795. else if (code == "Place" || code == "PlaceMr")
  7796. {
  7797. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7798. }
  7799. dStruct.Order = "RefundState asc,created desc";
  7800. }
  7801. else if (st == 10)
  7802. {
  7803. string responsible = GetPostString("responsibleman");
  7804. if (responsible == "空白")
  7805. {
  7806. lw.Add(string.Format("ResponsibleUserName = ''"));
  7807. }
  7808. else if (responsible.Length > 0)
  7809. {
  7810. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7811. }
  7812. lw.Add(string.Format("RefundState>=0"));
  7813. dStruct.Order = "created desc";
  7814. }
  7815. else
  7816. {
  7817. string responsible = GetPostString("responsibleman");
  7818. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7819. lw.Add(string.Format("RefundState={0}", st));
  7820. dStruct.Order = "created desc";
  7821. }
  7822. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7823. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7824. dt.Columns.Add("refund_fees");
  7825. foreach (DataRow dr in dt.Rows)
  7826. {
  7827. String status = dr["status"].ToString();
  7828. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7829. {
  7830. dr["refund_fees"] = dr["refund_fee"];
  7831. }
  7832. else
  7833. {
  7834. dr["refund_fees"] = "0.0";
  7835. }
  7836. }
  7837. writeGridDataTableJson(dStruct.TotalCount, dt);
  7838. }
  7839. public void get_erp_refunddesignlist()
  7840. {
  7841. DataStruct dStruct = GetPostStruct();
  7842. List<string> lw = new List<string>();
  7843. string tid = GetPostString("tid");
  7844. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7845. string shopname = GetPostString("shopname");
  7846. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7847. string buyernick = GetPostString("buyer_nick");
  7848. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7849. string customer = GetPostString("customer");
  7850. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7851. string design = GetPostString("design");
  7852. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7853. string sellermemo = GetPostString("seller_memo");
  7854. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7855. string redate1 = GetPostString("refunddate1");
  7856. string redate2 = GetPostString("refunddate2");
  7857. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7858. if (dwdate.Length > 0) lw.Add(dwdate);
  7859. string price1 = GetPostString("price1");
  7860. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7861. string price2 = GetPostString("price2");
  7862. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7863. string ispartrefund = GetPostString("ispartrefund");
  7864. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7865. string designerorg = GetPostString("designerorg");
  7866. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7867. string refundState = GetPostString("refundState");
  7868. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7869. int myOrgid = CurrentUser.UserPost.OrgID;
  7870. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7871. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7872. {
  7873. if (CurrentUser.User.TeamIds.Length > 0)
  7874. {
  7875. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7876. }
  7877. else
  7878. {
  7879. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7880. }
  7881. }
  7882. else if ("SysAdmin".Equals(myOrgCode))
  7883. {
  7884. }
  7885. else
  7886. {
  7887. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7888. {
  7889. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7890. }
  7891. else
  7892. {
  7893. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7894. }
  7895. }
  7896. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7897. dStruct.Order = "created desc";
  7898. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7899. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7900. dt.Columns.Add("refund_fees");
  7901. foreach (DataRow dr in dt.Rows)
  7902. {
  7903. String status = dr["status"].ToString();
  7904. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7905. {
  7906. dr["refund_fees"] = dr["refund_fee"];
  7907. }
  7908. else
  7909. {
  7910. dr["refund_fees"] = "0.0";
  7911. }
  7912. }
  7913. writeGridDataTableJson(dStruct.TotalCount, dt);
  7914. }
  7915. public void handle_erp_refundtag()
  7916. {
  7917. if (UrlPostParmsCheck("refund_id"))
  7918. {
  7919. string eid = GetPostString("refund_id");
  7920. string respMan = GetPostString("ResponsibleName");
  7921. if (respMan.Length <= 0)
  7922. {
  7923. returnErrorMsg("责任人不能为空");
  7924. return;
  7925. }
  7926. CeErpTradeRefund entity = null;
  7927. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7928. if (entity != null)
  7929. {
  7930. entity.ResponsibleUserName = respMan;
  7931. string userid = GetPostString("ResponsibleUserId");
  7932. if (userid.Length > 0)
  7933. {
  7934. entity.ResponsibleUserId = userid;
  7935. }
  7936. entity.Memo = GetPostString("Memo");
  7937. if (respMan.IndexOf("客服") != -1 ||
  7938. respMan.IndexOf("设计师") != -1 ||
  7939. respMan.IndexOf("下单员") != -1)
  7940. {
  7941. entity.RefundState = 2;
  7942. }
  7943. else
  7944. {
  7945. entity.RefundState = 3;
  7946. }
  7947. entity.modified = DateTime.Now;
  7948. entity.Update();
  7949. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7950. returnSuccessMsg("操作成功!");
  7951. return;
  7952. }
  7953. returnErrorMsg("找不到订单记录");
  7954. }
  7955. }
  7956. public void handle_erp_designrefundtag()
  7957. {
  7958. if (UrlPostParmsCheck("refund_id"))
  7959. {
  7960. string eid = GetPostString("refund_id");
  7961. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7962. if (ceErpTradeCellExtend == null)
  7963. {
  7964. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7965. ceErpTradeCellExtend.ctid = eid;
  7966. }
  7967. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7968. if (ceErpTradeCellExtend.ID > 0)
  7969. {
  7970. ceErpTradeCellExtend.Update();
  7971. }
  7972. else
  7973. {
  7974. ceErpTradeCellExtend.Create();
  7975. }
  7976. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7977. returnSuccessMsg("操作成功!");
  7978. return;
  7979. }
  7980. returnErrorMsg("找不到订单记录");
  7981. }
  7982. public void upd_erp_refundverify()
  7983. {
  7984. if (UrlPostParmsCheck("refund_id"))
  7985. {
  7986. string eid = GetPostString("refund_id");
  7987. CeErpTradeRefund entity = null;
  7988. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7989. if (entity != null)
  7990. {
  7991. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7992. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7993. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7994. {
  7995. entity.RefundState = 2;
  7996. }
  7997. else
  7998. {
  7999. entity.RefundState = 3;
  8000. }
  8001. entity.Update();
  8002. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8003. returnSuccessMsg("操作成功!");
  8004. return;
  8005. }
  8006. returnErrorMsg("找不到订单记录");
  8007. }
  8008. }
  8009. public void upd_erp_refundapprove()
  8010. {
  8011. if (UrlPostParmsCheck("refund_id"))
  8012. {
  8013. string eid = GetPostString("refund_id");
  8014. CeErpTradeRefund entity = null;
  8015. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8016. if (entity != null)
  8017. {
  8018. int apr = GetPostInt("approve");
  8019. if (apr == 0)
  8020. {
  8021. entity.RefundState = 1;
  8022. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8023. }
  8024. else if (apr == 1)
  8025. {
  8026. entity.RefundState = 3;
  8027. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8028. }
  8029. entity.modified = DateTime.Now;
  8030. entity.Update();
  8031. returnSuccessMsg("操作成功!");
  8032. return;
  8033. }
  8034. returnErrorMsg("找不到订单记录");
  8035. }
  8036. }
  8037. public void get_erp_billlist()
  8038. {
  8039. DataStruct dStruct = GetPostStruct();
  8040. List<string> lw = new List<string>();
  8041. string title = GetPostString("title");
  8042. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8043. string tid = GetPostString("tid");
  8044. string tids = GetPostString("tids");
  8045. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8046. if (tids.Length > 0)
  8047. {
  8048. tids = "'" + tids + "'";
  8049. tids = tids.Replace(",", "','");
  8050. lw.Add(string.Format("tid in ({0})", tids));
  8051. }
  8052. string shopname = GetPostString("shopname");
  8053. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8054. string buyernick = GetPostString("buyer_nick");
  8055. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8056. string customer = GetPostString("customer");
  8057. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8058. string date1 = GetPostString("date1");
  8059. string date2 = GetPostString("date2");
  8060. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8061. if (dw.Length > 0) lw.Add(dw);
  8062. string price1 = GetPostString("price1");
  8063. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8064. string price2 = GetPostString("price2");
  8065. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8066. string returndate1 = GetPostString("returndate1");
  8067. string returndate2 = GetPostString("returndate2");
  8068. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8069. if (dw1.Length > 0) lw.Add(dw1);
  8070. string billtype = GetPostString("billtype");
  8071. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8072. string billstate = GetPostString("billstate");
  8073. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8074. string usershop = CurrentUser.User.pemShop;
  8075. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8076. dStruct.Order = "createTime desc";
  8077. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8078. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8079. //foreach (DataRow dr in dt.Rows)
  8080. //{
  8081. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8082. //}
  8083. writeGridDataTableJson(dStruct.TotalCount, dt);
  8084. }
  8085. public void modify_erp_billinfo()
  8086. {
  8087. if (UrlPostParmsCheck("ID"))
  8088. {
  8089. string eid = GetPostString("ID");
  8090. CeErpBill bill_entity = null;
  8091. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8092. if (bill_entity != null)
  8093. {
  8094. bill_entity.tid = GetPostString("tid");
  8095. bill_entity.title = GetPostString("title");
  8096. bill_entity.tax = GetPostString("tax");
  8097. bill_entity.bank = GetPostString("bank");
  8098. bill_entity.bankac = GetPostString("bankac");
  8099. bill_entity.address = GetPostString("address");
  8100. bill_entity.phone = GetPostString("phone");
  8101. bill_entity.price = GetPostString("price");
  8102. bill_entity.productId = GetPostInt("ProductName");
  8103. bill_entity.num = GetPostInt("num");
  8104. bill_entity.unit = GetPostString("unit");
  8105. bill_entity.type = GetPostString("type");
  8106. bill_entity.sendType = GetPostString("SendType");
  8107. bill_entity.email = GetPostString("email");
  8108. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8109. bill_entity.shopName = GetPostString("ShopName");
  8110. bill_entity.applymemo = GetPostString("applymemo");
  8111. bill_entity.modifyTime = DateTime.Now;
  8112. bill_entity.createTime = DateTime.Now;
  8113. bill_entity.state = 0;
  8114. bill_entity.Update();
  8115. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8116. returnSuccessMsg("发票修改成功!");
  8117. return;
  8118. }
  8119. returnErrorMsg("找不到对应记录");
  8120. }
  8121. }
  8122. public void set_erp_invoicing()
  8123. {
  8124. if (UrlPostParmsCheck("id"))
  8125. {
  8126. try
  8127. {
  8128. string eid = GetPostString("id");
  8129. CeErpBill bill_entity = null;
  8130. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8131. if (bill_entity != null)
  8132. {
  8133. int ComId = GetPostInt("ComId");
  8134. //string memo = GetPostString("Memo");
  8135. int allInfo = GetPostInt("allinfo");
  8136. string clert = CurrentUser.User.Name;
  8137. //string detailValue = GetPostString("detailvalue");
  8138. string billId = bill_entity.billOrderId;
  8139. string[] billIdList = billId.Split(',');
  8140. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8141. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8142. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8143. {
  8144. billCount += 1;
  8145. }
  8146. if (billId.Length <= 0 || billIdList.Length != billCount)
  8147. {
  8148. bill_entity.billOrderId = "";
  8149. string prebill = "ltb";
  8150. for (int idx = 1; idx <= billCount; idx++)
  8151. {
  8152. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8153. string billoid = prebill + idx + dtstr;
  8154. bill_entity.billOrderId += billoid;
  8155. if (idx < billCount)
  8156. {
  8157. bill_entity.billOrderId += ",";
  8158. }
  8159. }
  8160. }
  8161. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8162. if (bill_entity.state == 5)
  8163. {
  8164. string errMsg = bill_entity.failerror;
  8165. string[] errlist = errMsg.Split('|');
  8166. string[] errTags = new string[errlist.Length];
  8167. for (int itag = 0; itag < errlist.Length; itag++)
  8168. {
  8169. if (errlist[itag].Length <= 0) continue;
  8170. errTags[itag] = errlist[itag].Split('&')[0];
  8171. }
  8172. for (int iii = 0; iii < errTags.Length; iii++)
  8173. {
  8174. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8175. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8176. if (billOrderList.Length >= erroBillOrderTag)
  8177. {
  8178. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8179. if (needModifyBillId.Length <= 19)
  8180. {
  8181. needModifyBillId = needModifyBillId + "1";
  8182. }
  8183. else
  8184. {
  8185. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8186. last = last + 1;
  8187. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8188. }
  8189. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8190. }
  8191. }
  8192. }
  8193. bool isHaveBillSucces = false;
  8194. string totalRes = "";
  8195. bill_entity.failerror = "";
  8196. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8197. {
  8198. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8199. totalRes += res;
  8200. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8201. {
  8202. isHaveBillSucces = true;
  8203. bill_entity.comId = ComId;
  8204. bill_entity.state = 1;
  8205. bill_entity.executeTime = DateTime.Now;
  8206. bill_entity.executeUser = clert;
  8207. }
  8208. else
  8209. {
  8210. bill_entity.state = 5;
  8211. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8212. }
  8213. }
  8214. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8215. bill_entity.Update();
  8216. if (isHaveBillSucces)
  8217. {
  8218. StringBuilder sql = new StringBuilder();
  8219. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8220. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8221. }
  8222. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8223. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8224. {
  8225. returnErrorMsg("开票失败");
  8226. }
  8227. else
  8228. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8229. return;
  8230. }
  8231. returnErrorMsg("找不到对应记录");
  8232. }
  8233. catch (Exception ex)
  8234. {
  8235. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8236. returnErrorMsg("操作失败");
  8237. }
  8238. }
  8239. }
  8240. public void get_erp_invoicing_back()
  8241. {
  8242. if (UrlPostParmsCheck("id"))
  8243. {
  8244. try
  8245. {
  8246. string id = GetPostString("id");
  8247. CeErpBill entiy = CeErpBill.Get(id);
  8248. if (entiy != null)
  8249. {
  8250. if (entiy.state == 0)
  8251. {
  8252. returnErrorMsg("发票还未开具");
  8253. return;
  8254. }
  8255. string[] billOrderList = entiy.billOrderId.Split(',');
  8256. int iTag = 0;
  8257. entiy.fplsh = "";
  8258. entiy.fpdm = "";
  8259. entiy.fphm = "";
  8260. foreach (string billOrderId in billOrderList)
  8261. {
  8262. iTag++;
  8263. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8264. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8265. {
  8266. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8267. try
  8268. {
  8269. Invoicing_get_response_Obj iObj = null;
  8270. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8271. if (iObj != null)
  8272. {
  8273. entiy.state = 2;
  8274. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8275. entiy.fpdm += iObj.list[0].c_fpdm;
  8276. entiy.fphm += iObj.list[0].c_fphm;
  8277. if (iTag < billOrderList.Length)
  8278. {
  8279. entiy.fplsh += ",";
  8280. entiy.fpdm += ",";
  8281. entiy.fphm += ",";
  8282. }
  8283. entiy.Update();
  8284. }
  8285. StringBuilder sql = new StringBuilder();
  8286. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8287. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8288. returnSuccessMsg("开票成功");
  8289. }
  8290. catch (Exception ex)
  8291. {
  8292. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8293. }
  8294. return;
  8295. }
  8296. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8297. {
  8298. var res_obj = new
  8299. {
  8300. data = "开票中"
  8301. };
  8302. string ro_json = JsonConvert.SerializeObject(res_obj);
  8303. returnSuccess(ro_json);
  8304. return;
  8305. }
  8306. else
  8307. {
  8308. int eidx = res.IndexOf("c_resultmsg");
  8309. int lidx = res.IndexOf("c_status");
  8310. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8311. entiy.state = 5;
  8312. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8313. entiy.Update();
  8314. returnErrorMsg("开票失败");
  8315. return;
  8316. }
  8317. }
  8318. }
  8319. }
  8320. catch (Exception ex)
  8321. {
  8322. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8323. }
  8324. return;
  8325. }
  8326. }
  8327. public void get_erp_invoicing()
  8328. {
  8329. if (UrlPostParmsCheck("id"))
  8330. {
  8331. try
  8332. {
  8333. string id = GetPostString("id");
  8334. CeErpBill entiy = CeErpBill.Get(id);
  8335. if (entiy != null)
  8336. {
  8337. if (entiy.state == 0)
  8338. {
  8339. returnErrorMsg("发票还未开具");
  8340. return;
  8341. }
  8342. if (entiy.sendType == "纸质发票")
  8343. {
  8344. if (entiy.img.Length <= 0)
  8345. {
  8346. returnErrorMsg("查无纸质发票");
  8347. return;
  8348. }
  8349. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8350. returnSuccess(returnres);
  8351. return;
  8352. }
  8353. string[] billOrderList = entiy.billOrderId.Split(',');
  8354. int iTag = 0;
  8355. string fpUrl = "";
  8356. entiy.fplsh = "";
  8357. entiy.fpdm = "";
  8358. entiy.fphm = "";
  8359. foreach (string billOrderId in billOrderList)
  8360. {
  8361. iTag++;
  8362. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8363. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8364. {
  8365. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8366. Invoicing_get_response_Obj iObj = null;
  8367. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8368. if (iObj != null)
  8369. {
  8370. //entiy.state = 2;
  8371. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8372. entiy.fpdm += iObj.list[0].c_fpdm;
  8373. entiy.fphm += iObj.list[0].c_fphm;
  8374. if (iTag < billOrderList.Length)
  8375. {
  8376. entiy.fplsh += ",";
  8377. entiy.fpdm += ",";
  8378. entiy.fphm += ",";
  8379. }
  8380. entiy.Update();
  8381. fpUrl += iObj.list[0].c_url + ",";
  8382. }
  8383. //returnSuccess(res);
  8384. StringBuilder sql = new StringBuilder();
  8385. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8386. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8387. }
  8388. else
  8389. {
  8390. int eidx = res.IndexOf("c_resultmsg");
  8391. //int lidx = res.IndexOf("c_status");
  8392. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8393. //开票失败
  8394. entiy.state = 5;
  8395. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8396. entiy.Update();
  8397. returnErrorMsg("开票失败");
  8398. return;
  8399. }
  8400. }
  8401. var returnObj = new
  8402. {
  8403. data = fpUrl
  8404. };
  8405. string ro_json = JsonConvert.SerializeObject(returnObj);
  8406. returnSuccess(ro_json);
  8407. }
  8408. }
  8409. catch (Exception ex)
  8410. {
  8411. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8412. }
  8413. return;
  8414. }
  8415. }
  8416. public void save_erp_billimg()
  8417. {
  8418. if (UrlPostParmsCheck("id"))
  8419. {
  8420. string eid = GetPostString("id");
  8421. CeErpBill bill_entity = null;
  8422. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8423. if (bill_entity != null)
  8424. {
  8425. bill_entity.img = GetPostString("img");
  8426. bill_entity.executeTime = DateTime.Now;
  8427. bill_entity.state = 2;
  8428. bill_entity.Update();
  8429. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8430. returnSuccessMsg("保存成功");
  8431. }
  8432. return;
  8433. }
  8434. }
  8435. public void upd_erp_billreturnback()
  8436. {
  8437. if (UrlPostParmsCheck("id"))
  8438. {
  8439. int eid = GetPostInt("id");
  8440. CeErpBill bill_entity = null;
  8441. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8442. if (bill_entity != null)
  8443. {
  8444. bill_entity.state = 3;
  8445. bill_entity.returnReason = GetPostString("reason");
  8446. bill_entity.Update();
  8447. returnSuccessMsg("驳回成功!");
  8448. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8449. }
  8450. return;
  8451. }
  8452. }
  8453. public void cancel_erp_bill()
  8454. {
  8455. if (UrlPostParmsCheck("id"))
  8456. {
  8457. int eid = GetPostInt("id");
  8458. int detailValue = GetPostInt("detailvalue");
  8459. CeErpBill bill_entity = null;
  8460. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8461. string cres = "";
  8462. string gres = "";
  8463. if (bill_entity != null)
  8464. {
  8465. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8466. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8467. {
  8468. int iTag = 0;
  8469. bill_entity.fplsh = "";
  8470. bill_entity.fpdm = "";
  8471. bill_entity.fphm = "";
  8472. foreach (string billOrderId in billOrderList)
  8473. {
  8474. iTag++;
  8475. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8476. if (gres.IndexOf("success") != -1)
  8477. {
  8478. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8479. Invoicing_get_response_Obj iObj = null;
  8480. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8481. if (iObj != null)
  8482. {
  8483. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8484. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8485. bill_entity.fphm += iObj.list[0].c_fphm;
  8486. if (iTag < billOrderList.Length)
  8487. {
  8488. bill_entity.fplsh += ",";
  8489. bill_entity.fpdm += ",";
  8490. bill_entity.fphm += ",";
  8491. }
  8492. bill_entity.Update();
  8493. }
  8494. }
  8495. else
  8496. {
  8497. returnErrorMsg(gres);
  8498. return;
  8499. }
  8500. }
  8501. }
  8502. if (bill_entity.sendType == "纸质发票")
  8503. {
  8504. //作废
  8505. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8506. //if (DateTime.Now.Month == extime.Month)
  8507. //{
  8508. //cres = taobaoHelper.cancel_invoicing(eid);
  8509. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8510. //{
  8511. bill_entity.state = 4;//已作废
  8512. bill_entity.Update();
  8513. returnSuccessMsg("发票已作废");
  8514. return;
  8515. //}
  8516. //else
  8517. //{
  8518. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8519. // bill_entity.Update();
  8520. // returnErrorMsg(cres);
  8521. // return;
  8522. //}
  8523. //}
  8524. //else
  8525. //{
  8526. // returnErrorMsg("纸质发票只能作废本月的发票");
  8527. // return;
  8528. //}
  8529. }
  8530. //红冲
  8531. int redTag = 0;
  8532. string[] fpdmList = bill_entity.fpdm.Split(',');
  8533. string[] fphmList = bill_entity.fphm.Split(',');
  8534. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8535. {
  8536. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8537. return;
  8538. }
  8539. foreach (string billOrderId in billOrderList)
  8540. {
  8541. redTag++;
  8542. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8543. cres += onecres;
  8544. cres += ",";
  8545. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8546. {
  8547. bill_entity.state = 4;//已作废
  8548. //bill_entity.Update();
  8549. //returnSuccessMsg("发票已红冲");
  8550. }
  8551. else if (onecres.IndexOf("重复冲红") != -1)
  8552. {
  8553. bill_entity.state = 4;//已作废
  8554. //bill_entity.Update();
  8555. //returnSuccessMsg("发票已红冲");
  8556. }
  8557. else
  8558. {
  8559. string errmsg = commonHelper.KeepChinese(onecres);
  8560. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8561. }
  8562. }
  8563. bill_entity.Update();
  8564. if (cres.IndexOf("失败") != -1)
  8565. returnErrorMsg("红冲失败");
  8566. else
  8567. returnSuccessMsg("发票已红冲");
  8568. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8569. return;
  8570. }
  8571. return;
  8572. }
  8573. }
  8574. public void del_erp_billorder()
  8575. {
  8576. if (UrlPostParmsCheck("id"))
  8577. {
  8578. string eid = GetPostString("id");
  8579. CeErpBill.Del(eid);
  8580. CeErpBill bill = CeErpBill.Get(eid);
  8581. if (bill != null)
  8582. {
  8583. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8584. }
  8585. returnSuccessMsg("删除成功");
  8586. }
  8587. }
  8588. public void finish_erp_bill()
  8589. {
  8590. if (UrlPostParmsCheck("ids"))
  8591. {
  8592. string eids = GetPostString("ids");
  8593. string[] list = eids.Split(',');
  8594. foreach (string eid in list)
  8595. {
  8596. CeErpBill bill = CeErpBill.Get(eid);
  8597. if (bill != null)
  8598. {
  8599. bill.state = 2;
  8600. bill.Update();
  8601. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8602. }
  8603. }
  8604. returnSuccessMsg("操作成功");
  8605. }
  8606. }
  8607. public void get_erp_returncash()
  8608. {
  8609. DataStruct dStruct = GetPostStruct();
  8610. List<string> lw = new List<string>();
  8611. string tid = GetPostString("tid");
  8612. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8613. string shopname = GetPostString("shopname");
  8614. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8615. string buyernick = GetPostString("buyer_nick");
  8616. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8617. string customer = GetPostString("customer");
  8618. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8619. string returndate1 = GetPostString("returndate1");
  8620. string returndate2 = GetPostString("returndate2");
  8621. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8622. if (dw.Length > 0) lw.Add(dw);
  8623. string finishDate1 = GetPostString("finishdate1");
  8624. string finishDate2 = GetPostString("finishdate2");
  8625. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8626. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8627. string returntype = GetPostString("returntype");
  8628. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8629. string returnvstate = GetPostString("returnvstate");
  8630. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8631. dStruct.Order = "created desc";
  8632. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8633. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8634. writeGridDataTableJson(dStruct.TotalCount, dt);
  8635. }
  8636. public void get_erp_staygoods()
  8637. {
  8638. DataStruct dStruct = GetPostStruct();
  8639. List<string> lw = new List<string>();
  8640. string tid = GetPostString("tid");
  8641. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8642. string shopname = GetPostString("shopname");
  8643. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8644. string wangwang = GetPostString("wangwang");
  8645. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8646. string customer = GetPostString("customer");
  8647. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8648. string returndate1 = GetPostString("returndate1");
  8649. string returndate2 = GetPostString("returndate2");
  8650. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8651. if (dw.Length > 0) lw.Add(dw);
  8652. string finishDate1 = GetPostString("finishdate1");
  8653. string finishDate2 = GetPostString("finishdate2");
  8654. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8655. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8656. string returnvstate = GetPostString("returnvstate");
  8657. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8658. string persuadetype = GetPostString("persuadetype");
  8659. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8660. string customerOrg = GetPostString("customerOrg");
  8661. if (customerOrg.Length > 0)
  8662. {
  8663. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8664. }
  8665. dStruct.Order = "creata_time desc";
  8666. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8667. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8668. writeGridDataTableJson(dStruct.TotalCount, dt);
  8669. }
  8670. public void upd_erp_staygoods()
  8671. {
  8672. if (UrlPostParmsCheck("id"))
  8673. {
  8674. int eid = GetPostInt("id");
  8675. CeErpStayGoods entity = null;
  8676. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8677. if (entity != null)
  8678. {
  8679. entity.audit_type = 1;
  8680. entity.audit_time = DateTime.Now;
  8681. entity.audit_u_id = CurrentUser.UserID;
  8682. entity.audit_u_name = CurrentUser.UserName;
  8683. entity.Update();
  8684. returnSuccessMsg("审核成功!");
  8685. return;
  8686. }
  8687. returnErrorMsg("找不到订单记录");
  8688. }
  8689. }
  8690. public void upd_erp_stayGoodsback()
  8691. {
  8692. if (UrlPostParmsCheck("id"))
  8693. {
  8694. int eid = GetPostInt("id");
  8695. CeErpStayGoods entity = null;
  8696. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8697. if (entity != null)
  8698. {
  8699. entity.audit_text = GetPostString("reason");
  8700. entity.audit_type = 2;
  8701. entity.audit_time = DateTime.Now;
  8702. entity.audit_u_id = CurrentUser.UserID;
  8703. entity.audit_u_name = CurrentUser.UserName;
  8704. entity.Update();
  8705. returnSuccessMsg("退回成功!");
  8706. return;
  8707. }
  8708. returnErrorMsg("找不到订单记录");
  8709. }
  8710. }
  8711. public void upd_erp_returncashverify()
  8712. {
  8713. if (UrlPostParmsCheck("ID"))
  8714. {
  8715. int eid = GetPostInt("ID");
  8716. CeErpReturnCash entity = null;
  8717. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8718. if (entity != null)
  8719. {
  8720. entity.cashstate = 1;
  8721. entity.verifytime = DateTime.Now;
  8722. entity.verifyuserid = CurrentUser.UserID;
  8723. entity.Update();
  8724. returnSuccessMsg("审核成功!");
  8725. return;
  8726. }
  8727. returnErrorMsg("找不到订单记录");
  8728. }
  8729. }
  8730. public void upd_all_erp_returncashverify()
  8731. {
  8732. if (UrlPostParmsCheck("ID"))
  8733. {
  8734. String[] list = GetPostString("ID").Split(',');
  8735. CeErpReturnCash entity = null;
  8736. for (int i = 0; i < list.Length; i++)
  8737. {
  8738. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8739. if (entity != null)
  8740. {
  8741. if (entity.cashstate == 1)
  8742. {
  8743. returnErrorMsg("已审核过的订单不需要在审核!");
  8744. return;
  8745. }
  8746. entity.cashstate = 1;
  8747. entity.verifytime = DateTime.Now;
  8748. entity.verifyuserid = CurrentUser.UserID;
  8749. entity.Update();
  8750. }
  8751. }
  8752. returnSuccessMsg("审核成功!");
  8753. return;
  8754. }
  8755. }
  8756. public void upd_erp_returncashback()
  8757. {
  8758. if (UrlPostParmsCheck("ID"))
  8759. {
  8760. int eid = GetPostInt("ID");
  8761. CeErpReturnCash entity = null;
  8762. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8763. if (entity != null)
  8764. {
  8765. entity.backreason = GetPostString("reason");
  8766. entity.cashstate = 2;
  8767. entity.verifytime = DateTime.Now;
  8768. entity.verifyuserid = CurrentUser.UserID;
  8769. entity.Update();
  8770. returnSuccessMsg("退回成功!");
  8771. return;
  8772. }
  8773. returnErrorMsg("找不到订单记录");
  8774. }
  8775. }
  8776. public void upd_erp_returnprice()
  8777. {
  8778. if (UrlPostParmsCheck("ID"))
  8779. {
  8780. int eid = GetPostInt("ID");
  8781. CeErpReturnCash entity = null;
  8782. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8783. if (entity != null)
  8784. {
  8785. if (entity.cashstate == 1)
  8786. {
  8787. returnErrorMsg("审核通过了不能改");
  8788. return;
  8789. }
  8790. entity.returnprice = GetPostDouble("returnprice");
  8791. entity.Update();
  8792. returnSuccessMsg("修改成功!");
  8793. return;
  8794. }
  8795. returnErrorMsg("找不到订单记录");
  8796. }
  8797. }
  8798. public void del_erp_returncash()
  8799. {
  8800. if (UrlPostParmsCheck("ID"))
  8801. {
  8802. int eid = GetPostInt("ID");
  8803. CeErpReturnCash.Del(eid);
  8804. returnSuccessMsg("操作成功");
  8805. return;
  8806. }
  8807. }
  8808. public void test_for_do_sql()
  8809. {
  8810. string sql = GetPostString("sqlstr");
  8811. if (sql.Length > 0)
  8812. {
  8813. try
  8814. {
  8815. DbHelper.DbConn.ExecuteNonQuery(sql);
  8816. var res_obj = new
  8817. {
  8818. data = "成功",
  8819. };
  8820. string ro_json = JsonConvert.SerializeObject(res_obj);
  8821. returnSuccess(ro_json);
  8822. }
  8823. catch (Exception ex)
  8824. {
  8825. var res_obj = new
  8826. {
  8827. data = ex.Message,
  8828. };
  8829. string ro_json = JsonConvert.SerializeObject(res_obj);
  8830. returnSuccess(ro_json);
  8831. }
  8832. }
  8833. }
  8834. public void get_user_info()
  8835. {
  8836. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8837. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8838. }
  8839. public void get_total_data()
  8840. {
  8841. int userId = CurrentUser.UserID;
  8842. string sql = "";
  8843. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8844. {
  8845. 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);
  8846. }
  8847. else
  8848. {
  8849. 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 " +
  8850. "(select ID from CE_ErpUser where ID = {0}) d " +
  8851. "left join " +
  8852. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8853. ") a on d.ID = a.id left join " +
  8854. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8855. ") b on a.id = b.id1 left join" +
  8856. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8857. ") c on a.id = c.id2;", userId);
  8858. }
  8859. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8860. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8861. }
  8862. public void get_date_area_total_data2()
  8863. {
  8864. int userId = CurrentUser.UserID;
  8865. string date_type = GetPostString("timetype");
  8866. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8867. string sql = "";
  8868. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8869. {
  8870. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8871. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8872. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8873. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8874. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8875. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8876. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8877. ") a on e.ID = a.id left join " +
  8878. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8879. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8880. ") b on a.id = b.id1 " +
  8881. "left join " +
  8882. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8883. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8884. ") c on a.id = c.id2 " +
  8885. "left join " +
  8886. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8887. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8888. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8889. }
  8890. else
  8891. {
  8892. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8893. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8894. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8895. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8896. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8897. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8898. ") a on e.ID = a.id left join " +
  8899. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8900. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8901. ") c on a.id = c.id2 " +
  8902. "left join " +
  8903. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8904. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8905. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8906. }
  8907. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8908. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8909. }
  8910. public void get_date_area_total_data()
  8911. {
  8912. int userId = CurrentUser.UserID;
  8913. string date_type = GetPostString("timetype");
  8914. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8915. string date1 = searchDT[0].ToString();
  8916. string date2 = searchDT[1].ToString();
  8917. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8918. {
  8919. SqlParameter[] sqlParameter ={
  8920. new SqlParameter("@userId", SqlDbType.Int,4),
  8921. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8922. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8923. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8924. };
  8925. sqlParameter[0].Value = userId;
  8926. sqlParameter[1].Value = date1;
  8927. sqlParameter[2].Value = date2;
  8928. sqlParameter[3].Direction = ParameterDirection.Output;
  8929. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8930. string res = sqlParameter[3].Value.ToString();
  8931. var res_obj = new
  8932. {
  8933. data = res
  8934. };
  8935. string ro_json = JsonConvert.SerializeObject(res_obj);
  8936. returnSuccess(ro_json);
  8937. }
  8938. else
  8939. {
  8940. SqlParameter[] sqlParameter ={
  8941. new SqlParameter("@userId", SqlDbType.Int,4),
  8942. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8943. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8944. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8945. };
  8946. sqlParameter[0].Value = userId;
  8947. sqlParameter[1].Value = date1;
  8948. sqlParameter[2].Value = date2;
  8949. sqlParameter[3].Direction = ParameterDirection.Output;
  8950. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8951. string res = sqlParameter[3].Value.ToString();
  8952. var res_obj = new
  8953. {
  8954. data = res
  8955. };
  8956. string ro_json = JsonConvert.SerializeObject(res_obj);
  8957. returnSuccess(ro_json);
  8958. }
  8959. //writeGridDataViewJson(dt.Rows.Count, dv);
  8960. }
  8961. public void get_order_list()
  8962. {
  8963. string strFields = GetPostString("paraFields");
  8964. string strOrder = GetPostString("paraOrder");
  8965. string strWhere = GetPostString("paraWhere");
  8966. string strPageSize = GetPostString("paraPageSize");
  8967. DataStruct dStruct = GetPostStruct();
  8968. dStruct.PageSize = int.Parse(strPageSize);
  8969. dStruct.Fileds = strFields;
  8970. dStruct.Order = strOrder;
  8971. dStruct.MainWhere = strWhere;
  8972. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8973. writeGridDataTableJson(dStruct.TotalCount, dt);
  8974. }
  8975. ////获取待开始订单列表
  8976. //public void get_wait_design_order_list()
  8977. //{
  8978. // string date_type = GetPostString("date_type");
  8979. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8980. // DataStruct dStruct = GetPostStruct();
  8981. // dStruct.PageSize = 1000;
  8982. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8983. // List<string> lw = new List<string>();
  8984. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8985. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8986. // dStruct.Order = "WaitDesignTime asc";
  8987. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8988. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8989. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8990. //}
  8991. //获取完成单量排名
  8992. public void get_finish_order_count_ranking()
  8993. {
  8994. /* string date_type = GetPostString("date_type");
  8995. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8996. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8997. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8998. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8999. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9000. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9001. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9002. writeGridDataTableJson(0, new DataTable());
  9003. }
  9004. public void get_finish_order_amount_ranking()
  9005. {
  9006. /*string date_type = GetPostString("date_type");
  9007. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9008. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9009. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9010. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9011. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9012. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9013. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9014. writeGridDataTableJson(0, new DataTable());
  9015. }
  9016. public void get_finish_refund_count_ranking()
  9017. {
  9018. string date_type = GetPostString("date_type");
  9019. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9020. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9021. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9022. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9023. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9024. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9025. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9026. writeGridDataTableJson(dt.Rows.Count, dt);
  9027. }
  9028. public void get_finish_refund_amount_ranking()
  9029. {
  9030. string date_type = GetPostString("date_type");
  9031. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9032. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9033. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9034. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9035. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9036. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9037. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9038. writeGridDataTableJson(dt.Rows.Count, dt);
  9039. }
  9040. public void set_erp_finishorder_director()
  9041. {
  9042. if (UrlPostParmsCheck("ctid"))
  9043. {
  9044. string eid = GetPostString("ctid");
  9045. CeErpTradeCell entity = null;
  9046. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9047. if (entity != null)
  9048. {
  9049. entity.OrderState = 8;
  9050. entity.Update();
  9051. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9052. returnSuccessMsg("操作成功!");
  9053. return;
  9054. }
  9055. returnErrorMsg("找不到记录");
  9056. }
  9057. }
  9058. public void get_erp_placeregistlist()
  9059. {
  9060. DataStruct dStruct = GetPostStruct();
  9061. List<string> lw = new List<string>();
  9062. string outsid = GetPostString("outsid");
  9063. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9064. string memo = GetPostString("memo");
  9065. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9066. string filename = GetPostString("filename");
  9067. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9068. string islate = GetPostString("islate");
  9069. if (islate.Length > 0)
  9070. {
  9071. if (islate == "1")
  9072. lw.Add(string.Format("OutLate>0"));
  9073. else
  9074. lw.Add(string.Format("OutLate=0"));
  9075. }
  9076. string placedate1 = GetPostString("placedate1");
  9077. string placedate2 = GetPostString("placedate2");
  9078. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9079. if (dw.Length > 0) lw.Add(dw);
  9080. string deliveryDate1 = GetPostString("deliverydate1");
  9081. string deliveryDate2 = GetPostString("deliverydate2");
  9082. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9083. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9084. dStruct.Order = "ID desc";
  9085. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9086. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9087. writeGridDataTableJson(dStruct.TotalCount, dt);
  9088. }
  9089. public void ins_erp_placeregist()
  9090. {
  9091. if (UrlPostParmsCheck("id"))
  9092. {
  9093. string eid = GetPostString("id");
  9094. CeErpPlaceRegister entity = null;
  9095. if (eid == "0")//新增
  9096. {
  9097. entity = new CeErpPlaceRegister();
  9098. string xdTime = GetPostString("placeTime");
  9099. if (xdTime.Length > 0)
  9100. {
  9101. entity.PlactTime = Convert.ToDateTime(xdTime);
  9102. }
  9103. string fhTime = GetPostString("deliveryTime");
  9104. if (fhTime.Length > 0)
  9105. {
  9106. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9107. }
  9108. string preTime = GetPostString("preOutTime");
  9109. if (preTime.Length > 0)
  9110. {
  9111. entity.PreOutTime = Convert.ToDateTime(preTime);
  9112. }
  9113. entity.DeliveryCount = GetPostInt("deliveryCount");
  9114. entity.ReceiveCount = GetPostInt("receiveCount");
  9115. entity.OutSid = GetPostString("outSid");
  9116. entity.FileName = GetPostString("fileName");
  9117. entity.Memo = GetPostString("memo");
  9118. entity.AddUserId = CurrentUser.UserID;
  9119. entity.CreateTime = DateTime.Now;
  9120. entity.Img = GetPostString("img");
  9121. entity.Supplier = GetPostInt("supplier");
  9122. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9123. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9124. {
  9125. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9126. DateTime dt2 = (DateTime)entity.PreOutTime;
  9127. TimeSpan span = dt1.Subtract(dt2);
  9128. if (span.Days > 0)
  9129. {
  9130. entity.OutLate = span.Days;
  9131. }
  9132. }
  9133. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9134. entity.Create();
  9135. returnSuccessMsg("添加成功!");
  9136. return;
  9137. }
  9138. else //修改
  9139. {
  9140. entity = CeErpPlaceRegister.Get(eid);
  9141. if (entity != null)
  9142. {
  9143. string xdTime = GetPostString("placeTime");
  9144. if (xdTime.Length > 0)
  9145. {
  9146. entity.PlactTime = Convert.ToDateTime(xdTime);
  9147. }
  9148. string fhTime = GetPostString("deliveryTime");
  9149. if (fhTime.Length > 0)
  9150. {
  9151. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9152. }
  9153. string preTime = GetPostString("preOutTime");
  9154. if (preTime.Length > 0)
  9155. {
  9156. entity.PreOutTime = Convert.ToDateTime(preTime);
  9157. }
  9158. entity.DeliveryCount = GetPostInt("deliveryCount");
  9159. entity.ReceiveCount = GetPostInt("receiveCount");
  9160. if (entity.DeliveryCount == entity.ReceiveCount)
  9161. {
  9162. entity.CurState = "已完成";
  9163. }
  9164. else
  9165. {
  9166. entity.CurState = "未完成";
  9167. }
  9168. entity.OutSid = GetPostString("outSid");
  9169. entity.FileName = GetPostString("fileName");
  9170. entity.Memo = GetPostString("memo");
  9171. entity.Img = GetPostString("img");
  9172. entity.Supplier = GetPostInt("supplier");
  9173. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9174. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9175. {
  9176. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9177. DateTime dt2 = (DateTime)entity.PreOutTime;
  9178. TimeSpan span = dt1.Subtract(dt2);
  9179. if (span.Days > 0)
  9180. {
  9181. entity.OutLate = span.Days;
  9182. }
  9183. }
  9184. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9185. entity.Update();
  9186. returnSuccessMsg("修改成功");
  9187. return;
  9188. }
  9189. returnErrorMsg("找不到对应的记录");
  9190. return;
  9191. }
  9192. }
  9193. returnErrorMsg("缺少必要参数");
  9194. }
  9195. public void del_erp_placeregist()
  9196. {
  9197. string eid = GetPostString("id");
  9198. CeErpPlaceRegister.Del(eid);
  9199. returnSuccessMsg("删除成功!");
  9200. return;
  9201. }
  9202. public void ins_erp_placeregistbyorder()
  9203. {
  9204. string ctid = GetPostString("ctid");
  9205. if (ctid.Length > 0)
  9206. {
  9207. StringBuilder sql = new StringBuilder();
  9208. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9209. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9210. if (dt.Rows.Count > 0)
  9211. {
  9212. foreach (DataRow dr in dt.Rows)
  9213. {
  9214. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9215. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9216. entity.AddUserId = CurrentUser.UserID;
  9217. entity.tid = dr["tid"].ToString();
  9218. entity.Did = Convert.ToString(dr["ctid"]);
  9219. entity.splitTag = dr["SplitTag"].ToString();
  9220. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9221. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9222. if (pre_ctid.Length > 0)
  9223. {
  9224. sellmemo = sellmemo.Replace(pre_ctid, "");
  9225. }
  9226. sellmemo = sellmemo.Replace("[", "");
  9227. sellmemo = sellmemo.Replace("]", "");
  9228. entity.FileName = sellmemo;
  9229. string count = dr["ProductCount"].ToString();
  9230. int usecount = commonHelper.getIntCountFromString(count);
  9231. entity.DeliveryCount = usecount;
  9232. entity.CurState = "未完成";
  9233. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9234. {
  9235. entity.Supplier = 24;//dl手提袋定制
  9236. }
  9237. else
  9238. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9239. entity.CreateTime = DateTime.Now;
  9240. entity.Create();
  9241. }
  9242. returnSuccessMsg("操作成功");
  9243. return;
  9244. }
  9245. returnErrorMsg("没有找到对应订单");
  9246. return;
  9247. }
  9248. returnErrorMsg("缺少订单编号");
  9249. return;
  9250. }
  9251. public void get_erp_persuadelist()
  9252. {
  9253. DataStruct dStruct = GetPostStruct();
  9254. List<string> lw = new List<string>();
  9255. string ctid = GetPostString("ctid");
  9256. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9257. string shopname = GetPostString("shopname");
  9258. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9259. string buyernick = GetPostString("buyer_nick");
  9260. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9261. string customer = GetPostString("customer");
  9262. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9263. string returndate1 = GetPostString("returndate1");
  9264. string returndate2 = GetPostString("returndate2");
  9265. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9266. if (dw.Length > 0) lw.Add(dw);
  9267. string finishDate1 = GetPostString("finishdate1");
  9268. string finishDate2 = GetPostString("finishdate2");
  9269. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9270. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9271. string persuadetype = GetPostString("persuadetype");
  9272. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9273. string returnvstate = GetPostString("returnvstate");
  9274. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9275. dStruct.Order = "created desc";
  9276. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9277. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9278. writeGridDataTableJson(dStruct.TotalCount, dt);
  9279. }
  9280. public void upd_erp_returnpersuadeback()
  9281. {
  9282. if (UrlPostParmsCheck("ID"))
  9283. {
  9284. int eid = GetPostInt("ID");
  9285. CeErpPersuade entity = null;
  9286. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9287. if (entity != null)
  9288. {
  9289. entity.backreason = GetPostString("reason");
  9290. entity.pstate = 2;
  9291. entity.verifytime = DateTime.Now;
  9292. entity.verifyuserid = CurrentUser.UserID;
  9293. entity.Update();
  9294. returnSuccessMsg("退回成功!");
  9295. return;
  9296. }
  9297. returnErrorMsg("找不到订单记录");
  9298. }
  9299. }
  9300. public void upd_erp_returnpersuadeverify()
  9301. {
  9302. if (UrlPostParmsCheck("ID"))
  9303. {
  9304. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9305. {
  9306. returnErrorMsg("暂无权限审核");
  9307. return;
  9308. }
  9309. int eid = GetPostInt("ID");
  9310. CeErpPersuade entity = null;
  9311. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9312. if (entity != null)
  9313. {
  9314. entity.pstate = 1;
  9315. entity.verifytime = DateTime.Now;
  9316. entity.verifyuserid = CurrentUser.UserID;
  9317. entity.Update();
  9318. returnSuccessMsg("审核成功!");
  9319. return;
  9320. }
  9321. returnErrorMsg("找不到订单记录");
  9322. }
  9323. }
  9324. public void del_erp_persuade()
  9325. {
  9326. if (UrlPostParmsCheck("ID"))
  9327. {
  9328. int eid = GetPostInt("ID");
  9329. CeErpPersuade.Del(eid);
  9330. returnSuccessMsg("操作成功");
  9331. return;
  9332. }
  9333. }
  9334. public void get_erp_oldcustoupload()
  9335. {
  9336. DataStruct dStruct = GetPostStruct();
  9337. List<string> lw = new List<string>();
  9338. string buyernick = GetPostString("buyer_nick");
  9339. if (buyernick.Length > 0)
  9340. {
  9341. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9342. }
  9343. else
  9344. return;
  9345. dStruct.Order = "pay_time desc";
  9346. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9347. DataTable dt = null;
  9348. dt = WebCache.GetData("view_erptradecell", dStruct);
  9349. writeGridDataTableJson(dStruct.TotalCount, dt);
  9350. }
  9351. public void get_erp_checkorderlist()
  9352. {
  9353. DataStruct dStruct = GetPostStruct();
  9354. List<string> lw = new List<string>();
  9355. string tid = GetPostString("ctid");
  9356. if (tid.Length > 0)
  9357. {
  9358. string select_tid = getTidByCtid(tid);
  9359. lw.Add(string.Format("tid='{0}'", select_tid));
  9360. }
  9361. string shopname = GetPostString("shopname");
  9362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9363. string buyernick = GetPostString("buyer_nick");
  9364. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9365. string customer = GetPostString("customer");
  9366. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9367. string design = GetPostString("design");
  9368. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9369. string orderState = GetPostString("orderState");
  9370. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9371. string address = GetPostString("address");
  9372. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9373. string sellermemo = GetPostString("seller_memo");
  9374. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9375. string supplier = GetPostString("supplier");
  9376. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9377. {
  9378. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9379. }
  9380. else
  9381. {
  9382. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9383. }
  9384. string date1 = GetPostString("date1");
  9385. string date2 = GetPostString("date2");
  9386. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9387. if (dw.Length > 0) lw.Add(dw);
  9388. string placedate1 = GetPostString("placedate1");
  9389. string placedate2 = GetPostString("placedate2");
  9390. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9391. if (fdw.Length > 0) lw.Add(fdw);
  9392. string price1 = GetPostString("price1");
  9393. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9394. string price2 = GetPostString("price2");
  9395. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9396. string checkst = GetPostString("checkstate");
  9397. if (checkst.Length > 0 && "10".Equals(checkst))
  9398. {
  9399. lw.Add(string.Format("CheckOut>0"));
  9400. }
  9401. else
  9402. {
  9403. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9404. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9405. }
  9406. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9407. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9408. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9409. writeGridDataTableJson(dStruct.TotalCount, dt);
  9410. }
  9411. public void ins_erp_startCheck()
  9412. {
  9413. if (UrlPostParmsCheck("ctid"))
  9414. {
  9415. string eid = GetPostString("ctid");
  9416. CeErpTradeCell entity = null;
  9417. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9418. if (entity != null)
  9419. {
  9420. entity.MemoOpt = 4;
  9421. entity.UpdateTime = DateTime.Now;
  9422. entity.Update();
  9423. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9424. CeErpSukuraData.createInfo(entity.ctid, 6);
  9425. returnSuccessMsg("操作成功!");
  9426. return;
  9427. }
  9428. returnErrorMsg("找不到记录");
  9429. }
  9430. }
  9431. public void upd_erp_sendXlw()
  9432. {
  9433. if (UrlPostParmsCheck("ctid"))
  9434. {
  9435. string eid = GetPostString("ctid");
  9436. CeErpTradeCell entity = null;
  9437. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9438. if (entity != null)
  9439. {
  9440. if (entity.IsSendGift == 1)
  9441. {
  9442. returnErrorMsg("请勿重复标记");
  9443. return;
  9444. }
  9445. entity.IsSendGift = 1;
  9446. entity.Update();
  9447. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9448. returnSuccessMsg("操作成功!");
  9449. return;
  9450. }
  9451. returnErrorMsg("找不到记录");
  9452. }
  9453. }
  9454. public void cancel_sendXlw()
  9455. {
  9456. if (UrlPostParmsCheck("ctid"))
  9457. {
  9458. string eid = GetPostString("ctid");
  9459. CeErpTradeCell entity = null;
  9460. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9461. if (entity != null)
  9462. {
  9463. if (entity.IsSendGift == 0)
  9464. {
  9465. returnErrorMsg("未标记小礼物");
  9466. return;
  9467. }
  9468. entity.IsSendGift = 0;
  9469. entity.Update();
  9470. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9471. returnSuccessMsg("操作成功!");
  9472. return;
  9473. }
  9474. returnErrorMsg("找不到记录");
  9475. }
  9476. }
  9477. public void get_erp_designbill()
  9478. {
  9479. DataStruct dStruct = GetPostStruct();
  9480. List<string> lw = new List<string>();
  9481. int isMy = GetInt("my");
  9482. if (isMy == 1)
  9483. {
  9484. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9485. }
  9486. string tid = GetPostString("tid");
  9487. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9488. string userName = GetPostString("design");
  9489. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9490. string price1 = GetPostString("price1");
  9491. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9492. string price2 = GetPostString("price2");
  9493. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9494. string rePrice1 = GetPostString("rePrice1");
  9495. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9496. string rePrice2 = GetPostString("rePrice2");
  9497. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9498. string designerType = GetPostString("designerType");
  9499. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9500. string orderState = GetPostString("orderState");
  9501. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9502. string endTime1 = GetPostString("endTime1");
  9503. string endTime2 = GetPostString("endTime2");
  9504. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9505. if (dw.Length > 0) lw.Add(dw);
  9506. string isDk = GetPostString("isDk");
  9507. if (isDk == "1")
  9508. {
  9509. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9510. }
  9511. else if (isDk == "0")
  9512. {
  9513. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9514. }
  9515. dStruct.Order = "oid, create_time desc";
  9516. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9517. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9518. writeGridDataTableJson(dStruct.TotalCount, dt);
  9519. }
  9520. public void upd_erp_designerbill()
  9521. {
  9522. if (UrlPostParmsCheck("ID"))
  9523. {
  9524. string eid = GetPostString("ID");
  9525. CeErpDesignerBill entity = null;
  9526. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9527. if (entity != null)
  9528. {
  9529. if (GetPostDouble("designerpirce") > 0)
  9530. {
  9531. entity.realPrice = GetPostDouble("designerpirce");
  9532. entity.update_time = DateTime.Now;
  9533. entity.update_u_id = CurrentUser.UserID;
  9534. entity.update_u_name = CurrentUser.UserName;
  9535. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9536. entity.Update();
  9537. returnSuccessMsg("操作成功!");
  9538. return;
  9539. }
  9540. else
  9541. {
  9542. entity.price = GetPostDouble("price");
  9543. entity.update_time = DateTime.Now;
  9544. entity.update_u_id = CurrentUser.UserID;
  9545. entity.update_u_name = CurrentUser.UserName;
  9546. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9547. entity.Update();
  9548. returnSuccessMsg("操作成功!");
  9549. return;
  9550. }
  9551. }
  9552. returnErrorMsg("找不到记录");
  9553. }
  9554. }
  9555. public void audit_erp_designerbill()
  9556. {
  9557. if (UrlPostParmsCheck("ID"))
  9558. {
  9559. string eid = GetPostString("ID");
  9560. CeErpDesignerBill entity = null;
  9561. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9562. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9563. if (entity != null)
  9564. {
  9565. entity.realPrice = GetPostDouble("designerpirce");
  9566. entity.update_time = DateTime.Now;
  9567. entity.update_u_id = CurrentUser.UserID;
  9568. entity.update_u_name = CurrentUser.UserName;
  9569. entity.isAudit = 1;
  9570. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9571. entity.Update();
  9572. if (orderEntity != null)
  9573. {
  9574. orderEntity.IsReadTag = 3;
  9575. orderEntity.Update();
  9576. }
  9577. returnSuccessMsg("操作成功!");
  9578. return;
  9579. }
  9580. returnErrorMsg("找不到记录");
  9581. }
  9582. }
  9583. public void all_audit_erp_designerbill()
  9584. {
  9585. if (UrlPostParmsCheck("idList"))
  9586. {
  9587. string[] list = GetPostString("idList").Split(',');
  9588. CeErpDesignerBill entity = null;
  9589. for (int i = 0; i < list.Length; i++)
  9590. {
  9591. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9592. if (entity == null) return;
  9593. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9594. if (orderEntity == null) return;
  9595. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9596. entity.update_time = DateTime.Now;
  9597. entity.update_u_id = CurrentUser.UserID;
  9598. entity.update_u_name = CurrentUser.UserName;
  9599. entity.isAudit = 1;
  9600. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9601. entity.Update();
  9602. orderEntity.IsReadTag = 3;
  9603. orderEntity.Update();
  9604. }
  9605. returnSuccessMsg("操作成功!");
  9606. return;
  9607. }
  9608. }
  9609. public void get_erp_sameorders()
  9610. {
  9611. if (UrlPostParmsCheck("ctid"))
  9612. {
  9613. string eid = GetPostString("ctid");
  9614. CeErpTradeCell entity = null;
  9615. entity = CeErpTradeCell.GetByCtid(eid);
  9616. if (entity != null)
  9617. {
  9618. StringBuilder sql = new StringBuilder();
  9619. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9620. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9621. var res = new
  9622. {
  9623. data = dt.Rows.Count
  9624. };
  9625. string ro_jsond = JsonConvert.SerializeObject(res);
  9626. returnSuccess(ro_jsond);
  9627. return;
  9628. }
  9629. returnErrorMsg("未找到订单");
  9630. return;
  9631. }
  9632. returnErrorMsg("缺少必要的参数");
  9633. }
  9634. public void get_erp_islasthavesameorder()
  9635. {
  9636. if (UrlPostParmsCheck("ctid"))
  9637. {
  9638. string eid = GetPostString("ctid");
  9639. string[] ctidList = eid.Split(',');
  9640. StringBuilder sql = new StringBuilder();
  9641. string tisCtid = "";
  9642. foreach (string ctid in ctidList)
  9643. {
  9644. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9645. if (entity != null)
  9646. {
  9647. sql = new StringBuilder();
  9648. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9649. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9650. if (dth.Rows.Count > 0)
  9651. {
  9652. tisCtid += entity.ctid;
  9653. tisCtid += ",";
  9654. }
  9655. }
  9656. }
  9657. if (tisCtid.Length > 0)
  9658. {
  9659. var res = new
  9660. {
  9661. data = tisCtid
  9662. };
  9663. string ro_jsond = JsonConvert.SerializeObject(res);
  9664. returnSuccess(ro_jsond);
  9665. }
  9666. else
  9667. {
  9668. var res = new
  9669. {
  9670. data = ""
  9671. };
  9672. string ro_jsond = JsonConvert.SerializeObject(res);
  9673. returnSuccess(ro_jsond);
  9674. }
  9675. return;
  9676. }
  9677. returnErrorMsg("缺少必要的参数");
  9678. }
  9679. public void file_client_down_url()
  9680. {
  9681. if (!UrlPostParmsCheck("userId"))
  9682. {
  9683. returnErrorMsg("缺少必要的参数");
  9684. }
  9685. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9686. }
  9687. public void checkout_form_data()
  9688. {
  9689. if (!UrlPostParmsCheck("tid"))
  9690. {
  9691. returnErrorMsg("缺少必要的参数");
  9692. }
  9693. string tid = GetPostString("tid");
  9694. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9695. if (ceErpOrderFormData != null)
  9696. {
  9697. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9698. returnSuccess(ro_jsond);
  9699. return;
  9700. }
  9701. returnErrorMsg("尚未有文件!");
  9702. }
  9703. public void back_supplier_audit()
  9704. {
  9705. int userId = CurrentUser.UserID;
  9706. StringBuilder sql = new StringBuilder();
  9707. 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);
  9708. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9709. if (dt.Rows.Count > 0)
  9710. {
  9711. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9712. }
  9713. else
  9714. {
  9715. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9716. }
  9717. }
  9718. public void back_supplier_query()
  9719. {
  9720. string eid = GetPostString("ctid");
  9721. if (eid != "")
  9722. {
  9723. StringBuilder sql = new StringBuilder();
  9724. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9725. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9726. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9727. }
  9728. else
  9729. {
  9730. returnErrorMsg("找不到订单记录");
  9731. return;
  9732. }
  9733. }
  9734. public void verified_to_order()
  9735. {
  9736. int userId = CurrentUser.UserID;
  9737. StringBuilder sql = new StringBuilder();
  9738. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9739. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9740. if (dt.Rows.Count > 0)
  9741. {
  9742. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9743. }
  9744. else
  9745. {
  9746. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9747. }
  9748. }
  9749. public void upd_supplier_audit()
  9750. {
  9751. if (UrlPostParmsCheck("ctid"))
  9752. {
  9753. string eid = GetPostString("ctid");
  9754. string reason = GetPostString("returnreason");
  9755. CeErpTradeCell entity = null;
  9756. CeWithdraw withdraw = null;
  9757. withdraw = CeWithdraw.GetByTid(eid);
  9758. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9759. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9760. {
  9761. if (withdraw != null)
  9762. {
  9763. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9764. {
  9765. returnSuccessMsg("您没有权限操作!");
  9766. return;
  9767. }
  9768. else
  9769. {
  9770. if (reason.Equals("1"))
  9771. {
  9772. if (entity.OrderState == -1)
  9773. {
  9774. if (entity.FinishPlaceTime == null)
  9775. {
  9776. entity.OrderState = 2;
  9777. }
  9778. else
  9779. {
  9780. entity.OrderState = 6;
  9781. }
  9782. }
  9783. entity.Update();
  9784. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9785. if (withdraw != null)
  9786. {
  9787. withdraw.status = int.Parse(reason);
  9788. withdraw.Update();
  9789. }
  9790. returnSuccessMsg("操作成功!");
  9791. return;
  9792. }
  9793. else
  9794. {
  9795. withdraw.status = int.Parse(reason);
  9796. withdraw.acknowledgingtime = DateTime.Now;
  9797. withdraw.Update();
  9798. returnSuccessMsg("查看详细请点击线下订单查询");
  9799. return;
  9800. }
  9801. }
  9802. }
  9803. // 第一个字符是 'N'
  9804. }
  9805. if (eid[0] != 'N')
  9806. {
  9807. }
  9808. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9809. {
  9810. entity.IsVerifyToSupplier = false;
  9811. entity.IsReturn = 1;
  9812. entity.ReturnTime = DateTime.Now;
  9813. entity.ReturnReason = reason;
  9814. if (entity.OrderState == 6)
  9815. {
  9816. entity.OrderState = 5;
  9817. }
  9818. entity.Update();
  9819. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9820. if (withdraw != null)
  9821. {
  9822. withdraw.status = int.Parse(reason);
  9823. withdraw.Update();
  9824. }
  9825. returnSuccessMsg("操作成功!");
  9826. return;
  9827. }
  9828. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9829. {
  9830. ;
  9831. if (withdraw != null)
  9832. {
  9833. withdraw.status = int.Parse(reason);
  9834. withdraw.acknowledgingtime = DateTime.Now;
  9835. withdraw.Update();
  9836. returnSuccessMsg("供应商取消撤回!");
  9837. return;
  9838. }
  9839. }
  9840. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9841. {
  9842. if (entity.OrderState == -1)
  9843. {
  9844. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9845. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  9846. {
  9847. returnErrorMsg("订单spu没有确认无法通过审核!");
  9848. return;
  9849. }
  9850. if (entity.FinishPlaceTime == null)
  9851. {
  9852. entity.OrderState = 2;
  9853. }
  9854. else
  9855. {
  9856. entity.OrderState = 3;
  9857. }
  9858. commonHelper.getCytPrice(entity);
  9859. }
  9860. entity.Update();
  9861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9862. if (withdraw != null)
  9863. {
  9864. withdraw.status = int.Parse(reason);
  9865. withdraw.Update();
  9866. }
  9867. returnSuccessMsg("操作成功!");
  9868. return;
  9869. }
  9870. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9871. {
  9872. if (withdraw == null)
  9873. {
  9874. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9875. return;
  9876. }
  9877. }
  9878. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9879. {
  9880. if (withdraw != null)
  9881. {
  9882. withdraw.status = int.Parse(reason);
  9883. withdraw.acknowledgingtime = DateTime.Now;
  9884. withdraw.Update();
  9885. returnSuccessMsg("查看详细请点击线下订单查询");
  9886. return;
  9887. }
  9888. }
  9889. return;
  9890. }
  9891. }
  9892. //校验报价
  9893. public void refund_order_tip()
  9894. {
  9895. int userid = CurrentUser.UserID;
  9896. int sectionId = CurrentUser.UserPost.OrgID;
  9897. StringBuilder sql = new StringBuilder();
  9898. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9899. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9900. List<string> ids = new List<string>();
  9901. if (dth.Rows.Count > 0)
  9902. {
  9903. foreach (DataRow dr in dth.Rows)
  9904. {
  9905. ids.Add(dr["ID"].ToString());
  9906. }
  9907. try
  9908. {
  9909. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9910. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9911. }
  9912. catch (Exception ex)
  9913. {
  9914. }
  9915. }
  9916. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9917. }
  9918. public void refund_order_Design()
  9919. {
  9920. int userid = CurrentUser.UserID;
  9921. int sectionId = CurrentUser.UserPost.OrgID;
  9922. StringBuilder sql = new StringBuilder();
  9923. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9924. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9925. List<string> ids = new List<string>();
  9926. if (dth.Rows.Count > 0)
  9927. {
  9928. foreach (DataRow dr in dth.Rows)
  9929. {
  9930. ids.Add(dr["ID"].ToString());
  9931. }
  9932. try
  9933. {
  9934. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9935. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9936. }
  9937. catch (Exception ex)
  9938. {
  9939. }
  9940. }
  9941. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9942. }
  9943. public void change_order_info()
  9944. {
  9945. int userid = CurrentUser.UserID;
  9946. StringBuilder sql = new StringBuilder();
  9947. 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);
  9948. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9949. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9950. }
  9951. public void change_win_mome()
  9952. {
  9953. if (UrlPostParmsCheck("id,ctid"))
  9954. {
  9955. string id = GetPostString("id");
  9956. string ctid = GetPostString("ctid");
  9957. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9958. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9959. if (ce == null || ceErpMessageTip == null)
  9960. {
  9961. returnSuccessMsg("未找到对应的订单!");
  9962. return;
  9963. }
  9964. if (ce.OrderState >= 5)
  9965. {
  9966. returnSuccessMsg("已上传文件无法修改!");
  9967. return;
  9968. }
  9969. int type = GetPostInt("type");
  9970. string content = GetPostString("content");
  9971. if (type == 0)
  9972. {
  9973. content = content.Replace("(", "(");
  9974. content = content.Replace(")", ")");
  9975. string check = MidStrEx(content, "(", ")").Trim();
  9976. if (string.IsNullOrEmpty(check))
  9977. {
  9978. returnSuccessMsg("文件名格式不正确");
  9979. return;
  9980. }
  9981. }
  9982. ce.DispatchSort = 0;
  9983. ce.seller_memo = content;
  9984. ce.Update();
  9985. ceErpMessageTip.isVisit = true;
  9986. ceErpMessageTip.Update();
  9987. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9988. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9989. ApiVo apiVo = new ApiVo();
  9990. apiVo.orderNumber = ce.ctid;
  9991. apiVo.actionName = "demandDesign";
  9992. apiVo.orderRemarks = content;
  9993. apiVo.demandExamine = type + 1;
  9994. designHelper.API_WorkCore(apiVo);//demandDesign
  9995. returnSuccessMsg("修改成功!");
  9996. }
  9997. }
  9998. public static string MidStrEx(string sourse, string startstr, string endstr)
  9999. {
  10000. string result = string.Empty;
  10001. int startindex, endindex;
  10002. try
  10003. {
  10004. startindex = sourse.IndexOf(startstr);
  10005. if (startindex == -1)
  10006. return result;
  10007. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10008. endindex = tmpstr.IndexOf(endstr);
  10009. if (endindex == -1)
  10010. return result;
  10011. result = tmpstr.Remove(endindex);
  10012. }
  10013. catch (Exception ex)
  10014. {
  10015. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10016. }
  10017. return result;
  10018. }
  10019. public void refund_order_list()
  10020. {
  10021. int userid = CurrentUser.UserID;
  10022. int sectionId = CurrentUser.UserPost.OrgID;
  10023. StringBuilder sql = new StringBuilder();
  10024. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10025. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10026. DataStruct dStruct = GetPostStruct();
  10027. DataTable dt = null;
  10028. List<string> ids = new List<string>();
  10029. List<string> tids = new List<string>();
  10030. if (dth.Rows.Count > 0)
  10031. {
  10032. foreach (DataRow dr in dth.Rows)
  10033. {
  10034. tids.Add("'" + dr["tid"].ToString() + "'");
  10035. ids.Add(dr["id"].ToString());
  10036. }
  10037. try
  10038. {
  10039. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10040. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10041. List<string> lw = new List<string>();
  10042. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10043. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10044. dt = WebCache.GetData("view_orderlist", dStruct);
  10045. }
  10046. catch (Exception ex)
  10047. {
  10048. }
  10049. }
  10050. writeGridDataTableJson(dStruct.TotalCount, dt);
  10051. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10052. }
  10053. //新增
  10054. public void order_batch_downloads()
  10055. {
  10056. string ceid = GetPostString("tid");
  10057. String[] tid = ceid.Split(',');
  10058. order_batch_caiyingtong(tid);
  10059. /* (string success, string errors) = UploadFiles(tid);
  10060. returnSuccessMsg(success + errors);*/
  10061. return;
  10062. }
  10063. //报价接口
  10064. public void Get_To_Quote()
  10065. {
  10066. string ceid = GetPostString("ctid");
  10067. if (ceid != null)
  10068. {
  10069. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10070. if (entity != null)
  10071. {
  10072. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10073. {
  10074. return;
  10075. }
  10076. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10077. double price = 0;
  10078. if (cp == null)
  10079. {
  10080. JObject jsonObject12 = new JObject
  10081. {
  10082. { "UserId", "77886" },
  10083. { "Pwd", "lt666888" },
  10084. { "Filename", entity.seller_memo }
  10085. };
  10086. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10087. JObject jsonObjects1 = JObject.Parse(response1);
  10088. string ms1g = (string)jsonObjects1["msg"];
  10089. if (ms1g == "报价成功")
  10090. {
  10091. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10092. string data = (string)jsonObject1["price"];
  10093. 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 + "');";
  10094. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10095. returnSuccessMsg("获取报价成功:" + data);
  10096. price = Convert.ToDouble(data);
  10097. }
  10098. else
  10099. {
  10100. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10101. return;
  10102. }
  10103. }
  10104. String[] beizhu = entity.seller_memo.Split('-');
  10105. String chanp = "";
  10106. if (beizhu.Length > 0)
  10107. {
  10108. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10109. }
  10110. else
  10111. {
  10112. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10113. }
  10114. JObject jsonObject = new JObject
  10115. {
  10116. { "UserId", "77886" },
  10117. { "Pwd", "lt666888" },
  10118. { "Filename", chanp }
  10119. };
  10120. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10121. JObject jsonObjects = JObject.Parse(response);
  10122. string msg = (string)jsonObjects["msg"];
  10123. if (msg == "报价成功")
  10124. {
  10125. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10126. string data = (string)jsonObject1["price"];
  10127. 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 + "');";
  10128. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10129. returnSuccessMsg("获取报价成功:" + data);
  10130. price = Convert.ToDouble(data);
  10131. }
  10132. else
  10133. {
  10134. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10135. return;
  10136. }
  10137. if (price > 0)
  10138. {
  10139. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10140. if (ceErpTradeCellExtend == null)
  10141. {
  10142. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10143. ceErpTradeCellExtend.ctid = entity.ctid;
  10144. ceErpTradeCellExtend.payment_cyt = price;
  10145. ceErpTradeCellExtend.Create();
  10146. }
  10147. else
  10148. {
  10149. ceErpTradeCellExtend.payment_cyt = price;
  10150. ceErpTradeCellExtend.Update();
  10151. }
  10152. }
  10153. return;
  10154. }
  10155. }
  10156. else
  10157. {
  10158. returnErrorMsg("请至少选择一条数据");
  10159. return;
  10160. }
  10161. }
  10162. //新增
  10163. public void order_To_Supplier()
  10164. {
  10165. string ceid = GetPostString("tid");
  10166. String[] tid = ceid.Split(',');
  10167. if (tid.Length > 0)
  10168. {
  10169. try
  10170. {
  10171. for (int i = 0; i < tid.Length; i++)
  10172. {
  10173. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10174. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10175. entity.SupplierId = suid;
  10176. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10177. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10178. entity.Update();
  10179. }
  10180. }
  10181. catch (Exception ex)
  10182. {
  10183. returnErrorMsg("自动匹配供应商失败");
  10184. return;
  10185. }
  10186. }
  10187. else
  10188. {
  10189. returnErrorMsg("请至少选择一条数据");
  10190. return;
  10191. }
  10192. returnSuccessMsg("自动匹配供应商成功");
  10193. return;
  10194. }
  10195. public (string, string) UploadFiles(string[] urls)
  10196. {
  10197. string success = "";
  10198. string errors = "";
  10199. int userid = CurrentUser.UserID;
  10200. foreach (string url in urls)
  10201. {
  10202. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10203. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10204. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10205. {
  10206. JObject jsonObject = new JObject
  10207. {
  10208. { "Userid", "77886" },
  10209. { "pwd", "cyt86435015" },
  10210. { "content", base64FileContent },
  10211. { "ext", Path.GetExtension(fileName) }
  10212. };
  10213. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10214. JObject jsonObjects = JObject.Parse(response);
  10215. string msg = (string)jsonObjects["msg"];
  10216. if (msg.Equals("上传成功"))
  10217. {
  10218. success += url + " 上传成功";
  10219. }
  10220. else
  10221. {
  10222. errors += url + " 上传失败";
  10223. }
  10224. }
  10225. else
  10226. {
  10227. errors += url + " 格式出现问题";
  10228. }
  10229. }
  10230. if (urls.Length == 0)
  10231. {
  10232. return (success, errors);
  10233. }
  10234. return (success, errors);
  10235. }
  10236. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10237. {
  10238. return true; //总是接受
  10239. }
  10240. public static string HttpPost(string url, string param = null)
  10241. {
  10242. HttpWebRequest request;
  10243. //如果是发送HTTPS请求
  10244. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10245. {
  10246. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10247. request = WebRequest.Create(url) as HttpWebRequest;
  10248. request.ProtocolVersion = HttpVersion.Version10;
  10249. }
  10250. else
  10251. {
  10252. request = WebRequest.Create(url) as HttpWebRequest;
  10253. }
  10254. request.Method = "POST";
  10255. request.ContentType = "application/json";
  10256. request.Accept = "*/*";
  10257. request.Timeout = 120000;
  10258. request.AllowAutoRedirect = false;
  10259. StreamWriter requestStream = null;
  10260. WebResponse response = null;
  10261. string responseStr = null;
  10262. try
  10263. {
  10264. requestStream = new StreamWriter(request.GetRequestStream());
  10265. requestStream.Write(param);
  10266. requestStream.Close();
  10267. response = request.GetResponse();
  10268. if (response != null)
  10269. {
  10270. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10271. responseStr = reader.ReadToEnd();
  10272. reader.Close();
  10273. }
  10274. }
  10275. catch (Exception ex)
  10276. {
  10277. return ex.Message;
  10278. }
  10279. finally
  10280. {
  10281. request = null;
  10282. requestStream = null;
  10283. response = null;
  10284. }
  10285. return responseStr;
  10286. }
  10287. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10288. {
  10289. string base64FileContent;
  10290. string fileName;
  10291. using (WebClient webClient = new WebClient())
  10292. {
  10293. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10294. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10295. {
  10296. using (Stream stream = response.GetResponseStream())
  10297. {
  10298. using (MemoryStream memoryStream = new MemoryStream())
  10299. {
  10300. stream.CopyTo(memoryStream);
  10301. byte[] fileBytes = memoryStream.ToArray();
  10302. base64FileContent = Convert.ToBase64String(fileBytes);
  10303. fileName = response.Headers["Content-Disposition"];
  10304. if (!string.IsNullOrEmpty(fileName))
  10305. {
  10306. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10307. if (index >= 0)
  10308. {
  10309. fileName = fileName.Substring(index + 9).Trim('\"');
  10310. }
  10311. }
  10312. else
  10313. {
  10314. fileName = Path.GetFileName(downloadUrl);
  10315. }
  10316. }
  10317. }
  10318. }
  10319. }
  10320. return (fileName, base64FileContent);
  10321. }
  10322. //新增
  10323. public void order_batch_caiyingtong(string[] downloadUrls)
  10324. {
  10325. try
  10326. {
  10327. //遍历文件
  10328. DataStruct dStruct = GetPostStruct();
  10329. DataTable dt = null;
  10330. int userid = CurrentUser.UserID;
  10331. List<string> ids = new List<string>();//失败组
  10332. List<string> tids = new List<string>();
  10333. using (WebClient webClient = new WebClient())
  10334. {
  10335. foreach (var url in downloadUrls)
  10336. {
  10337. try
  10338. {
  10339. tids.Add("'" + url + "'");
  10340. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10341. if (entity != null)
  10342. {
  10343. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10344. if (cp == null)
  10345. {
  10346. JObject jsonObject = new JObject
  10347. {
  10348. { "Userid", "77886" },
  10349. { "pwd", "lt666888" },
  10350. { "Filename",entity.seller_memo }
  10351. };
  10352. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10353. JObject jsonObjects = JObject.Parse(response);
  10354. string msg = (string)jsonObjects["msg"];
  10355. if (msg == "报价成功")
  10356. {
  10357. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10358. DownloadAndConvertToBase64(url1);
  10359. }
  10360. else
  10361. {
  10362. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10363. }
  10364. }
  10365. else
  10366. {
  10367. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10368. JObject jsonObject = new JObject
  10369. {
  10370. { "Userid", "77886" },
  10371. { "pwd", "lt666888" },
  10372. { "Filename",chanp }
  10373. };
  10374. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10375. JObject jsonObjects = JObject.Parse(response);
  10376. string msg = (string)jsonObjects["msg"];
  10377. if (msg == "报价成功")
  10378. {
  10379. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10380. DownloadAndConvertToBase64(url1);
  10381. }
  10382. else
  10383. {
  10384. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10385. }
  10386. }
  10387. }
  10388. // 上传文件到FTP
  10389. }
  10390. catch (Exception ex)
  10391. {
  10392. Console.WriteLine($"An error occurred: {ex.Message}");
  10393. }
  10394. }
  10395. List<string> lw = new List<string>();
  10396. lw.Add(string.Format("( OrderState < 6 )"));
  10397. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10398. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10399. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10400. if (dt.Rows.Count > 0)
  10401. {
  10402. foreach (DataRow dr in dt.Rows)
  10403. {
  10404. ids.Add(dr["ctid"].ToString());
  10405. }
  10406. }
  10407. String ErrorMsgs = "";
  10408. foreach (String id in ids)
  10409. {
  10410. ErrorMsgs += id + ",";
  10411. }
  10412. if (ErrorMsgs.Length > 1)
  10413. {
  10414. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10415. }
  10416. if (ErrorMsgs.Length < 1)
  10417. {
  10418. ErrorMsgs = "上传成功";
  10419. returnSuccessMsg(ErrorMsgs);
  10420. }
  10421. else
  10422. {
  10423. returnErrorMsg("以下订单" + ErrorMsgs);
  10424. }
  10425. }
  10426. // 删除文件夹及其内容
  10427. /* Directory.Delete(localDirectory, true);*/
  10428. }
  10429. catch { }
  10430. }
  10431. public void get_center_data()
  10432. {
  10433. int userId = CurrentUser.UserID;
  10434. string postCode = CurrentUser.UserPost.Post.Code;
  10435. List<string> lw = new List<string>();
  10436. List<string> ww = new List<string>();
  10437. DateTime currentTime = DateTime.Now;
  10438. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10439. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10440. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10441. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10442. string sql = " SELECT ";
  10443. string startTime = "2023-10-01 11:22:31";
  10444. //设计
  10445. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10446. {
  10447. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10448. 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));
  10449. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10450. 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));
  10451. }
  10452. //客服
  10453. else if (postCode == "CustomerService" || postCode == "Director")
  10454. {
  10455. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10456. 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));
  10457. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10458. 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));
  10459. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10460. 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));
  10461. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10462. 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));
  10463. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10464. 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));
  10465. }
  10466. //售后
  10467. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10468. {
  10469. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10470. 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));
  10471. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10472. 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));
  10473. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10474. 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));
  10475. }
  10476. //下单部
  10477. else if (postCode == "Place" || postCode == "PlaceMr")
  10478. {
  10479. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10480. 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));
  10481. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10482. 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));
  10483. }
  10484. //车间
  10485. else if (postCode == "Supplier")
  10486. {
  10487. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10488. 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));
  10489. }
  10490. DataTable dt = new DataTable();
  10491. if (lw.Count > 0)
  10492. {
  10493. sql += string.Join(" , ", lw);
  10494. sql += " FROM ";
  10495. sql += string.Join(" , ", ww);
  10496. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10497. }
  10498. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10499. }
  10500. public void get_center_data_list()
  10501. {
  10502. int userId = CurrentUser.UserID;
  10503. string postCode = CurrentUser.UserPost.Post.Code;
  10504. string shopIds = CurrentUser.User.pemShop;
  10505. DataStruct dStruct = GetPostStruct();
  10506. List<string> lw = new List<string>();
  10507. DateTime currentTime = DateTime.Now;
  10508. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10509. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10510. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10511. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10512. string startTime = "2023-10-01 11:22:31";
  10513. int order_type = GetPostInt("order_type");
  10514. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10515. {
  10516. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10517. if (order_type == 0)
  10518. {
  10519. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10520. }
  10521. else if (order_type == 3)
  10522. {
  10523. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10524. }
  10525. else
  10526. {
  10527. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10528. }
  10529. }
  10530. //客服
  10531. if (postCode == "CustomerService" || postCode == "Director")
  10532. {
  10533. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10534. if (order_type == 0)
  10535. {
  10536. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10537. }
  10538. else if (order_type == 1)
  10539. {
  10540. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10541. }
  10542. else if (order_type == 2)
  10543. {
  10544. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10545. }
  10546. else if (order_type == 3)
  10547. {
  10548. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10549. }
  10550. else if (order_type == 4)
  10551. {
  10552. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10553. }
  10554. else
  10555. {
  10556. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10557. }
  10558. }
  10559. //售后
  10560. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10561. {
  10562. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10563. if (shopIds != "")
  10564. {
  10565. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10566. }
  10567. if (order_type == 2)
  10568. {
  10569. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10570. }
  10571. else if (order_type == 4)
  10572. {
  10573. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10574. }
  10575. else if (order_type == 5)
  10576. {
  10577. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10578. }
  10579. else
  10580. {
  10581. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10582. }
  10583. }
  10584. //下单部
  10585. if (postCode == "Place" || postCode == "PlaceMr")
  10586. {
  10587. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10588. if (shopIds != "")
  10589. {
  10590. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10591. }
  10592. else if (order_type == 1)
  10593. {
  10594. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10595. }
  10596. else if (order_type == 2)
  10597. {
  10598. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10599. }
  10600. else
  10601. {
  10602. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10603. }
  10604. }
  10605. //车间
  10606. if (postCode == "Supplier")
  10607. {
  10608. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10609. if (order_type == 5)
  10610. {
  10611. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10612. }
  10613. else
  10614. {
  10615. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10616. }
  10617. }
  10618. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10619. dStruct.Fileds = "tid,ctid";
  10620. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10621. writeGridDataTableJson(dStruct.TotalCount, dt);
  10622. }
  10623. public void aftersale_audit_master()
  10624. {
  10625. if (UrlPostParmsCheck("ctid"))
  10626. {
  10627. string ctid = GetPostString("ctid");
  10628. if (ctid.Length > 0)
  10629. {
  10630. bool result = aftersale_data_change(ctid);
  10631. if (result)
  10632. {
  10633. returnSuccessMsg("修改成功!");
  10634. return;
  10635. }
  10636. }
  10637. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10638. }
  10639. }
  10640. public void aftersale_batch_audit_master()
  10641. {
  10642. if (UrlPostParmsCheck("ctids"))
  10643. {
  10644. string ctids = GetPostString("ctids");
  10645. if (ctids.Length > 0)
  10646. {
  10647. List<string> list = new List<string>();
  10648. string[] ctid_list = ctids.Split(',');
  10649. foreach (var item in ctid_list)
  10650. {
  10651. bool result = aftersale_data_change(item);
  10652. if (!result)
  10653. {
  10654. list.Add(item);
  10655. }
  10656. }
  10657. if (list.Count > 0)
  10658. {
  10659. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10660. return;
  10661. }
  10662. returnSuccessMsg("修改成功!");
  10663. return;
  10664. }
  10665. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10666. }
  10667. }
  10668. public bool aftersale_data_change(string ctid)
  10669. {
  10670. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10671. if (ceErpTradeCell != null)
  10672. {
  10673. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10674. ceErpTradeCell.AfterSaleSupplierState = 0;
  10675. StringBuilder sql = new StringBuilder();
  10676. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10677. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10678. CeErpTradeResponsible.DelByTid(ctid, 0);
  10679. 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 == "不理赔")
  10680. {
  10681. CeErpTradeResponsible.DelByTid(ctid, 1);
  10682. ceErpTradeCell.AfterSaleSupplierState = 1;
  10683. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10684. ceErpTradeCell.AfterSaleState = 4;
  10685. }
  10686. else
  10687. {
  10688. ceErpTradeCell.AfterSaleState = 3;
  10689. }
  10690. bool needCyt = false;
  10691. if (dt != null)
  10692. {
  10693. if (dt.Rows.Count == 1)
  10694. {
  10695. bool isEnd = false;
  10696. foreach (DataRow dr in dt.Rows)
  10697. {
  10698. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10699. {
  10700. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10701. isEnd = true;
  10702. }
  10703. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10704. {
  10705. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10706. isEnd = true;
  10707. }
  10708. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10709. {
  10710. needCyt = true;
  10711. }
  10712. }
  10713. if (isEnd)
  10714. {
  10715. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10716. ceErpTradeCell.AfterSaleState = 4;
  10717. ceErpTradeCell.AfterSaleSupplierState = 1;
  10718. }
  10719. }
  10720. else
  10721. {
  10722. bool isAll = true;
  10723. foreach (DataRow dr in dt.Rows)
  10724. {
  10725. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10726. {
  10727. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10728. continue;
  10729. }
  10730. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10731. {
  10732. string path = "";
  10733. int OrgID = 0;
  10734. if (!Convert.IsDBNull(dr["OrgPath"]))
  10735. {
  10736. path = dr["OrgPath"].ToString();
  10737. }
  10738. if (!Convert.IsDBNull(dr["OrgID"]))
  10739. {
  10740. OrgID = Convert.ToInt32(dr["OrgID"]);
  10741. }
  10742. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10743. {
  10744. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10745. continue;
  10746. }
  10747. }
  10748. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10749. {
  10750. needCyt = true;
  10751. }
  10752. isAll = false;
  10753. }
  10754. if (isAll)
  10755. {
  10756. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10757. ceErpTradeCell.AfterSaleState = 4;
  10758. ceErpTradeCell.AfterSaleSupplierState = 1;
  10759. }
  10760. }
  10761. }
  10762. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10763. {
  10764. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10765. }
  10766. if (ceErpTradeCell.AfterSaleState == 4)
  10767. {
  10768. ApiVo apiVo = new ApiVo();
  10769. apiVo.orderNumber = ceErpTradeCell.ctid;
  10770. apiVo.actionName = "afterOver";
  10771. designHelper.API_WorkCore(apiVo); //afterOver
  10772. }
  10773. ceErpTradeCell.Update();
  10774. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10775. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10776. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10777. return true;
  10778. }
  10779. return false;
  10780. }
  10781. public void get_erp_wechatorder()
  10782. {
  10783. DataStruct dStruct = GetPostStruct();
  10784. List<string> lw = new List<string>();
  10785. string tid = GetPostString("tid");
  10786. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10787. string shopname = GetPostString("shopname");
  10788. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10789. string buyernick = GetPostString("buyer_nick");
  10790. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10791. string customer = GetPostString("customer");
  10792. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10793. string returndate1 = GetPostString("returndate1");
  10794. string returndate2 = GetPostString("returndate2");
  10795. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10796. if (dw.Length > 0) lw.Add(dw);
  10797. string finishDate1 = GetPostString("finishdate1");
  10798. string finishDate2 = GetPostString("finishdate2");
  10799. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10800. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10801. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10802. dStruct.Order = "created desc";
  10803. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10804. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10805. writeGridDataTableJson(dStruct.TotalCount, dt);
  10806. }
  10807. public void get_erp_wechatlist_sumprice()
  10808. {
  10809. DataStruct dStruct = GetPostStruct();
  10810. List<string> lw = new List<string>();
  10811. string tid = GetPostString("tid");
  10812. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10813. string shopname = GetPostString("shopname");
  10814. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10815. string buyernick = GetPostString("buyer_nick");
  10816. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10817. string customer = GetPostString("customer");
  10818. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10819. string returndate1 = GetPostString("returndate1");
  10820. string returndate2 = GetPostString("returndate2");
  10821. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10822. if (dw.Length > 0) lw.Add(dw);
  10823. string finishDate1 = GetPostString("finishdate1");
  10824. string finishDate2 = GetPostString("finishdate2");
  10825. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10826. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10827. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10828. string mainWhere = string.Join(" and ", lw.ToArray());
  10829. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10830. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10831. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10832. decimal total = 0;
  10833. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10834. {
  10835. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10836. }
  10837. var res = new
  10838. {
  10839. data = total
  10840. };
  10841. string ro_jsond = JsonConvert.SerializeObject(res);
  10842. returnSuccess(ro_jsond);
  10843. return;
  10844. }
  10845. public void get_erp_qr_waitdeliverylist()
  10846. {
  10847. DataStruct dStruct = GetPostStruct();
  10848. List<string> lw = new List<string>();
  10849. string tid = GetPostString("ctid");
  10850. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10851. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10852. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10853. var res_objz = new
  10854. {
  10855. restype = 1,
  10856. data = dt
  10857. };
  10858. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10859. returnSuccess(ro_jsonz);
  10860. }
  10861. public void get_erp_yield_list()
  10862. {
  10863. DataStruct dStruct = GetPostStruct();
  10864. List<string> lw = new List<string>();
  10865. string tid = GetPostString("ctid");
  10866. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10867. string shopname = GetPostString("shopname");
  10868. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10869. string buyernick = GetPostString("buyer_nick");
  10870. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10871. //if (tid.Length == 0 && buyernick.Length == 0)
  10872. //{
  10873. // lw.Add(string.Format("IsRefund<={0}", 1));
  10874. //}
  10875. string customer = GetPostString("customer");
  10876. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10877. string design = GetPostString("design");
  10878. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10879. string orderState = GetPostString("orderState");
  10880. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10881. string address = GetPostString("address");
  10882. 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));
  10883. string sellermemo = GetPostString("seller_memo");
  10884. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10885. string supplier = GetPostString("supplier");
  10886. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10887. string OrderArea = GetPostString("order_area");
  10888. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10889. string placedate1 = GetPostString("placedate1");
  10890. string placedate2 = GetPostString("placedate2");
  10891. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10892. if (fdw.Length > 0) lw.Add(fdw);
  10893. string price1 = GetPostString("price1");
  10894. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10895. string price2 = GetPostString("price2");
  10896. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10897. string unusualCon = GetPostString("unusualcon");
  10898. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10899. string posTag = CurrentUser.UserPost.Post.Code;
  10900. if (posTag == "Supplier")
  10901. {
  10902. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10903. }
  10904. lw.Add(string.Format("OrderState = 6 "));
  10905. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10906. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10907. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10908. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10909. writeGridDataTableJson(dStruct.TotalCount, dt);
  10910. }
  10911. public void change_erp_sup_state()
  10912. {
  10913. if (UrlPostParmsCheck("ctid"))
  10914. {
  10915. string ctid = GetPostString("ctid");
  10916. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10917. if (ceErpTradeCell != null)
  10918. {
  10919. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10920. if (ceErpTradeCellExtend == null)
  10921. {
  10922. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10923. ceErpTradeCellExtend.ctid = ctid;
  10924. ceErpTradeCellExtend.SupState = 1;
  10925. ceErpTradeCellExtend.Create();
  10926. }
  10927. else
  10928. {
  10929. ceErpTradeCellExtend.SupState = 1;
  10930. ceErpTradeCellExtend.Update();
  10931. }
  10932. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10933. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10934. return;
  10935. }
  10936. returnErrorMsg("找不到订单");
  10937. }
  10938. }
  10939. public void supplier_all_downs()
  10940. {
  10941. if (UrlPostParmsCheck("tids"))
  10942. {
  10943. string tids = GetPostString("tids");
  10944. if (tids != null && tids.Length > 0)
  10945. {
  10946. StringBuilder sql = new StringBuilder();
  10947. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10948. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10949. sql = new StringBuilder();
  10950. 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, "下载设计文件");
  10951. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10952. string[] list = tids.Split(',');
  10953. foreach (string ctid in list)
  10954. {
  10955. CeErpSukuraData.createInfo(ctid, 3);
  10956. }
  10957. designHelper.api_approveDesign(tids); //approveDesign
  10958. returnSuccessMsg("下载成功!");
  10959. return;
  10960. }
  10961. returnErrorMsg("下载订单更新失败");
  10962. }
  10963. }
  10964. public void uploaderFileSuccess()
  10965. {
  10966. if (UrlPostParmsCheck("fileName"))
  10967. {
  10968. string fileName = GetPostString("fileName");
  10969. ApiVo apiVo = new ApiVo();
  10970. apiVo.orderNumber = fileName;
  10971. apiVo.actionName = "finishDesign";
  10972. designHelper.API_WorkCore(apiVo);//finishDesign
  10973. returnSuccessMsg("");
  10974. }
  10975. }
  10976. public void get_sample2_order()
  10977. {
  10978. if (UrlPostParmsCheck("ctid"))
  10979. {
  10980. string ctid = GetPostString("ctid");
  10981. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10982. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10983. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10984. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10985. double total = 0.0;
  10986. double order_price = 0.0;
  10987. if (dt_bu.Rows.Count > 0)
  10988. {
  10989. foreach (DataRow dr in dt_bu.Rows)
  10990. {
  10991. total += Convert.ToDouble(dr["payment"]);
  10992. }
  10993. }
  10994. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10995. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10996. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10997. string tid = ctid.Replace("S_", "");
  10998. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10999. double paymant = 0.0;
  11000. if (entity != null)
  11001. {
  11002. paymant = entity.payment;
  11003. }
  11004. string return_reason = "";
  11005. if (dt_after != null && dt_after.Rows.Count > 0)
  11006. {
  11007. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11008. }
  11009. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11010. }
  11011. }
  11012. public void get_erp_design_status()
  11013. {
  11014. string designName = GetPostString("designName");
  11015. DataStruct dStruct = GetPostStruct();
  11016. if (designName.Length > 0)
  11017. {
  11018. 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";
  11019. sql_user += " and Name like '%" + designName + "%'";
  11020. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11021. List<string> ids_list = new List<string>();
  11022. if (user_table.Rows.Count > 0)
  11023. {
  11024. foreach (DataRow item in user_table.Rows)
  11025. {
  11026. ids_list.Add(item["id"].ToString());
  11027. string ids_s = item["TeamIds"].ToString();
  11028. if (ids_s.Length > 0)
  11029. {
  11030. ids_list.AddRange(ids_s.Split(','));
  11031. }
  11032. }
  11033. }
  11034. HashSet<string> set = new HashSet<string>(ids_list);
  11035. ids_list = set.ToList();
  11036. if (ids_list.Count > 0)
  11037. {
  11038. 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));
  11039. dStruct.MainWhere = sql;
  11040. DataTable dt = null;
  11041. dt = WebCache.GetData("view_ErpUser", dStruct);
  11042. writeGridDataTableJson(dStruct.TotalCount, dt);
  11043. }
  11044. }
  11045. }
  11046. public void change_erp_order_price()
  11047. {
  11048. string ctid = GetPostString("ctid");
  11049. double price = GetPostDouble("price");
  11050. if (ctid.Length > 0)
  11051. {
  11052. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11053. if (ceErpTradeCellExtend == null)
  11054. {
  11055. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11056. ceErpTradeCellExtend.ctid = ctid;
  11057. ceErpTradeCellExtend.payment_cyt = price;
  11058. ceErpTradeCellExtend.Create();
  11059. }
  11060. else
  11061. {
  11062. ceErpTradeCellExtend.payment_cyt = price;
  11063. ceErpTradeCellExtend.Update();
  11064. }
  11065. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11066. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11067. {
  11068. ceErpDataSendOrderInfo.isSync = false;
  11069. ceErpDataSendOrderInfo.Update();
  11070. }
  11071. if (ceErpDataSendOrderInfo == null)
  11072. {
  11073. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11074. ceErpDataSendOrderInfo.isSync = false;
  11075. ceErpDataSendOrderInfo.ctid = ctid;
  11076. ceErpDataSendOrderInfo.Create();
  11077. }
  11078. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11079. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11080. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11081. if (dth != null && dth.Rows.Count > 0)
  11082. {
  11083. dataSendOrderBean dataSendOrderBean = null;
  11084. foreach (DataRow item in dth.Rows)
  11085. {
  11086. try
  11087. {
  11088. dataSendOrderBean = new dataSendOrderBean();
  11089. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11090. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11091. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11092. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11093. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11094. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11095. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11096. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11097. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11098. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11099. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11100. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11101. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11102. if (result != null)
  11103. {
  11104. if ("0".Equals(result.errcode))
  11105. {
  11106. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11107. }
  11108. else
  11109. {
  11110. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11111. }
  11112. }
  11113. }
  11114. catch (Exception ex)
  11115. {
  11116. }
  11117. }
  11118. }
  11119. returnSuccessMsg("修改成功!");
  11120. return;
  11121. }
  11122. returnErrorMsg("找不到订单");
  11123. }
  11124. public void find_he_together()
  11125. {
  11126. string ctid = GetPostString("ctid");
  11127. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11128. List<string> list = new List<string>();
  11129. if (ceErpTradeCell != null)
  11130. {
  11131. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11132. {
  11133. 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);
  11134. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11135. if (table != null && table.Rows.Count > 0)
  11136. {
  11137. foreach (TableRow row in table.Rows)
  11138. {
  11139. }
  11140. }
  11141. }
  11142. }
  11143. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11144. }
  11145. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11146. {
  11147. //chy----19
  11148. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11149. //GD-CYT-----64
  11150. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11151. //ZHX----3
  11152. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11153. //JK----97
  11154. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11155. //ZT----70
  11156. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11157. //LHCY-----98
  11158. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11159. //XD-----90
  11160. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11161. //CYCY-----14
  11162. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  11163. };
  11164. //其他改名
  11165. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11166. {
  11167. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11168. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11169. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11170. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11171. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11172. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11173. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11174. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11175. };
  11176. //不统计
  11177. List<int> no_suppliers = new List<int>()
  11178. {
  11179. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11180. };
  11181. //配件单
  11182. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11183. {
  11184. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11185. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11186. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11187. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11188. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11189. {"旗杆",new List<string>(){ "班旗" } },
  11190. {"牙签",new List<string>(){ "不干胶" } }
  11191. };
  11192. public void get_place_order_data()
  11193. {
  11194. string date1 = GetPostString("date1");
  11195. string date2 = GetPostString("date2");
  11196. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11197. DateTime start = DateTime.Parse(starttime);
  11198. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11199. DateTime end = DateTime.Parse(endtime);
  11200. if (date1 != null && date1.Length > 0)
  11201. {
  11202. DateTime dateTime = DateTime.Parse(date1);
  11203. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11204. start = DateTime.Parse(starttime);
  11205. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11206. end = DateTime.Parse(endtime);
  11207. }
  11208. if (date2 != null && date2.Length > 0)
  11209. {
  11210. DateTime dateTime = DateTime.Parse(date2);
  11211. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11212. end = DateTime.Parse(endtime);
  11213. }
  11214. 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);
  11215. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11216. //不干胶-----1,卡片-----29
  11217. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11218. foreach (DataRow row in data.Rows)
  11219. {
  11220. int productId = Convert.ToInt32(row["ProductId"]);
  11221. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11222. if (no_suppliers.Contains(supplierId))
  11223. {
  11224. continue;
  11225. }
  11226. string seller_memo = row["seller_memo"].ToString();
  11227. bool ispj = false;//是否配件单
  11228. bool isfirst = true;//第一个配
  11229. maps.Keys.ForEach(key =>
  11230. {
  11231. //备注包含配件
  11232. if (seller_memo.Contains(key) && isfirst)
  11233. {
  11234. List<string> list = maps[key];
  11235. ispj = true;
  11236. isfirst = false;
  11237. for (int i = 0; i < list.Count; i++)
  11238. {
  11239. if (seller_memo.Contains(list[i]))
  11240. {
  11241. ispj = false;
  11242. break;
  11243. }
  11244. }
  11245. }
  11246. });
  11247. if (ispj)
  11248. {
  11249. continue;
  11250. }
  11251. seller_memo = seller_memo.Replace("UV", "uv");
  11252. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11253. //吊牌归到卡片
  11254. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11255. seller_memo = seller_memo.Replace("卡套", "卡片");
  11256. seller_memo = seller_memo.Replace("封套", "卡片");
  11257. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11258. seller_memo = seller_memo.Replace("腰封", "卡片");
  11259. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11260. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11261. seller_memo = seller_memo.Replace("横幅", "条幅");
  11262. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11263. string map_key = "";
  11264. string type = "";
  11265. if (supplierMap.ContainsKey(supplierId))
  11266. {
  11267. foreach (var kvp in supplierMap[supplierId])
  11268. {
  11269. if (seller_memo.Contains(kvp.Key))
  11270. {
  11271. map_key = kvp.Value;
  11272. type = kvp.Value;
  11273. break;
  11274. }
  11275. }
  11276. }
  11277. if (map_key == "")
  11278. {
  11279. type = "其他";
  11280. map_key = "其他";
  11281. }
  11282. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11283. {
  11284. map_key = suppliers[supplierId];
  11285. }
  11286. if (supplierId == 70)
  11287. {
  11288. supplierId = 70;
  11289. }
  11290. map_key += "_" + row["SupplierName"].ToString();
  11291. Dictionary<string, int> map = null;
  11292. if (other_map.ContainsKey(map_key))
  11293. {
  11294. other_map.TryGetValue(map_key, out map);
  11295. }
  11296. else
  11297. {
  11298. map = new Dictionary<string, int>();
  11299. map.Add("dayDev", 0);//当天出货
  11300. map.Add("dayTotal", 0);//下单总数
  11301. map.Add("payTotal", 0);//500以上
  11302. map.Add("today", 0);//当天出货数量
  11303. map.Add("unusua", 0);//异常数
  11304. other_map.Add(map_key, map);
  11305. other_map.TryGetValue(map_key, out map);
  11306. }
  11307. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11308. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11309. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11310. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11311. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11312. {
  11313. map["dayTotal"]++;
  11314. if (supplierId == 97)
  11315. {
  11316. supplierId = 97;
  11317. }
  11318. }
  11319. if (Convert.ToDecimal(row["payment"]) >= 500)
  11320. {
  11321. map["payTotal"]++;
  11322. }
  11323. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11324. {
  11325. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11326. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11327. {
  11328. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11329. {
  11330. map["today"]++;
  11331. }
  11332. }
  11333. else
  11334. {
  11335. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11336. {
  11337. map["today"]++;
  11338. }
  11339. else
  11340. {
  11341. if (supplierId == 119)
  11342. {
  11343. Debug.WriteLine(row["seller_memo"].ToString());
  11344. }
  11345. }
  11346. }
  11347. }
  11348. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11349. {
  11350. map["unusua"]++;
  11351. }
  11352. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11353. //GD-CYT-----64
  11354. DateTime two = palceTimeStart.AddHours(14);
  11355. DateTime three = palceTimeStart.AddHours(15);
  11356. DateTime four = palceTimeStart.AddHours(16);
  11357. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11358. {
  11359. //下午四点前 500-1000
  11360. string count = row["ProductCount"].ToString();
  11361. if (count != null && count.Length > 0)
  11362. {
  11363. int productCount = commonHelper.getPlaceProductCount(count);
  11364. if (productCount >= 500 && productCount <= 1000)
  11365. {
  11366. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11367. {
  11368. map["dayDev"]++;
  11369. }
  11370. }
  11371. }
  11372. }
  11373. //UV
  11374. else if ("uv".Equals(type))
  11375. {
  11376. //ZT----70
  11377. //ZHX----3
  11378. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11379. {
  11380. map["dayDev"]++;
  11381. }
  11382. //JK----97
  11383. //HZX----105
  11384. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11385. {
  11386. map["dayDev"]++;
  11387. if (supplierId == 97)
  11388. {
  11389. supplierId = 97;
  11390. }
  11391. }
  11392. }
  11393. //帆布---52|条幅---27
  11394. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11395. {
  11396. //LHCY-----98
  11397. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11398. {
  11399. map["dayDev"]++;
  11400. }
  11401. }
  11402. //条幅
  11403. else if ("条幅".Equals(type))
  11404. {
  11405. //XD-----90
  11406. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11407. {
  11408. map["dayDev"]++;
  11409. }
  11410. }
  11411. //桌布
  11412. else if ("桌布".Equals(type))
  11413. {
  11414. //XD-----90
  11415. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11416. {
  11417. map["dayDev"]++;
  11418. }
  11419. }
  11420. //DL---10
  11421. //AYTW---119
  11422. //FS-CYT-DY ----80
  11423. //JK----97
  11424. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11425. {
  11426. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11427. {
  11428. map["dayDev"]++;
  11429. }
  11430. }
  11431. }
  11432. DataTable dt = new DataTable();
  11433. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11434. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11435. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11436. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11437. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11438. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11439. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11440. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11441. other_map.Keys.ForEach(key =>
  11442. {
  11443. DataRow dr = dt.NewRow();
  11444. Dictionary<string, int> map = other_map[key];
  11445. string[] key_list = key.Split('_');
  11446. dr[0] = key_list[0];
  11447. dr[1] = key_list[1];
  11448. if (key_list.Length > 2)
  11449. {
  11450. dr[1] += "(" + key_list[2] + ")";
  11451. }
  11452. dr[2] = map["dayTotal"];
  11453. dr[3] = map["payTotal"];
  11454. dr[4] = map["today"];
  11455. dr[5] = map["unusua"];
  11456. dr[6] = map["dayDev"];
  11457. double rate = 0.00;
  11458. if (map["dayDev"] > 0)
  11459. {
  11460. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11461. }
  11462. dr[7] = rate.ToString();
  11463. dt.Rows.Add(dr);
  11464. });
  11465. DataView dv = new DataView(dt);
  11466. dv.Sort = "SupplierName";
  11467. //dv.Sort = "AllOrder desc";
  11468. DataTable dtNew = dv.ToTable();
  11469. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11470. }
  11471. public void check_order_desing_info()
  11472. {
  11473. string ctid = GetPostString("ctid");
  11474. if (!string.IsNullOrEmpty(ctid))
  11475. {
  11476. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11477. if (ceErpTradeCell != null)
  11478. {
  11479. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11480. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11481. return;
  11482. }
  11483. returnErrorMsg("找不到订单");
  11484. return;
  11485. }
  11486. returnErrorMsg("找不到订单");
  11487. }
  11488. public void get_timeout_detail()
  11489. {
  11490. string poscode = CurrentUser.UserPost.Post.Code;
  11491. DataStruct dStruct = GetPostStruct();
  11492. List<string> lw = new List<string>();
  11493. string id = GetPostString("id");
  11494. string pay_date1 = GetPostString("pay_date1");
  11495. string pay_date2 = GetPostString("pay_date2");
  11496. int type = GetPostInt("type");
  11497. if (type == 0)
  11498. {
  11499. if (pay_date1.Length > 0)
  11500. {
  11501. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11502. }
  11503. if (pay_date2.Length > 0)
  11504. {
  11505. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11506. }
  11507. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11508. }
  11509. if (type == 1)
  11510. {
  11511. if (pay_date1.Length > 0)
  11512. {
  11513. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11514. }
  11515. if (pay_date2.Length > 0)
  11516. {
  11517. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11518. }
  11519. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11520. }
  11521. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11522. DataTable dt = null;
  11523. dt = WebCache.GetData("view_orderlist", dStruct);
  11524. writeGridDataTableJson(dStruct.TotalCount, dt);
  11525. }
  11526. public void saveUrgentChargePrice()
  11527. {
  11528. string ctid = GetPostString("ctid");
  11529. if (!string.IsNullOrEmpty(ctid))
  11530. {
  11531. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11532. if (ceErpTradeCell != null)
  11533. {
  11534. double price = GetPostDouble("price");
  11535. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11536. if (ceErpTradeCellExtend == null)
  11537. {
  11538. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11539. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11540. }
  11541. ceErpTradeCellExtend.urgentCharge = price;
  11542. if (ceErpTradeCellExtend.ID > 0)
  11543. {
  11544. ceErpTradeCellExtend.Update();
  11545. }
  11546. else
  11547. {
  11548. ceErpTradeCellExtend.Save();
  11549. }
  11550. returnSuccessMsg("修改成功!");
  11551. return;
  11552. }
  11553. returnErrorMsg("找不到订单");
  11554. return;
  11555. }
  11556. returnErrorMsg("找不到订单");
  11557. }
  11558. public void finish_erp_order()
  11559. {
  11560. string ctid = GetPostString("ctid");
  11561. if (!string.IsNullOrEmpty(ctid))
  11562. {
  11563. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11564. {
  11565. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11566. if (ceErpTradeCell != null)
  11567. {
  11568. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11569. ceErpTradeCell.Update();
  11570. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11571. returnSuccessMsg("修改成功!");
  11572. return;
  11573. }
  11574. }
  11575. }
  11576. returnErrorMsg("找不到订单");
  11577. }
  11578. public void get_trade_order_list()
  11579. {
  11580. string tid = GetPostString("tid");
  11581. if (!string.IsNullOrEmpty(tid))
  11582. {
  11583. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11584. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11585. writeGridDataTableJson(data.Rows.Count, data);
  11586. return;
  11587. }
  11588. returnErrorMsg("找不到订单");
  11589. }
  11590. public void save_cell_spu()
  11591. {
  11592. string ctid = GetPostString("ctid");
  11593. string spu_id = GetPostString("spu_id");
  11594. if (!string.IsNullOrEmpty(ctid))
  11595. {
  11596. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11597. if (ceErpTradeCellExtend == null)
  11598. {
  11599. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11600. ceErpTradeCellExtend.ctid = ctid;
  11601. }
  11602. ceErpTradeCellExtend.spu_id = spu_id;
  11603. if (!string.IsNullOrEmpty(spu_id))
  11604. {
  11605. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11606. string result = designHelper.API_CheckOrderTo(ceErpTradeCellExtend.ctid, ceErpTradeCellExtend.spu_id, ceErpTradeCell.ShopId);
  11607. ceErpTradeCellExtend.ToType = result;
  11608. List<int> products = new List<int>() { 4, 13, 19, 24, 32, 57, 1971, 2319, 2377, 2521, 2533, 2554, 2556, 2557, 2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2571, 2572, 2619, 2634, 2636, 2637, 2638, 2645, 2646 };
  11609. if (products.Contains(ceErpTradeCell.ProductId) || ceErpTradeCell.seller_memo.IndexOf("手绘") > -1 || ceErpTradeCell.seller_memo.IndexOf("电子稿") > -1 || ceErpTradeCell.isDianziOrder > 0)
  11610. {
  11611. ceErpTradeCellExtend.ToType = "外协";
  11612. }
  11613. if ("外协".Equals(ceErpTradeCellExtend.ToType))
  11614. {
  11615. string sql_pay = "update CE_ErpTradeCell with(rowlock) set DispatchSort=2 where ctid='" + ctid + "';";
  11616. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  11617. }
  11618. }
  11619. if (ceErpTradeCellExtend.ID == 0)
  11620. {
  11621. ceErpTradeCellExtend.Create();
  11622. }
  11623. else
  11624. {
  11625. ceErpTradeCellExtend.Update();
  11626. }
  11627. returnSuccessMsg("修改成功!");
  11628. return;
  11629. }
  11630. returnErrorMsg("找不到订单");
  11631. }
  11632. public void change_express_info()
  11633. {
  11634. string ctid = GetPostString("ctid");
  11635. string transNo = GetPostString("transNo");
  11636. string transCom = GetPostString("transCom");
  11637. if (!string.IsNullOrEmpty(ctid))
  11638. {
  11639. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11640. if (ceErpTradeCellExtend == null)
  11641. {
  11642. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11643. ceErpTradeCellExtend.ctid = ctid;
  11644. }
  11645. ceErpTradeCellExtend.modExpressNo = transNo;
  11646. ceErpTradeCellExtend.modExpressCom = transCom;
  11647. ceErpTradeCellExtend.readMod = 2;
  11648. if (ceErpTradeCellExtend.ID == 0)
  11649. {
  11650. ceErpTradeCellExtend.Create();
  11651. }
  11652. else
  11653. {
  11654. ceErpTradeCellExtend.Update();
  11655. }
  11656. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11657. returnSuccessMsg("修改成功!");
  11658. return;
  11659. }
  11660. returnErrorMsg("找不到订单");
  11661. }
  11662. public void get_change_express_list()
  11663. {
  11664. DataStruct dStruct = GetPostStruct();
  11665. List<string> lw = new List<string>();
  11666. int st = 2;
  11667. string tid = GetPostString("ctid");
  11668. if (tid.Length > 0)
  11669. {
  11670. string select_tid = getTidByCtid(tid);
  11671. lw.Add(string.Format("tid='{0}'", select_tid));
  11672. }
  11673. string shopname = GetPostString("shopname");
  11674. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11675. string buyernick = GetPostString("buyer_nick");
  11676. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11677. string sellermemo = GetPostString("seller_memo");
  11678. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11679. string supplier = GetPostString("supplier");
  11680. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11681. string customer = GetPostString("customer");
  11682. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11683. string design = GetPostString("design");
  11684. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11685. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11686. string poscode = CurrentUser.UserPost.Post.Code;
  11687. if (poscode != "SysAdmin")
  11688. {
  11689. string shopid = CurrentUser.User.pemShop;
  11690. lw.Add(string.Format("shopId in ({0})", shopid));
  11691. }
  11692. lw.Add("readMod = 2");
  11693. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11694. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11695. writeGridDataTableJson(dStruct.TotalCount, dt);
  11696. }
  11697. public void deal_express_complete()
  11698. {
  11699. string ctid = GetPostString("ctid");
  11700. if (!string.IsNullOrEmpty(ctid))
  11701. {
  11702. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11703. if (ceErpTradeCellExtend == null)
  11704. {
  11705. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11706. ceErpTradeCellExtend.ctid = ctid;
  11707. }
  11708. ceErpTradeCellExtend.readMod = 1;
  11709. if (ceErpTradeCellExtend.ID == 0)
  11710. {
  11711. ceErpTradeCellExtend.Create();
  11712. }
  11713. else
  11714. {
  11715. ceErpTradeCellExtend.Update();
  11716. }
  11717. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11718. returnSuccessMsg("修改成功!");
  11719. return;
  11720. }
  11721. returnErrorMsg("找不到订单");
  11722. }
  11723. public void aftersale_return_visit()
  11724. {
  11725. string ctid = GetPostString("ctid");
  11726. if (!string.IsNullOrEmpty(ctid))
  11727. {
  11728. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11729. if (ceErpTradeCellExtend == null)
  11730. {
  11731. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11732. ceErpTradeCellExtend.ctid = ctid;
  11733. }
  11734. ceErpTradeCellExtend.returnVisit = 1;
  11735. if (ceErpTradeCellExtend.ID == 0)
  11736. {
  11737. ceErpTradeCellExtend.Create();
  11738. }
  11739. else
  11740. {
  11741. ceErpTradeCellExtend.Update();
  11742. }
  11743. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11744. if (ceErpTradeAfterSaleExtend != null)
  11745. {
  11746. ceErpTradeAfterSaleExtend.TextResult = "";
  11747. ceErpTradeAfterSaleExtend.Update();
  11748. }
  11749. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11750. returnSuccessMsg("修改成功!");
  11751. return;
  11752. }
  11753. returnErrorMsg("找不到订单");
  11754. }
  11755. public void orderPlaceInfo()
  11756. {
  11757. string ctids = GetPostString("ctids");
  11758. string[] list = ctids.Split(',');
  11759. foreach (string ctid in list)
  11760. {
  11761. CeErpSukuraData.createInfo(ctid, 3);
  11762. }
  11763. StringBuilder sql = new StringBuilder();
  11764. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11765. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11766. designHelper.api_approveDesign(ctids); //approveDesign
  11767. returnSuccessMsg("");
  11768. }
  11769. public void get_issue_list()
  11770. {
  11771. DataStruct dStruct = GetPostStruct();
  11772. List<string> lw = new List<string>();
  11773. int st = 2;
  11774. string tid = GetPostString("ctid");
  11775. if (tid.Length > 0)
  11776. {
  11777. string select_tid = getTidByCtid(tid);
  11778. lw.Add(string.Format("tid='{0}'", select_tid));
  11779. }
  11780. string shopname = GetPostString("shopname");
  11781. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11782. string buyernick = GetPostString("buyer_nick");
  11783. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11784. string sellermemo = GetPostString("seller_memo");
  11785. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11786. string supplier = GetPostString("supplier");
  11787. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11788. string customer = GetPostString("customer");
  11789. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11790. string design = GetPostString("design");
  11791. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11792. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11793. string poscode = CurrentUser.UserPost.Post.Code;
  11794. if (poscode != "SysAdmin")
  11795. {
  11796. string shopid = CurrentUser.User.pemShop;
  11797. lw.Add(string.Format("shopId in ({0})", shopid));
  11798. }
  11799. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11800. {
  11801. lw.Add("IssueState = 1");
  11802. }
  11803. lw.Add("IssueState > 0");
  11804. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11805. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11806. writeGridDataTableJson(dStruct.TotalCount, dt);
  11807. }
  11808. public void saveIssueContent()
  11809. {
  11810. string ctid = GetPostString("ctid");
  11811. if (!string.IsNullOrEmpty(ctid))
  11812. {
  11813. string content = GetPostString("content");
  11814. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11815. if (ceErpTradeAfterSaleExtend == null)
  11816. {
  11817. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11818. ceErpTradeAfterSaleExtend.tid = ctid;
  11819. }
  11820. ceErpTradeAfterSaleExtend.IssueContent = content;
  11821. ceErpTradeAfterSaleExtend.IssueState = 1;
  11822. if (ceErpTradeAfterSaleExtend.ID > 0)
  11823. {
  11824. ceErpTradeAfterSaleExtend.Update();
  11825. }
  11826. else
  11827. {
  11828. ceErpTradeAfterSaleExtend.Create();
  11829. }
  11830. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11831. returnSuccessMsg("添加成功!");
  11832. return;
  11833. }
  11834. returnErrorMsg("找不到订单");
  11835. }
  11836. public void dealIssueContent()
  11837. {
  11838. string ctid = GetPostString("ctid");
  11839. if (!string.IsNullOrEmpty(ctid))
  11840. {
  11841. string content = GetPostString("content");
  11842. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11843. if (ceErpTradeAfterSaleExtend != null)
  11844. {
  11845. ceErpTradeAfterSaleExtend.IssueState = 2;
  11846. ceErpTradeAfterSaleExtend.Update();
  11847. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11848. returnSuccessMsg("修改完成!");
  11849. return;
  11850. }
  11851. }
  11852. returnErrorMsg("找不到订单");
  11853. }
  11854. public void set_tid_attachments()
  11855. {
  11856. string tid = GetPostString("tid");
  11857. string atta = GetPostString("atta");
  11858. if (!string.IsNullOrEmpty(tid))
  11859. {
  11860. if (string.IsNullOrEmpty(atta))
  11861. {
  11862. returnErrorMsg("文件地址为空");
  11863. return;
  11864. }
  11865. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11866. if (ceErpTradeCell != null)
  11867. {
  11868. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11869. if (ceErpTrade == null)
  11870. {
  11871. returnErrorMsg("找不到订单");
  11872. return;
  11873. }
  11874. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11875. bool isSend = false;
  11876. if (dt != null && dt.Rows.Count > 0)
  11877. {
  11878. foreach (DataRow row in dt.Rows)
  11879. {
  11880. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11881. {
  11882. isSend = true;
  11883. }
  11884. }
  11885. if (isSend)
  11886. {
  11887. returnErrorMsg("已发货无法修改");
  11888. return;
  11889. }
  11890. ceErpTrade.Attachments = atta;
  11891. ceErpTrade.Update();
  11892. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11893. returnSuccessMsg("上传成功!");
  11894. return;
  11895. }
  11896. }
  11897. }
  11898. returnErrorMsg("找不到订单");
  11899. }
  11900. public void get_tid_attachments()
  11901. {
  11902. string tid = GetPostString("tid");
  11903. if (!string.IsNullOrEmpty(tid))
  11904. {
  11905. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11906. if (ceErpTradeCell != null)
  11907. {
  11908. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11909. if (ceErpTrade == null)
  11910. {
  11911. returnErrorMsg("找不到订单");
  11912. return;
  11913. }
  11914. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11915. return;
  11916. }
  11917. }
  11918. returnErrorMsg("找不到订单");
  11919. }
  11920. public void check_erp_sameorders()
  11921. {
  11922. if (UrlPostParmsCheck("ctid"))
  11923. {
  11924. string eid = GetPostString("ctid");
  11925. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11926. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11927. if (entity != null && ceErpTrade != null)
  11928. {
  11929. if (entity.OrderState > 6)
  11930. {
  11931. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11932. return;
  11933. }
  11934. StringBuilder sql = new StringBuilder();
  11935. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  11936. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  11937. {
  11938. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  11939. }
  11940. else
  11941. {
  11942. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  11943. }
  11944. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11945. List<string> ids = new List<string>();
  11946. if (dt != null && dt.Rows.Count > 1)
  11947. {
  11948. bool needhe = true;
  11949. foreach (DataRow dr in dt.Rows)
  11950. {
  11951. ids.Add("'" + dr["ctid"] + "'");
  11952. /* //备注有合包
  11953. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11954. {
  11955. needhe = true;
  11956. }
  11957. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11958. {
  11959. needhe = true;
  11960. }
  11961. //顺丰快递
  11962. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11963. {
  11964. needhe = true;
  11965. }*/
  11966. }
  11967. if (!needhe)
  11968. {
  11969. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11970. return;
  11971. }
  11972. sql = new StringBuilder();
  11973. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11974. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11975. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11976. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11977. foreach (DataRow dr in dt.Rows)
  11978. {
  11979. dr["dstate"] = 0;
  11980. dr["dnumber"] = 0;
  11981. foreach (DataRow row in dt1.Rows)
  11982. {
  11983. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11984. {
  11985. dr["dstate"] = 2;
  11986. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11987. }
  11988. }
  11989. if (eid.Equals(dr["ctid"].ToString()))
  11990. {
  11991. dr["dstate"] = 1;
  11992. }
  11993. }
  11994. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11995. return;
  11996. }
  11997. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11998. return;
  11999. }
  12000. returnErrorMsg("未找到订单");
  12001. return;
  12002. }
  12003. returnErrorMsg("缺少必要的参数");
  12004. }
  12005. public void get_mark_number()
  12006. {
  12007. string eid = GetPostString("ctid");
  12008. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12009. if (entity != null)
  12010. {
  12011. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12012. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12013. int current = 1;
  12014. if (ceErpDeliverMark == null)
  12015. {
  12016. StringBuilder sql = new StringBuilder();
  12017. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6 and IsSample = 0", entity.SupplierId);
  12018. if (string.IsNullOrEmpty(ceErpTrade.receiverId))
  12019. {
  12020. sql.AppendFormat(" and (tid='{0}');", entity.tid);
  12021. }
  12022. else
  12023. {
  12024. sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
  12025. }
  12026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12027. List<string> ids = new List<string>();
  12028. if (dt != null && dt.Rows.Count > 1)
  12029. {
  12030. foreach (DataRow dr in dt.Rows)
  12031. {
  12032. ids.Add("'" + dr["ctid"] + "'");
  12033. }
  12034. //查询已有的编号
  12035. sql = new StringBuilder();
  12036. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12037. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12038. if (dt1 == null || dt1.Rows.Count == 0)
  12039. {
  12040. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12041. List<int> list_number = new List<int>();
  12042. foreach (DataRow row in numbers.Rows)
  12043. {
  12044. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12045. }
  12046. //查询空余编号
  12047. for (int i = 0; i < list_number.Count + 2; i++)
  12048. {
  12049. if (!list_number.Contains(current))
  12050. {
  12051. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12052. //防止查询过程中有新数据生成
  12053. if (ceErpDeliverMark1 == null)
  12054. {
  12055. break;
  12056. }
  12057. }
  12058. current++;
  12059. }
  12060. }
  12061. else
  12062. {
  12063. foreach (DataRow row in dt1.Rows)
  12064. {
  12065. current = Convert.ToInt32(row["markNumber"]);
  12066. }
  12067. }
  12068. ceErpDeliverMark = new CeErpDeliverMark();
  12069. ceErpDeliverMark.ctid = eid;
  12070. ceErpDeliverMark.createtime = DateTime.Now;
  12071. if (ceErpTrade != null)
  12072. {
  12073. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12074. }
  12075. ceErpDeliverMark.markNumber = current;
  12076. ceErpDeliverMark.Create();
  12077. }
  12078. }
  12079. else
  12080. {
  12081. current = ceErpDeliverMark.markNumber;
  12082. }
  12083. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12084. return;
  12085. }
  12086. }
  12087. public void aftersaleCytSend()
  12088. {
  12089. string ctid = GetPostString("ctid");
  12090. if (!string.IsNullOrEmpty(ctid))
  12091. {
  12092. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12093. if (ceErpTradeCell != null)
  12094. {
  12095. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12096. }
  12097. returnSuccessMsg("推送成功");
  12098. return;
  12099. }
  12100. returnErrorMsg("缺少必要的参数");
  12101. }
  12102. public void packOrderInfo()
  12103. {
  12104. string ctids = GetPostString("ctids");
  12105. if (!string.IsNullOrEmpty(ctids))
  12106. {
  12107. string[] ctid_list = ctids.Split(',');
  12108. if (ctid_list.Length > 20)
  12109. {
  12110. returnErrorMsg("单次下载次数不能超过20个");
  12111. return;
  12112. }
  12113. StringBuilder sql = new StringBuilder();
  12114. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  12115. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12116. int supplierId = 0;
  12117. StringBuilder insterSql = new StringBuilder();
  12118. for (int i = 0; i < dt.Rows.Count; i++)
  12119. {
  12120. DataRow row = dt.Rows[i];
  12121. if (i == 0)
  12122. {
  12123. supplierId = Convert.ToInt32(row["SupplierId"]);
  12124. }
  12125. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12126. {
  12127. returnErrorMsg("同车间的订单才能一起打包");
  12128. return;
  12129. }
  12130. int orderState = Convert.ToInt32(row["OrderState"]);
  12131. if (orderState != 5)
  12132. {
  12133. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12134. return;
  12135. }
  12136. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12137. }
  12138. CeErpPackData ceErpPackData = new CeErpPackData();
  12139. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + ".zip";
  12140. ceErpPackData.supplierId = supplierId;
  12141. ceErpPackData.createtime = DateTime.Now;
  12142. ceErpPackData.createBy = CurrentUser.UserID;
  12143. ceErpPackData.createName = CurrentUser.UserName;
  12144. ceErpPackData.Create();
  12145. if (ceErpPackData.ID > 0)
  12146. {
  12147. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12148. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12149. }
  12150. returnSuccessMsg("打包成功");
  12151. return;
  12152. }
  12153. returnErrorMsg("缺少必要的参数");
  12154. }
  12155. public void get_pack_list()
  12156. {
  12157. DataStruct dStruct = GetPostStruct();
  12158. List<string> lw = new List<string>();
  12159. string supplier = GetPostString("supplier");
  12160. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12161. string posTag = CurrentUser.UserPost.Post.Code;
  12162. if (posTag == "Supplier")
  12163. {
  12164. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12165. }
  12166. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12167. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12168. writeGridDataTableJson(dStruct.TotalCount, dt);
  12169. }
  12170. public void getExpressInfo()
  12171. {
  12172. string ctid = GetPostString("ctid");
  12173. if (!string.IsNullOrEmpty(ctid))
  12174. {
  12175. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12176. if (ceErpTradeCell != null)
  12177. {
  12178. string outSid = ceErpTradeCell.OutSid;
  12179. if (outSid.Length > 0)
  12180. {
  12181. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12182. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12183. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12184. return;
  12185. }
  12186. }
  12187. returnErrorMsg("查无记录");
  12188. return;
  12189. }
  12190. returnErrorMsg("缺少必要的参数");
  12191. }
  12192. }
  12193. }