sync.order.cs 662 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. using System.Runtime.Remoting.Metadata.W3cXsd2001;
  47. using NPOI.Util;
  48. using static NPOI.HSSF.Util.HSSFColor;
  49. using BizCom.Enum;
  50. using NPOI.POIFS.Properties;
  51. using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;
  52. using static SiteCore.taoObj.Api_tmc_refund_info_Obj;
  53. namespace SiteCore.Handler
  54. {
  55. public partial class sync
  56. {
  57. public void get_erp_orderlist()
  58. {
  59. string poscode = CurrentUser.UserPost.Post.Code;
  60. DataStruct dStruct = GetPostStruct();
  61. //string a = SecurityHelper.DecryptSymmetric("BnK3+504SQ8=");
  62. //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\(250924170328638492)-210x140mm-10个-UV转印贴彩色模切-GL-gzb520gzb-广东省-龙井《4765947843000325546-琳19890725》.ai");
  63. //apiHelper.Api_SyncOrderByTime("598825");
  64. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  65. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  66. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  67. //banniuApiHelper.sendLogisticsInfo(null);
  68. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  69. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  70. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2811249339088067154");
  71. //int sid = commonHelper.autoDistributeToSupplier(entity);
  72. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  73. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1756945416000,\"deliveryType\":\"OFFLINE\",\"discountFee\":20.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1757118213000,\"lines\":[{\"latestDeliveryTime\":1757118213000,\"mark2\":[\"DELIVERED\"],\"num\":1,\"outerId\":\"JSBHUVZYT\",\"payment\":10.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/490100363/O1CN01pEaojF1EYIjYhp76h_!!490100363.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4718408366815008220\",\"refSkuId\":\"5139754537453\",\"refSpuId\":\"641811002682\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":10.0,\"singleFee\":10.0,\"spuOuterId\":\"JSBHUVZYT\",\"standards\":\"【撕膜留字 | 易撕无残留】\",\"status\":\"SHIPPED\",\"title\":\"水晶标贴UV转印贴logo定制透明标识贴纸设计金属商标烫金标签定做\",\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0}],\"logisticsOrderNo\":\"YT7568465598389\",\"mark2\":[],\"modifyTime\":1756946987000,\"openBuyerId\":\"AAEVRHraABkUZRPgSx3gFRIR\",\"openBuyerNick\":\"a**\",\"openSellerNick\":\"琳19890725\",\"orderSource\":\"SYNC\",\"orderTime\":1756945412000,\"payTime\":1756945413000,\"payment\":10.0,\"platServiceFee\":0.0,\"posCode\":\"guliang\",\"posId\":598696,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0,\"logisticList\":[{\"logisticNo\":\"YT7568465598389\",\"logisticName\":\"圆通速递\"}]},\"receivedPayment\":0.0,\"receiverCity\":\"苏州市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"吴江区\",\"receiverId\":\"871dbaa880a955e031c5061436d7a5c1$\",\"receiverState\":\"江苏省\",\"receiverTown\":\"江陵街道\",\"refOid\":\"4718408366815008220\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"寄样-不干胶-uv转印贴小尺寸字母银色黑色-aa_小f-龙井-5,寄样-不干胶-金属标字母银色黑色-aa_小f-龙井-5\",\"serviceFee\":0.0,\"shippingTime\":1756946983000,\"status\":\"SHIPPED\",\"sysTags\":[],\"totalFee\":10.0,\"totalPrice\":30.0,\"totalSellPrice\":10.0,\"type\":\"SALE\"}}");
  74. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  75. //string result = designHelper.API_CheckOrderTo("12123123123132", "456456465465");
  76. //string res = apiHelper.API_GetWaybill("YTO-PDD-CYT", "250703-469248284251412");
  77. //preSalesHelper.dealMessageInfo("{\"bizOrder\":{\"id\":235819,\"parentId\":null,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderNo\":\"4624034580248409502\",\"shopId\":4,\"shopCode\":\"aolifu\",\"customerId\":345874,\"customerServiceId\":3184,\"thirdOrderId\":\"4624034580248409502\",\"orderPlatform\":\"TMALL\",\"openBuyerId\":\"AAEORHraABkUZRHgSx6ksuhU\",\"openBuyerNick\":\"tb278604202340\",\"openSellerNick\":\"奥丽芙旗舰店\",\"productUrl\":null,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"payAmount\":125.0,\"unrefundedAmount\":125.0,\"discountAmount\":5.0,\"csDiscountAmount\":-35.0,\"num\":13,\"province\":\"山西省\",\"city\":\"吕梁市\",\"area\":\"孝义市\",\"receiverTown\":\"孝义市\",\"address\":null,\"thirdReceiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"receiverName\":null,\"receiverMobile\":null,\"weChatId\":null,\"phone\":null,\"designContent\":\"\",\"designPics\":\"[]\",\"weChatQrPics\":\"[]\",\"addressFileUrl\":\"\",\"thirdFlag\":\"NONE\",\"remark\":null,\"sellerRemark\":\"\",\"buyerRemark\":\"\",\"timeoutRemark\":null,\"discountRemark\":null,\"status\":\"NOT_SHIPPED\",\"refundStatus\":0,\"internalStatus\":2,\"auditStatus\":null,\"auditUserId\":null,\"auditor\":null,\"customTag\":null,\"isRepurchase\":false,\"isOffline\":false,\"paymentFile\":null,\"orderTime\":\"2025-07-10 14:46:13\",\"modifyTime\":\"2025-07-10 14:46:37\",\"payTime\":\"2025-07-10 14:46:37\",\"confirmTime\":\"2025-07-10 14:51:23\",\"auditTime\":null,\"shippingTime\":null,\"finishTime\":null,\"erpCustomerServiceId\":3319,\"openBuyerID\":\"AAEORHraABkUZRHgSx6ksuhU\",\"orderFrom\":\"10\",\"receiverId\":\"4679677a0c7af72f1e8d0e672d57c575$\",\"bizOrderItems\":[{\"id\":310334,\"orderId\":235819,\"thirdOrderItemId\":\"4624034580248409502\",\"thirdSpuId\":\"740203900330\",\"thirdSkuId\":\"0\",\"title\":\"pvc贴纸定制防水不干胶圆形贴标自粘商标logo广告二维码标签印刷\",\"specification\":\"\",\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i3/2433960672/O1CN01D0ZzzR1GppCHSoBjD_!!4611686018427382496-0-item_pic.jpg\",\"price\":10.0,\"sellPrice\":9.62,\"amount\":9.62,\"totalPrice\":130.0,\"totalSellPrice\":125.0,\"totalAmount\":125.0,\"num\":13,\"refundStatus\":\"NO_REFUND\"}],\"bizOrderSplits\":[{\"id\":151557,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328848\",\"splitNo\":\"C1_4624034580248409502\",\"splitInfoNo\":\"C2+1\",\"splitAmount\":52.64,\"quoteRecordId\":520208,\"quoteAmount\":40.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328848)-[C2+1]-80x20mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328848\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":40.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":80.00,\"width\":20.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"80x20mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":40.00,\"numberType\":\"\",\"isDianziOrder\":0},{\"id\":151558,\"orderSource\":\"10\",\"orderType\":\"10\",\"orderId\":235819,\"bizOrderNo\":\"4624034580248409502\",\"spuId\":\"740203900330\",\"customerId\":345874,\"designerId\":null,\"uniqueNo\":\"250710145121328853\",\"splitNo\":\"C2_4624034580248409502\",\"splitInfoNo\":\"C2+2\",\"splitAmount\":72.36,\"quoteRecordId\":520209,\"quoteAmount\":55.0,\"parentSplitNo\":null,\"compensateAmount\":0,\"internalStatus\":2,\"designStatus\":null,\"errorStatus\":0,\"errorReason\":null,\"backTime\":null,\"syncErpFlag\":0,\"syncErpMsg\":null,\"designTimeoutType\":null,\"isToDesignSys\":false,\"isSpot\":false,\"isRepurchase\":false,\"isGift\":0,\"isUrgent\":false,\"isCombinedShipping\":false,\"designEstimateTime\":null,\"designFinishTime\":null,\"shippingTime\":null,\"finalDraftTime\":null,\"sampleMark\":0,\"sfMark\":0,\"wechatMark\":0,\"sendGiftMark\":0,\"addWechatMark\":0,\"otherMark\":null,\"systemRemark\":\"(250710145121328853)-[C2+2]-90x50mm-200张-铜版纸不干胶覆亮膜模切\",\"otherRemark\":\"-老客户改稿 之前下单号:13935850820ma\",\"followOrderRemark\":null,\"timeoutRemark\":null,\"workshopNote\":\"\",\"isPreShipping\":0,\"workOrderFiles\":null,\"checkOrderTime\":null,\"refundStatus\":0,\"refundAmount\":0.0,\"afterSaleStatus\":0,\"afterSaleReason\":null,\"afterSalePayAmount\":null,\"afterSalePics\":null,\"afterSaleBackPics\":null,\"afterSaleBackReason\":null,\"afterSaleMethod\":null,\"afterSaleRemark\":null,\"afterSaleTime\":null,\"afterSaleFinishTime\":null,\"erpCustomerServiceId\":3319,\"OrderSn\":\"250710145121328853\",\"orderFrom\":\"10\",\"ptid\":\"4624034580248409502\",\"offerAmount\":55.0,\"paymentFile\":null,\"cate1Id\":\"770260a9d3ee11efba6a00163e010e55\",\"cate1\":\"不干胶\",\"cate2Id\":\"77026444d3ee11efba6a00163e010e55\",\"cate2\":\"平张不干胶\",\"cate3Id\":\"7702655dd3ee11efba6a00163e010e55\",\"productCategory\":\"铜版纸不干胶\",\"sceneId\":0,\"scene\":\"合版印刷\",\"materialId\":15,\"material\":\"铜版纸不干胶\",\"craft\":\"[{\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 11, \\\"productCraftName\\\": \\\"覆亮膜\\\"}, {\\\"isAfterCraft\\\": false, \\\"productCraftId\\\": 163, \\\"productCraftName\\\": \\\"模切\\\"}]\",\"numbers\":1,\"opSceneId\":\"\",\"opScene\":\"\",\"length\":90.00,\"width\":50.00,\"height\":0,\"recSize\":\"\",\"sizeUnit\":\"mm\",\"size\":\"90x50mm\",\"numberUnit\":\"张\",\"quantity\":200,\"productQuantity\":\"200张\",\"discountAmount\":55.00,\"numberType\":\"\",\"isDianziOrder\":0}]}}");
  78. /*string path = "C:\\Users\\231010\\Downloads\\tids.txt";
  79. string path1 = "C:\\Users\\231010\\Downloads\\tid.txt";
  80. string tids = File.ReadAllText(path);
  81. List<string> list = tids.Split(',').ToList();
  82. int index = 0;
  83. foreach (string item in list)
  84. {
  85. CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
  86. try
  87. {
  88. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  89. if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
  90. {
  91. sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
  92. }
  93. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  94. List<string> tidList = new List<string>();
  95. if (dataTable != null && dataTable.Rows.Count > 0)
  96. {
  97. foreach (DataRow row in dataTable.Rows)
  98. {
  99. tidList.Add("'" + row["tid"].ToString() + "'");
  100. }
  101. }
  102. if (tidList.Count > 0)
  103. {
  104. sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
  105. dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  106. if (dataTable != null && dataTable.Rows.Count > 0)
  107. {
  108. int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
  109. if (count > 0)
  110. {
  111. Debug.WriteLine(index++);
  112. continue;
  113. }
  114. }
  115. }
  116. File.AppendAllText(path1, ceErpTrade.tid + "\n");
  117. }
  118. catch (Exception e)
  119. {
  120. File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
  121. }
  122. Debug.WriteLine(index++);
  123. }*/
  124. //string a = commonHelper.convertQNMemo("48x61mm-4款各40个-铜版纸-不干胶-覆膜模切-tb963561715-金陵-顺丰到付.粘成品.6.5cm牙签-老客户改稿找金陵拉群-16发", CeErpTradeCell.GetByCtid("2879265072537265386"));
  125. List<string> lw = new List<string>();
  126. string tid = GetPostString("ctid");
  127. string date1 = GetPostString("date1");
  128. //12-1 修改
  129. string urgent = GetPostString("urgent");
  130. string back = GetPostString("back");
  131. string offlineSearch = GetPostString("offlineSearch");
  132. int paramsCount = 0;
  133. if (!string.IsNullOrWhiteSpace(urgent))
  134. {
  135. if (urgent.Equals("true"))
  136. {
  137. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  138. }
  139. }
  140. if (!string.IsNullOrWhiteSpace(back))
  141. {
  142. if (back.Equals("true"))
  143. {
  144. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  145. }
  146. }
  147. if (!string.IsNullOrWhiteSpace(offlineSearch))
  148. {
  149. if (offlineSearch.Equals("true"))
  150. {
  151. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  152. }
  153. }
  154. //end
  155. string date2 = GetPostString("date2");
  156. string buyernick = GetPostString("buyer_nick");
  157. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  158. {
  159. if (tid.Length <= 0 && buyernick.Length <= 0)
  160. {
  161. return;
  162. }
  163. }
  164. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  165. {
  166. if (tid.Length > 0)
  167. {
  168. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(tid);
  169. if (ceErpTradeCell != null)
  170. {
  171. tid = ceErpTradeCell.tid;
  172. }
  173. List<string> select_tid = getTidByCtidMore(tid);
  174. lw.Add(string.Format("tid in ({0})", string.Join(",", select_tid)));
  175. }
  176. if (buyernick.Length > 0)
  177. {
  178. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  179. }
  180. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  181. if (dw.Length > 0)
  182. {
  183. lw.Add(dw);
  184. }
  185. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  186. {
  187. string usershop = CurrentUser.User.pemShop;
  188. lw.Add(string.Format("ShopId in ({0})", usershop));
  189. }
  190. }
  191. else
  192. {
  193. if (ex_psize == 0)
  194. {
  195. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  196. }
  197. if (PKey != "admin" && poscode != "SysAdmin")
  198. {
  199. string usershop = CurrentUser.User.pemShop;
  200. lw.Add(string.Format("ShopId in ({0})", usershop));
  201. paramsCount++;
  202. }
  203. }
  204. string uploaddate1 = GetPostString("uploaddate1");
  205. string uploaddate2 = GetPostString("uploaddate2");
  206. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  207. if (update.Length > 0) lw.Add(update);
  208. string deliverydate1 = GetPostString("deliverydate1");
  209. string deliverydate2 = GetPostString("deliverydate2");
  210. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  211. if (deliverydate.Length > 0)
  212. {
  213. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  214. };
  215. string shopname = GetPostString("shopname");
  216. if (shopname.Length > 0)
  217. {
  218. CeErpShop ceErpShop = CeErpShop.GetShopIdByName(shopname);
  219. if (ceErpShop != null)
  220. {
  221. lw.Add(string.Format("shopId = {0}", ceErpShop.ID));
  222. }
  223. }
  224. string addwechat = GetPostString("addwechat");
  225. if (addwechat.Length > 0)
  226. {
  227. int addWt = Convert.ToInt32(addwechat);
  228. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  229. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  230. }
  231. string customer = GetPostString("customer");
  232. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  233. string design = GetPostString("design");
  234. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  235. string orderState = GetPostString("orderState");
  236. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  237. string address = GetPostString("address");
  238. 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));
  239. string sellermemo = GetPostString("seller_memo");
  240. if (sellermemo.Length > 0)
  241. {
  242. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  243. }
  244. string otherMemo = GetPostString("otherMemo");
  245. if (otherMemo.Length > 0)
  246. {
  247. lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  248. }
  249. string backReason = GetPostString("backReason");
  250. if (backReason.Length > 0)
  251. {
  252. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  253. }
  254. string apdate1 = GetPostString("apdate1");
  255. string apdate2 = GetPostString("apdate2");
  256. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  257. if (dwap.Length > 0) lw.Add(dwap);
  258. string price1 = GetPostString("price1");
  259. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  260. string price2 = GetPostString("price2");
  261. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  262. string isoldcustomer = GetPostString("isoldcus");
  263. string spudata = GetPostString("spudata");
  264. if ("0".Equals(spudata))
  265. {
  266. lw.Add(string.Format("(spu_id = '' or spu_id is null)"));
  267. }
  268. if ("1".Equals(spudata))
  269. {
  270. lw.Add(string.Format("spu_id <> ''"));
  271. }
  272. string finishdate1 = GetPostString("finishdate1");
  273. string finishdate2 = GetPostString("finishdate2");
  274. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  275. bool isFinish = false;
  276. if (finishdate.Length > 0)
  277. {
  278. lw.Add(finishdate);
  279. isFinish = true;
  280. paramsCount++;
  281. }
  282. if (isoldcustomer.Length > 0)
  283. {
  284. if ("2".Equals(isoldcustomer))
  285. {
  286. lw.Add(string.Format("VipCustomer=1"));
  287. }
  288. else
  289. {
  290. lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  291. }
  292. }
  293. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  294. if (ex_psize > 0)
  295. {
  296. int UserID = CurrentUser.UserID;
  297. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  298. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  299. {
  300. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  301. }
  302. dStruct.Order = "pay_time desc";
  303. }
  304. string isNew = GetPostString("isNew");
  305. if (isNew == "true")
  306. {
  307. lw.Add(string.Format("IsNew = {0}", 1));
  308. }
  309. string overtime = GetPostString("overtime");
  310. if (overtime == "1")
  311. {
  312. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  313. }
  314. String usePost = CurrentUser.UserPost.Post.Code;
  315. if (usePost.Equals("Operation") == true)
  316. {
  317. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  318. }
  319. else
  320. {
  321. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  322. }
  323. //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";
  324. if (dStruct.PageSize == 100000)
  325. {
  326. dStruct.Order = "";
  327. }
  328. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  329. DataTable dt = null;
  330. string tablename = "view_orderlist";
  331. if (isFinish)
  332. {
  333. tablename = "view_orderlist_end";
  334. }
  335. dt = WebCache.GetData(tablename, dStruct);
  336. if (dt != null && dt.Rows.Count > 0)
  337. {
  338. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  339. foreach (DataRow dr in dt.Rows)
  340. {
  341. try
  342. {
  343. if (dr["refund_fees"] != null)
  344. {
  345. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  346. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  347. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  348. if (payment == refund_fees)
  349. {
  350. dr["refund_fees"] = Math.Round(refund_fees, 2);
  351. }
  352. else if (refund_fees == total_fee)
  353. {
  354. dr["refund_fees"] = payment;
  355. }
  356. else
  357. {
  358. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  359. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  360. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  361. }
  362. }
  363. // 对象操作
  364. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  365. ceErpTradeCell.ctid = dr["ctid"].ToString();
  366. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  367. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  368. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  369. if (dStruct.PageSize != 100000)
  370. {
  371. if (dr["DispatchSort"].ToString() == "2")
  372. {
  373. dr["gongchuang"] = 200;
  374. }
  375. else if ("外协".Equals(dr["ToType"].ToString()))
  376. {
  377. dr["gongchuang"] = 200;
  378. }
  379. else if ("内部".Equals(dr["ToType"].ToString()))
  380. {
  381. dr["gongchuang"] = -1;
  382. }
  383. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  384. {
  385. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  386. dr["gongchuang"] = response.code;
  387. }
  388. }
  389. }
  390. catch (NullReferenceException ex)
  391. {
  392. // 处理空引用异常
  393. dr["refund_fees"] = "0.00";
  394. }
  395. }
  396. }
  397. writeGridDataTableJson(dStruct.TotalCount, dt);
  398. }
  399. public void get_erp_orderlist_sumprice()
  400. {
  401. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  402. return;
  403. List<string> lw = new List<string>();
  404. string tid = GetPostString("ctid");
  405. string date1 = GetPostString("date1");
  406. string date2 = GetPostString("date2");
  407. if (tid.Length > 0 || date1.Length > 0)
  408. {
  409. lw.Add(string.Format("ctid like '%{0}%'", tid));
  410. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  411. if (dw.Length > 0) lw.Add(dw);
  412. }
  413. else
  414. {
  415. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  416. }
  417. string shopname = GetPostString("shopname");
  418. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  419. string buyernick = GetPostString("buyer_nick");
  420. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  421. string customer = GetPostString("customer");
  422. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  423. string design = GetPostString("design");
  424. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  425. string orderState = GetPostString("orderState");
  426. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  427. string address = GetPostString("address");
  428. 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));
  429. string sellermemo = GetPostString("seller_memo");
  430. if (sellermemo.Length > 0)
  431. {
  432. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  433. }
  434. string apdate1 = GetPostString("apdate1");
  435. string apdate2 = GetPostString("apdate2");
  436. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  437. if (dwap.Length > 0) lw.Add(dwap);
  438. string price1 = GetPostString("price1");
  439. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  440. string price2 = GetPostString("price2");
  441. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  442. string isoldcustomer = GetPostString("isoldcus");
  443. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  444. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  445. if (PKey != "admin")
  446. {
  447. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  448. lw.Add(string.Format("shopId in ({0})", usershop));
  449. }
  450. //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";
  451. string mainWhere = string.Join(" and ", lw.ToArray());
  452. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  453. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  454. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  455. decimal total = 0;
  456. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  457. {
  458. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  459. }
  460. var res = new
  461. {
  462. data = total
  463. };
  464. string ro_jsond = JsonConvert.SerializeObject(res);
  465. returnSuccess(ro_jsond);
  466. return;
  467. }
  468. public void get_erp_CustomerServiceGather()
  469. {
  470. string userWhere = "", orderWhere = "";
  471. List<string> lw = new List<string>();
  472. string customer = GetPostString("customer");
  473. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  474. string shopname = GetPostString("shopname");
  475. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  476. string date1 = GetPostString("date1");
  477. string date2 = GetPostString("date2");
  478. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  479. if (dw.Length > 0) lw.Add(dw);
  480. orderWhere = string.Join(" and ", lw.ToArray());
  481. 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 " +
  482. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  483. "left join " +
  484. "( " +
  485. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  486. ") as b on a.ID = b.CustomerUserId " +
  487. "left join " +
  488. "( " +
  489. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  490. ") as d on a.ID = d.CustomerUserId " +
  491. "left join " +
  492. "( " +
  493. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  494. ") as e on a.ID = e.CustomerUserId " +
  495. "left join " +
  496. "( " +
  497. " select CustomerUserId, RefundCount, RefundSum from " +
  498. " ( " +
  499. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  500. " from CE_ErpTradeRefund a " +
  501. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  502. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  503. " group by CustomerUserId " +
  504. " ) as a " +
  505. ") as f on a.ID = f.CustomerUserId " +
  506. "where a.PostCode = 'CustomerService'",
  507. userWhere, orderWhere);
  508. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  509. writeGridDataTableJson(dt.Rows.Count, dt);
  510. //writeGridDataTableJson(dt.Rows.Count, dt);
  511. }
  512. //设计汇总
  513. public void get_erp_DesignerGather()
  514. {
  515. string userWhere = "", orderWhere = "";
  516. List<string> lw = new List<string>();
  517. string Designer = GetPostString("designer");
  518. int org = GetPostInt("org");
  519. if (Designer.Length > 0)
  520. {
  521. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  522. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  523. }
  524. else if (org > 0)
  525. {
  526. userWhere = string.Format(" where OrgID ={0}", org);
  527. }
  528. string shopname = GetPostString("shopname");
  529. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  530. string state = GetPostString("state");
  531. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  532. string OrderArea = GetPostString("order_area");
  533. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  534. string date1 = GetPostString("date1");
  535. string date2 = GetPostString("date2");
  536. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  537. if (dw.Length > 0) lw.Add(dw);
  538. string UpDate1 = GetPostString("UpDate1");
  539. string UpDate2 = GetPostString("UpDate2");
  540. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  541. if (dw.Length > 0) lw.Add(dw);
  542. orderWhere = string.Join(" and ", lw.ToArray());
  543. 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 (" +
  544. "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 " +
  545. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  546. "left join " +
  547. "( " +
  548. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  549. ") as b on a.ID = b.DesignUserId " +
  550. "left join " +
  551. "( " +
  552. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  553. ") as d on a.ID = d.DesignUserId " +
  554. "left join " +
  555. "( " +
  556. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  557. ") as e on a.ID = e.DesignUserId " +
  558. "left join " +
  559. "( " +
  560. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  561. ") as g on a.ID = g.DesignUserId " +
  562. "left join " +
  563. "( " +
  564. " select CustomerUserId, RefundCount, RefundSum from " +
  565. " ( " +
  566. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  567. " from CE_ErpTradeRefund a " +
  568. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  569. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  570. " group by CustomerUserId " +
  571. " ) as a " +
  572. ") as f on a.ID = f.CustomerUserId " +
  573. "where a.PostCode = 'Designer') as z",
  574. userWhere, orderWhere);
  575. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  576. writeGridDataTableJson(dt.Rows.Count, dt);
  577. }
  578. //删除tradecell的订单
  579. public void del_erp_cellorder()
  580. {
  581. if (UrlPostParmsCheck("ctid"))
  582. {
  583. string eid = GetPostString("ctid");
  584. CeErpTradeCell.DelByCtid(eid);
  585. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  586. returnSuccessMsg("删除成功");
  587. }
  588. }
  589. public void clear_erp_refundstate()
  590. {
  591. if (UrlPostParmsCheck("ids"))
  592. {
  593. string eids = GetPostString("ids");
  594. string[] ctidList = eids.Split(',');
  595. foreach (string ctid in ctidList)
  596. {
  597. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  598. if (entity != null)
  599. {
  600. entity.IsRefund = 0;
  601. entity.Update();
  602. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  603. }
  604. else
  605. continue;
  606. }
  607. returnSuccessMsg("操作成功");
  608. return;
  609. }
  610. returnErrorMsg("缺少必要参数");
  611. }
  612. public void set_erp_urgency()
  613. {
  614. if (UrlPostParmsCheck("ctid"))
  615. {
  616. string eid = GetPostString("ctid");
  617. CeErpTradeCell entity = null;
  618. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  619. if (entity != null)
  620. {
  621. double prices = commonHelper.calculationPrice(entity);
  622. if (prices <= 100)
  623. {
  624. returnErrorMsg("此订单金额不足100元,无法加急。");
  625. return;
  626. }
  627. string utime = GetPostString("urgencytime");
  628. if (utime.Length > 0)
  629. {
  630. entity.UrgencyTime = Convert.ToDateTime(utime);
  631. }
  632. else
  633. {
  634. returnErrorMsg("请选择加急时间");
  635. return;
  636. }
  637. if (entity.OrderState <= 4)
  638. {
  639. //entity.seller_memo = entity.seller_memo + "-加急";
  640. string smemo = entity.seller_memo;
  641. int kindex = smemo.IndexOf(")");
  642. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  643. if (lastoneStr != "-")
  644. {
  645. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  646. }
  647. string prememo = smemo.Substring(0, kindex + 2);
  648. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  649. int lastkindex = lastmemo.IndexOf("(");
  650. DateTime urgtime = Convert.ToDateTime(utime);
  651. string newlastmemo = "";
  652. if (lastkindex == 0)
  653. {
  654. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  655. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  656. }
  657. else
  658. {
  659. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  660. }
  661. entity.seller_memo = prememo + newlastmemo;
  662. }
  663. entity.IsUrgency = true;
  664. entity.UpdateTime = DateTime.Now;
  665. entity.Update();
  666. ApiVo apiVo = new ApiVo();
  667. apiVo.orderNumber = entity.ctid;
  668. apiVo.actionName = "changeDesign";
  669. apiVo.orderRemarks = entity.seller_memo;
  670. apiVo.remarkSign = 3;
  671. designHelper.API_WorkCore(apiVo); //changeDesign
  672. CeErpSukuraData.createInfo(entity.ctid, 7);
  673. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  674. returnSuccessMsg("设置成功!");
  675. return;
  676. }
  677. returnErrorMsg("找不到记录");
  678. }
  679. }
  680. public void set_erp_reset()
  681. {
  682. if (UrlPostParmsCheck("ctid"))
  683. {
  684. string eid = GetPostString("ctid");
  685. CeErpTradeCell entity = null;
  686. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  687. if (entity != null)
  688. {
  689. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  690. {
  691. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  692. {
  693. returnErrorMsg("财务要求已下单已发货无法重置");
  694. return;
  695. }
  696. }
  697. entity.IsUrgency = false;
  698. entity.seller_memo = "";
  699. entity.OtherMemo = "";
  700. entity.OrderState = 0;
  701. entity.IsReturn = 0;
  702. //entity.IsRefund = 0;
  703. entity.MemoOpt = 0;
  704. entity.AfterSaleState = 0;
  705. entity.AfterSaleResponsible = "";
  706. entity.AfterSaleUserId = 0;
  707. entity.IsNeedBill = 0;
  708. entity.CustomerUserId = 0;
  709. entity.DesignUserId = 0;
  710. entity.SupplierId = 0;
  711. entity.PlaceUserId = 0;
  712. entity.ptid = "";
  713. entity.IsSample = 0;
  714. entity.IsXianHuo = 0;
  715. entity.isDianziOrder = 0;
  716. entity.DispatchSort = 0;
  717. entity.IsVerifyToSupplier = false;
  718. entity.FinishPlaceTime = null;
  719. entity.Update();
  720. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  721. if (trade != null)
  722. {
  723. trade.seller_memo = "";
  724. trade.Update();
  725. }
  726. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  727. returnSuccessMsg("重置成功!");
  728. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  729. if (desginBill != null)
  730. {
  731. desginBill.isDel = 1;
  732. desginBill.Update();
  733. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  734. }
  735. ApiVo apiVo = new ApiVo();
  736. apiVo.orderNumber = entity.ctid;
  737. apiVo.actionName = "resetDesign";
  738. designHelper.API_WorkCore(apiVo);//resetDesign
  739. return;
  740. }
  741. returnErrorMsg("找不到记录");
  742. }
  743. }
  744. public void save_erp_sellermemo()
  745. {
  746. if (UrlPostParmsCheck("ctid"))
  747. {
  748. string ctid = GetPostString("ctid");
  749. CeErpTradeCell entity = null;
  750. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  751. if (entity != null)
  752. {
  753. string memo = GetPostString("seller_memo");
  754. string qn_memo = GetPostString("qn_memo");
  755. memo = memo.Replace(" ", "");
  756. if (memo.Contains("补差"))
  757. {
  758. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  759. return;
  760. }
  761. List<string> bitList = new List<string>
  762. {
  763. "\\","/",":","*","?", "\"","<" ,">","|"
  764. };
  765. bool isIn = false;
  766. foreach (string bit in bitList)
  767. {
  768. if (memo.Contains(bit))
  769. {
  770. isIn = true;
  771. }
  772. }
  773. if (isIn)
  774. {
  775. returnErrorMsg("不能使用 一些符合作为文件名");
  776. return;
  777. }
  778. if (entity.seller_memo != memo)
  779. {
  780. if (entity.IsSample == 2)
  781. {
  782. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  783. return;
  784. }
  785. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  786. {
  787. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  788. {
  789. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  790. return;
  791. }
  792. /*if (CurrentUser.UserPost.Post.Code != "Place")
  793. {
  794. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  795. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  796. {
  797. returnErrorMsg("售前系统订单无法再此修改!");
  798. return;
  799. }
  800. }*/
  801. }
  802. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  803. }
  804. if (!string.IsNullOrEmpty(qn_memo) && !(entity.IsSample > 0 || entity.ctid.Contains("N_") || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物")))
  805. {
  806. if (entity.OrderState >= 5)
  807. {
  808. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  809. return;
  810. }
  811. string delMemo = commonHelper.convertQNMemo(qn_memo, ref entity);
  812. if (string.IsNullOrEmpty(delMemo))
  813. {
  814. returnErrorMsg("备注不规范,无法识别");
  815. return;
  816. }
  817. memo = delMemo;
  818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统千牛修改为:" + memo, entity.OrderState, 1);
  819. }
  820. commonHelper.getCytPrice(entity);
  821. int memoopt = GetPostInt("MemoOpt");
  822. Boolean ismemoopt = false;
  823. if (memoopt > 0)
  824. {
  825. string stropt = "";
  826. if (memoopt == 1)
  827. {
  828. stropt = "“改稿”";
  829. ismemoopt = true;
  830. }
  831. else if (memoopt == 2)
  832. {
  833. stropt = "“定稿”";
  834. }
  835. else if (memoopt == 3)
  836. {
  837. stropt = "“查货”";
  838. CeErpSukuraData.createInfo(entity.ctid, 6);
  839. }
  840. entity.MemoOpt = Convert.ToInt32(memoopt);
  841. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  842. }
  843. if (entity.OrderState < 5)
  844. {
  845. memo = memo.Replace("(", "(");
  846. memo = memo.Replace(")", ")");
  847. }
  848. /* if (entity.OrderState < 3)
  849. {
  850. entity.DispatchSort = 0;
  851. }*/
  852. entity.seller_memo = memo;
  853. entity.UpdateTime = DateTime.Now;
  854. entity.Update();
  855. ApiVo apiVo = new ApiVo();
  856. apiVo.orderNumber = entity.ctid;
  857. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  858. apiVo.orderRemarks = memo;
  859. apiVo.remarkSign = memoopt;
  860. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  861. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  862. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  863. {
  864. dataHelper.api_orderBack(entity.ctid, "0", "");
  865. }
  866. if (entity.seller_memo.Contains("改稿"))
  867. {
  868. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  869. }
  870. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  871. returnSuccessMsg("保存成功!");
  872. return;
  873. }
  874. returnErrorMsg("找不到记录");
  875. }
  876. }
  877. public void ins_erp_checkorder()
  878. {
  879. if (UrlPostParmsCheck("ctid"))
  880. {
  881. string ctid = GetPostString("ctid");
  882. CeErpTradeCell entity = null;
  883. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  884. if (entity != null)
  885. {
  886. if (entity.OrderState < 6)
  887. {
  888. returnErrorMsg("下单完成后才可查货");
  889. return;
  890. }
  891. /*if (entity.OrderState > 6)
  892. {
  893. returnErrorMsg("订单已发货");
  894. return;
  895. }*/
  896. if (entity.FinishPlaceTime != null)
  897. {
  898. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  899. {
  900. returnErrorMsg("下单时间不足,无法查货");
  901. return;
  902. }
  903. }
  904. entity.MemoOpt = 3;
  905. entity.CheckOrderTime = DateTime.Now;
  906. entity.UpdateTime = DateTime.Now;
  907. entity.Update();
  908. CeErpSukuraData.createInfo(entity.ctid, 6);
  909. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  910. returnSuccessMsg("操作成功!");
  911. return;
  912. }
  913. returnErrorMsg("找不到记录");
  914. }
  915. }
  916. public void save_erp_othermemo()
  917. {
  918. if (UrlPostParmsCheck("ctid"))
  919. {
  920. string ctid = GetPostString("ctid");
  921. CeErpTradeCell entity = null;
  922. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  923. if (entity != null)
  924. {
  925. entity.OtherMemo = GetPostString("otherMemo");
  926. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  927. {
  928. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  929. StringBuilder sql = new StringBuilder();
  930. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  931. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  932. if (dt != null && dt.Rows.Count > 0)
  933. {
  934. foreach (DataRow dr in dt.Rows)
  935. {
  936. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  937. {
  938. //品类一直
  939. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  940. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  941. if (ceErpSampleCustomer == null)
  942. {
  943. ceErpSampleCustomer = new CeErpSampleCustomer();
  944. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  945. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  946. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  947. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  948. ceErpSampleCustomer.shopId = entity.ShopId;
  949. }
  950. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  951. ceErpSampleCustomer.lastTid = entity.tid;
  952. if (ceErpSampleCustomer.ID > 0)
  953. {
  954. ceErpSampleCustomer.Update();
  955. }
  956. else
  957. {
  958. ceErpSampleCustomer.Create();
  959. }
  960. }
  961. }
  962. }
  963. }
  964. //if (entity.IsOldCustomer == 1)
  965. //{
  966. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  967. //{
  968. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  969. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  970. //}
  971. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  972. //{
  973. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  974. // {
  975. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  976. // {
  977. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  978. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  979. // }
  980. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  981. // {
  982. // entity.OrderState = 2;
  983. // entity.DesignUserId = 0;
  984. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  985. // }
  986. // else
  987. // {
  988. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  989. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  990. // }
  991. // }
  992. //}
  993. //}
  994. entity.UpdateTime = DateTime.Now;
  995. entity.Update();
  996. returnSuccessMsg("保存成功!");
  997. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  998. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  999. if (entity.OtherMemo.Contains("改稿"))
  1000. {
  1001. commonHelper.sendSpuData(entity, ceErpTradeCellExtend);
  1002. }
  1003. return;
  1004. }
  1005. returnErrorMsg("找不到记录");
  1006. }
  1007. }
  1008. public void save_erp_customermemo()
  1009. {
  1010. if (UrlPostParmsCheck("ctid"))
  1011. {
  1012. string ctid = GetPostString("ctid");
  1013. CeErpTradeCell entity = null;
  1014. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  1015. if (entity != null)
  1016. {
  1017. entity.UpdateTime = DateTime.Now;
  1018. entity.CustomerMemo = GetPostString("CustomerMemo");
  1019. entity.Update();
  1020. ApiVo apiVo = new ApiVo();
  1021. apiVo.orderNumber = entity.ctid;
  1022. apiVo.actionName = "followRemarks";
  1023. apiVo.orderRemarks = entity.CustomerMemo;
  1024. designHelper.API_WorkCore(apiVo);//followRemarks
  1025. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  1026. returnSuccessMsg("保存成功!");
  1027. return;
  1028. }
  1029. returnErrorMsg("找不到记录");
  1030. }
  1031. }
  1032. public void upd_erp_addmemotag()
  1033. {
  1034. if (UrlPostParmsCheck("ctid"))
  1035. {
  1036. ;
  1037. string eid = GetPostString("ctid");
  1038. string sfTagstr = GetPostString("memotag");
  1039. CeErpTradeCell entity = null;
  1040. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1041. if (entity != null)
  1042. {
  1043. ApiVo apiVo = new ApiVo();
  1044. if (entity.OrderState == 0)
  1045. {
  1046. returnErrorMsg("请先领单");
  1047. return;
  1048. }
  1049. //撤销顺丰
  1050. if (sfTagstr == "撤销顺丰")
  1051. {
  1052. entity.IsSF = 0;
  1053. string reMsg = "";
  1054. string oldmemo = entity.seller_memo;
  1055. if (entity.OrderState < 5)
  1056. {
  1057. oldmemo = oldmemo.Replace("顺丰到付", "");
  1058. oldmemo = oldmemo.Replace("顺丰寄付", "");
  1059. entity.seller_memo = oldmemo;
  1060. }
  1061. else
  1062. {
  1063. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  1064. {
  1065. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  1066. }
  1067. }
  1068. entity.Update();
  1069. apiVo.orderNumber = entity.ctid;
  1070. apiVo.actionName = "orderRemarks";
  1071. apiVo.orderRemarks = entity.seller_memo;
  1072. apiVo.isSf = entity.IsSF.ToString();
  1073. designHelper.API_WorkCore(apiVo);//orderRemarks
  1074. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  1075. returnSuccessMsg("撤销成功!" + reMsg);
  1076. return;
  1077. }
  1078. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  1079. {
  1080. //string oldmemo = entity.seller_memo;
  1081. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  1082. string sfStr = GetPostString("memotag");
  1083. string smemo = entity.seller_memo;
  1084. int kindex = smemo.IndexOf(")");
  1085. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  1086. if (lastoneStr != "-")
  1087. {
  1088. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  1089. }
  1090. string prememo = smemo.Substring(0, kindex + 2);
  1091. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  1092. int lastkindex = lastmemo.IndexOf("(");
  1093. string newlastmemo = "";
  1094. if (lastkindex == 0)
  1095. {
  1096. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  1097. newlastmemo = "(" + sfStr + "." + useLastmemo;
  1098. }
  1099. else
  1100. {
  1101. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  1102. }
  1103. entity.seller_memo = prememo + newlastmemo;
  1104. }
  1105. string sfTagMSg = "";
  1106. if (sfTagstr == "顺丰寄付")
  1107. {
  1108. entity.IsSF = 1;
  1109. sfTagMSg = "顺丰寄付";
  1110. }
  1111. else if (sfTagstr == "顺丰到付")
  1112. {
  1113. entity.IsSF = 2;
  1114. sfTagMSg = "顺丰到付";
  1115. }
  1116. if (entity.SupplierId == 19 && entity.OrderState == 6)
  1117. {
  1118. string deliveryWayName = "";
  1119. if (sfTagstr == "撤销顺丰")
  1120. {
  1121. sfTagstr = "普通快递";
  1122. }
  1123. if (sfTagstr == "顺丰寄付")
  1124. {
  1125. sfTagstr = "顺丰特快寄付";
  1126. }
  1127. if (sfTagstr == "顺丰到付")
  1128. {
  1129. sfTagstr = "顺丰特快到付";
  1130. }
  1131. string result = apichyHelper.updateExpressMark(entity.tid, sfTagstr);
  1132. if ("修改失败".Equals(result))
  1133. {
  1134. returnErrorMsg("修改失败");
  1135. return;
  1136. }
  1137. }
  1138. entity.Update();
  1139. apiVo = new ApiVo();
  1140. apiVo.orderNumber = entity.ctid;
  1141. apiVo.actionName = "orderRemarks";
  1142. apiVo.orderRemarks = entity.seller_memo;
  1143. apiVo.isSf = entity.IsSF.ToString();
  1144. designHelper.API_WorkCore(apiVo);//orderRemarks
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_ordertag()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. string eid = GetPostString("ctid");
  1157. CeErpTradeCell entity = null;
  1158. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1159. if (entity != null)
  1160. {
  1161. int tag = GetPostInt("wechattag");
  1162. //if(tag==4 && entity.IsSample == 2)
  1163. //{
  1164. // returnErrorMsg("补差价单不能标记微信单");
  1165. // return;
  1166. //}
  1167. entity.wechatTag = tag;
  1168. entity.Update();
  1169. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1170. if (tag == 1)
  1171. {
  1172. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1173. if (cash == null)
  1174. {
  1175. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1176. cash = new CeErpReturnCash();
  1177. cash.tid = entity.tid;
  1178. cash.seller_nick = main.seller_nick;
  1179. cash.payment = trade.payment;
  1180. cash.buyer_nick = main.buyer_nick;
  1181. cash.cashstate = 0;
  1182. cash.rtype = "微信返现";
  1183. cash.returnprice = 0;
  1184. cash.created = DateTime.Now;
  1185. cash.con = "订单标记微信单";
  1186. cash.img = "";
  1187. cash.applyuserid = CurrentUser.UserID;
  1188. cash.Create();
  1189. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  1190. }
  1191. else
  1192. {
  1193. cash.cashstate = 0;
  1194. cash.Update();
  1195. }
  1196. CeErpSukuraData.createInfo(entity.ctid, 9);
  1197. }
  1198. else if (tag == 2)
  1199. {
  1200. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1201. if (cash == null)
  1202. {
  1203. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1204. cash = new CeErpReturnCash();
  1205. cash.tid = entity.tid;
  1206. cash.seller_nick = main.seller_nick;
  1207. cash.payment = trade.payment;
  1208. cash.buyer_nick = main.buyer_nick;
  1209. cash.cashstate = 0;
  1210. cash.rtype = "推购返现";
  1211. cash.returnprice = 5;
  1212. cash.created = DateTime.Now;
  1213. cash.con = "订单标记推购单";
  1214. cash.img = "";
  1215. cash.applyuserid = CurrentUser.UserID;
  1216. cash.Create();
  1217. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1218. }
  1219. else
  1220. {
  1221. cash.cashstate = 0;
  1222. cash.Update();
  1223. }
  1224. CeErpSukuraData.createInfo(entity.ctid, 9);
  1225. }
  1226. else if (tag == 3)
  1227. {
  1228. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1229. if (pers == null)
  1230. {
  1231. pers = new CeErpPersuade();
  1232. pers.ctid = entity.ctid;
  1233. pers.pstate = 0;
  1234. pers.created = DateTime.Now;
  1235. pers.applyuserid = CurrentUser.UserID;
  1236. pers.Create();
  1237. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1238. }
  1239. else
  1240. {
  1241. pers.pstate = 0;
  1242. pers.Update();
  1243. }
  1244. }
  1245. else if (tag == 4 || tag == 5)
  1246. {
  1247. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1248. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1249. if (pers == null)
  1250. {
  1251. pers = CeErpStayGoods.GetByTid(entity.tid);
  1252. }
  1253. if (pers == null)
  1254. {
  1255. pers = new CeErpStayGoods();
  1256. pers.t_id = entity.tid;
  1257. pers.ctid = entity.ctid;
  1258. pers.status = "待审核";
  1259. pers.audit_type = 0;
  1260. if (tag == 4)
  1261. {
  1262. pers.stay_type = "微信推购";
  1263. }
  1264. else
  1265. {
  1266. pers.stay_type = "旺旺推购";
  1267. }
  1268. if (entity.IsXianHuo == 0)
  1269. {
  1270. pers.product_id = entity.ProductId;
  1271. }
  1272. pers.wangwang = main.buyer_nick;
  1273. pers.shop_name = main.seller_nick;
  1274. pers.creata_time = DateTime.Now;
  1275. pers.create_u_id = CurrentUser.UserID;
  1276. pers.create_u_name = CurrentUser.UserName;
  1277. pers.Create();
  1278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1279. }
  1280. else
  1281. {
  1282. pers.ctid = entity.ctid;
  1283. pers.audit_type = 0;
  1284. pers.Update();
  1285. }
  1286. CeErpSukuraData.createInfo(entity.ctid, 10);
  1287. }
  1288. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1289. returnSuccessMsg("标记成功!");
  1290. return;
  1291. }
  1292. returnErrorMsg("找不到记录");
  1293. }
  1294. }
  1295. public void upd_erp_ordertag_cancel()
  1296. {
  1297. if (UrlPostParmsCheck("ctid"))
  1298. {
  1299. string eid = GetPostString("ctid");
  1300. CeErpTradeCell entity = null;
  1301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1302. if (entity != null)
  1303. {
  1304. entity.wechatTag = 0;
  1305. entity.Update();
  1306. CeErpStayGoods pers = CeErpStayGoods.GetByCtid(entity.ctid);
  1307. if (pers != null)
  1308. {
  1309. pers.status = "取消推购";
  1310. pers.audit_type = 3;
  1311. pers.Update();
  1312. }
  1313. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1314. returnSuccessMsg("标记成功!");
  1315. return;
  1316. }
  1317. returnErrorMsg("找不到记录");
  1318. }
  1319. }
  1320. public void upd_erp_addweichattag()
  1321. {
  1322. if (UrlPostParmsCheck("ctid"))
  1323. {
  1324. ;
  1325. string eid = GetPostString("ctid");
  1326. CeErpTradeCell entity = null;
  1327. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1328. if (entity != null)
  1329. {
  1330. if (entity.IsAddWechat > 0)
  1331. {
  1332. returnErrorMsg("此单已经标记过了");
  1333. return;
  1334. }
  1335. 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);
  1336. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1337. if (dt.Rows.Count > 0)
  1338. {
  1339. entity.IsAddWechat = 2;
  1340. }
  1341. else
  1342. {
  1343. entity.IsAddWechat = 1;
  1344. }
  1345. entity.Update();
  1346. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1347. returnSuccessMsg("标记成功!");
  1348. return;
  1349. }
  1350. returnErrorMsg("找不到记录");
  1351. }
  1352. }
  1353. public void upd_erp_getmyorder()
  1354. {
  1355. if (UrlPostParmsCheck("ctid"))
  1356. {
  1357. string eid = GetPostString("ctid");
  1358. CeErpTradeCell entity = null;
  1359. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1360. CeErpTrade father = CeErpTrade.Get(entity.tid);
  1361. if (father.receiver_state.Contains("台湾") && string.IsNullOrEmpty(father.receiver_zip))
  1362. {
  1363. returnErrorMsg("台湾客户需填写身份证号!");
  1364. return;
  1365. }
  1366. if (commonHelper.isFarAddress(father.receiver_state) && father.delivery_paymant == 0)
  1367. {
  1368. returnErrorMsg("偏远地区需要填写物流费!");
  1369. return;
  1370. }
  1371. if (entity != null)
  1372. {
  1373. if (entity.ctid.IndexOf("C") != -1)
  1374. {
  1375. StringBuilder sql = new StringBuilder();
  1376. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1377. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1378. if (dt.Rows.Count > 0)
  1379. {
  1380. decimal total = 0;
  1381. foreach (DataRow dr in dt.Rows)
  1382. {
  1383. total += Convert.ToDecimal(dr["payment"]);
  1384. }
  1385. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1386. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1387. {
  1388. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1389. return;
  1390. }
  1391. }
  1392. }
  1393. if (entity.OrderState == -1)
  1394. {
  1395. returnErrorMsg("待审核订单无法领取!");
  1396. return;
  1397. }
  1398. entity.CustomerUserId = CurrentUser.UserID;
  1399. if (entity.OrderState < 2)
  1400. {
  1401. entity.OrderState = 2;
  1402. if (entity.ShopId != 0)
  1403. {
  1404. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1405. }
  1406. }
  1407. entity.UpdateTime = DateTime.Now;
  1408. entity.Update();
  1409. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1410. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1411. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  1412. {
  1413. dataHelper.api_orderBack(entity.ctid, "0", "");
  1414. }
  1415. returnSuccessMsg("领单成功!");
  1416. return;
  1417. }
  1418. returnErrorMsg("找不到记录");
  1419. }
  1420. }
  1421. public void getmyorder_from_init()
  1422. {
  1423. if (UrlPostParmsCheck("ctid"))
  1424. {
  1425. string eid = GetPostString("ctid");
  1426. CeErpTradeCell entity = null;
  1427. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1428. if (entity != null)
  1429. {
  1430. string sellerMemo = GetPostString("sellerMemo");
  1431. if (sellerMemo.Length > 0)
  1432. {
  1433. entity.seller_memo = sellerMemo;
  1434. }
  1435. string oterhMemo = GetPostString("otherMemo");
  1436. if (oterhMemo.Length > 0)
  1437. {
  1438. entity.OtherMemo = oterhMemo;
  1439. }
  1440. int urg = GetPostInt("urgency");
  1441. entity.IsUrgency = (urg == 1 ? true : false);
  1442. int wechat = GetPostInt("wechat");
  1443. int command = GetPostInt("command");
  1444. if (wechat == 1)
  1445. {
  1446. entity.wechatTag = 1;
  1447. }
  1448. if (command == 1)
  1449. {
  1450. entity.wechatTag = 2;
  1451. }
  1452. string pPro = GetPostString("pprofession");
  1453. if (pPro.Length > 0)
  1454. {
  1455. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1456. string spro = GetPostString("profession");
  1457. if (spro.Length > 0)
  1458. {
  1459. entity.ProfessionId = Convert.ToInt32(spro);
  1460. }
  1461. }
  1462. string proId = GetPostString("productId");
  1463. if (proId.Length > 0)
  1464. {
  1465. entity.ProductId = Convert.ToInt32(proId);
  1466. }
  1467. entity.Material = GetPostString("material");
  1468. entity.Craft = GetPostString("craft");
  1469. entity.CustomerUserId = CurrentUser.UserID;
  1470. if (entity.OrderState < 2)
  1471. {
  1472. entity.OrderState = 2;
  1473. if (entity.ShopId != 0)
  1474. {
  1475. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1476. }
  1477. }
  1478. entity.Update();
  1479. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1480. returnSuccessMsg("领单成功!");
  1481. return;
  1482. }
  1483. returnErrorMsg("找不到记录");
  1484. }
  1485. }
  1486. public void upd_erp_setrelationorder()
  1487. {
  1488. if (UrlPostParmsCheck("ctid"))
  1489. {
  1490. ;
  1491. string eid = GetPostString("ctid");
  1492. string ftid = GetPostString("ftid");
  1493. CeErpTradeCell entity = null;
  1494. CeErpTradeCell fentity = null;
  1495. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1496. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1497. if (fentity == null)
  1498. {
  1499. returnErrorMsg("找不到关联的主订单");
  1500. return;
  1501. }
  1502. if (entity != null)
  1503. {
  1504. if (entity.OrderState >= 5)
  1505. {
  1506. returnErrorMsg("本单已经设计完成无法关联");
  1507. return;
  1508. }
  1509. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1510. {
  1511. returnErrorMsg("线下单续审核后才能关联!");
  1512. return;
  1513. }
  1514. entity.ptid = ftid;
  1515. entity.OrderState = fentity.OrderState;
  1516. //entity.status = fentity.status;
  1517. entity.CustomerUserId = fentity.CustomerUserId;
  1518. entity.DesignUserId = fentity.DesignUserId;
  1519. entity.seller_memo = "补差价单:" + ftid;
  1520. entity.IsSample = 2;
  1521. entity.Update();
  1522. ApiVo apiVo = new ApiVo();
  1523. apiVo.orderNumber = ftid;
  1524. apiVo.payment = entity.payment;
  1525. apiVo.actionName = "repairDesign";
  1526. designHelper.API_WorkCore(apiVo);//repairDesign
  1527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1528. returnSuccessMsg("关联成功!");
  1529. return;
  1530. }
  1531. else
  1532. returnErrorMsg("找不到记录");
  1533. }
  1534. }
  1535. public void download_erp_neworder()
  1536. {
  1537. string seller = GetPostString("seller_nick");
  1538. string tid = GetPostString("tid");
  1539. if (seller.Length <= 0 || tid.Length <= 0)
  1540. {
  1541. returnErrorMsg("数据错误");
  1542. }
  1543. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1544. //{
  1545. // returnErrorMsg("找不到店铺Sessionkey");
  1546. //}
  1547. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1548. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1549. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1550. if (res.IndexOf("refOid") == -1)
  1551. {
  1552. returnErrorMsg("下载订单数据失败");
  1553. return;
  1554. }
  1555. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1556. returnSuccessMsg("下载完成");
  1557. //tmcHelper.createNewOrder(res);
  1558. //CeErpTrade entr = null;
  1559. //entr = CeErpTrade.Get(tid);
  1560. //if (entr != null)
  1561. //{
  1562. // returnSuccess("下载成功");
  1563. // //下载成功之后,Cell表生成对应的订单;
  1564. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1565. //}
  1566. //else
  1567. //{
  1568. // returnErrorMsg("下载失败或者创建订单失败");
  1569. //}
  1570. }
  1571. public void set_erp_atersale()
  1572. {
  1573. if (UrlPostParmsCheck("ctid"))
  1574. {
  1575. string eid = GetPostString("ctid");
  1576. string reason = GetPostString("AfterSaleReason");
  1577. CeErpTradeCell entity = null;
  1578. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1579. if (entity != null)
  1580. {
  1581. /*if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1582. {
  1583. returnErrorMsg("此订单已经在售后");
  1584. return;
  1585. }*/
  1586. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1587. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1588. entity.AfterSaleTime = DateTime.Now;
  1589. entity.HandleTime = null;
  1590. entity.Update();
  1591. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1592. returnSuccessMsg("转售后成功!");
  1593. return;
  1594. }
  1595. returnErrorMsg("找不到记录");
  1596. }
  1597. }
  1598. public void set_erp_withdraw()
  1599. {
  1600. if (UrlPostParmsCheck("ctid"))
  1601. {
  1602. try
  1603. {
  1604. string eid = GetPostString("ctid");//商品id
  1605. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1606. CeWithdraw ceWithdrawSelect = null;
  1607. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1608. if (ceWithdrawSelect != null)
  1609. {
  1610. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1611. {
  1612. ceWithdrawSelect.status = -1;
  1613. ceWithdrawSelect.Update();
  1614. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1615. returnSuccessMsg("重新发起审核成功");
  1616. return;
  1617. }
  1618. else
  1619. {
  1620. returnSuccessMsg("请勿重复申请!");
  1621. return;
  1622. }
  1623. }
  1624. else
  1625. {
  1626. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1627. if (string.IsNullOrEmpty(CustomerUserId))
  1628. {
  1629. CustomerUserId = "-1";
  1630. }
  1631. int Userid = CurrentUser.UserID;//用户id
  1632. CeWithdraw ceWithdraw = new CeWithdraw();
  1633. ceWithdraw.tid = eid;
  1634. ceWithdraw.userid = Userid;
  1635. ceWithdraw.providerid = CustomerUserId;
  1636. ceWithdraw.status = 3;
  1637. ceWithdraw.creationtime = DateTime.Now;
  1638. ceWithdraw.Create();
  1639. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1640. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1641. return;
  1642. }
  1643. }
  1644. catch
  1645. {
  1646. returnErrorMsg("申请撤回订单失败");
  1647. return;
  1648. }
  1649. }
  1650. }
  1651. public void ins_erp_billinfo()
  1652. {
  1653. if (UrlPostParmsCheck("ctid"))
  1654. {
  1655. string eid = GetPostString("ctid");
  1656. CeErpTradeCell entity = null;
  1657. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1658. if (entity != null)
  1659. {
  1660. CeErpBill bill = CeErpBill.GetByTid(eid);
  1661. bool isHave = false;
  1662. if (bill != null)
  1663. {
  1664. isHave = true;
  1665. if (bill.state != 4)
  1666. {
  1667. returnErrorMsg("此单已经申请过发票了");
  1668. return;
  1669. }
  1670. }
  1671. if (entity.IsNeedBill == 0)
  1672. {
  1673. entity.IsNeedBill = 1;
  1674. }
  1675. entity.Update();
  1676. string errjson = "";
  1677. try
  1678. {
  1679. CeErpBill bill_entity = new CeErpBill();
  1680. bill_entity.tid = entity.tid;
  1681. bill_entity.title = GetPostString("title");
  1682. string taxstr = GetPostString("tax");
  1683. taxstr = taxstr.Replace(" ", "");
  1684. bill_entity.tax = taxstr;
  1685. bill_entity.bank = GetPostString("bank");
  1686. string bankacstr = GetPostString("bankac");
  1687. bankacstr = bankacstr.Replace(" ", "");
  1688. bill_entity.bankac = bankacstr;
  1689. bill_entity.address = GetPostString("address");
  1690. bill_entity.phone = GetPostString("phone");
  1691. bill_entity.price = GetPostString("price");
  1692. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1693. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1694. {
  1695. billCount += 1;
  1696. }
  1697. string prebill = "ltb";
  1698. for (int idx = 1; idx <= billCount; idx++)
  1699. {
  1700. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1701. string billoid = prebill + idx + dtstr;
  1702. bill_entity.billOrderId += billoid;
  1703. if (idx < billCount)
  1704. {
  1705. bill_entity.billOrderId += ",";
  1706. }
  1707. }
  1708. bill_entity.productId = GetPostInt("ProductName");
  1709. bill_entity.num = GetPostInt("num");
  1710. bill_entity.unit = GetPostString("unit");
  1711. bill_entity.type = GetPostString("type");
  1712. bill_entity.sendType = GetPostString("SendType");
  1713. bill_entity.email = GetPostString("email");
  1714. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1715. bill_entity.shopName = GetPostString("ShopName");
  1716. bill_entity.applymemo = GetPostString("applyMemo");
  1717. bill_entity.createTime = DateTime.Now;
  1718. bill_entity.state = 0;
  1719. bill_entity.userId = CurrentUser.UserID;
  1720. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1721. bill_entity.Create();
  1722. }
  1723. catch (Exception ex)
  1724. {
  1725. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1726. returnErrorMsg("创建发票出错!");
  1727. return;
  1728. }
  1729. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1730. returnSuccessMsg("发票申请成功!");
  1731. return;
  1732. }
  1733. returnErrorMsg("找不到记录");
  1734. }
  1735. }
  1736. public void ins_erp_neworder()
  1737. {
  1738. if (UrlPostParmsCheck("receiver_name"))
  1739. {
  1740. CeErpTrade entity = new CeErpTrade();
  1741. string plat_form = GetPostString("platform");
  1742. string preStr = "N_";
  1743. if (plat_form == "拼多多")
  1744. {
  1745. preStr = "P_";
  1746. }
  1747. else if (plat_form == "阿里巴巴")
  1748. {
  1749. preStr = "A_";
  1750. }
  1751. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1752. entity.seller_nick = GetPostString("seller_nick");
  1753. entity.buyer_nick = GetPostString("buyer_nick");
  1754. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1755. entity.total_fee = entity.payment;
  1756. entity.pay_time = DateTime.Now;
  1757. entity.status = "NOT_SHIPPED";
  1758. entity.receiver_name = GetPostString("receiver_name");
  1759. entity.receiver_mobile = GetPostString("receiver_mobile");
  1760. entity.receiver_state = GetPostString("receiver_state");
  1761. entity.receiver_city = GetPostString("receiver_city");
  1762. entity.receiver_district = GetPostString("receiver_district");
  1763. entity.receiver_address = GetPostString("receiver_address");
  1764. if (entity.receiver_state == "" || entity.receiver_city == "")
  1765. {
  1766. returnErrorMsg("收件地址不能为空");
  1767. return;
  1768. }
  1769. int shopId = 0;
  1770. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1771. if (nShop != null)
  1772. {
  1773. shopId = nShop.ID;
  1774. }
  1775. if (shopId != 34 && entity.payment == 0)
  1776. {
  1777. returnErrorMsg("公司自用的单金额才能为0");
  1778. return;
  1779. }
  1780. entity.Create();
  1781. CeErpTradeCell entitycell = new CeErpTradeCell();
  1782. entitycell.ctid = entity.tid;
  1783. entitycell.tid = entity.tid;
  1784. entitycell.ShopId = shopId;
  1785. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1786. entitycell.OrderState = 0;
  1787. entitycell.pay_time = entity.pay_time;
  1788. entitycell.IsOffLineOrder = 1;
  1789. entitycell.Create();
  1790. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1791. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1792. return;
  1793. }
  1794. }
  1795. public void ins_erp_neworder2()
  1796. {
  1797. if (UrlPostParmsCheck("receiver_name"))
  1798. {
  1799. //string plat_form = GetPostString("platform");
  1800. string preStr = "X_";
  1801. string memo = GetPostString("memo");
  1802. string productId = GetPostString("productId");
  1803. string primg = GetPostString("proofimg");
  1804. string sellerNick = GetPostString("seller_nick");
  1805. string addFrom = GetPostString("addfrom");
  1806. if (addFrom == "1")
  1807. {
  1808. preStr = "N_";
  1809. }
  1810. int shopId = 0;
  1811. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1812. if (nShop != null)
  1813. {
  1814. shopId = nShop.ID;
  1815. }
  1816. else
  1817. {
  1818. returnErrorMsg("找不到对应店铺");
  1819. return;
  1820. }
  1821. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1822. {
  1823. returnErrorMsg("必须上传付款凭证");
  1824. return;
  1825. }
  1826. CeErpTrade entity = new CeErpTrade();
  1827. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1828. entity.seller_nick = sellerNick;
  1829. entity.buyer_nick = GetPostString("buyer_nick");
  1830. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1831. entity.total_fee = entity.payment;
  1832. entity.pay_time = DateTime.Now;
  1833. entity.status = "NOT_SHIPPED";
  1834. entity.receiver_name = GetPostString("receiver_name");
  1835. entity.receiver_mobile = GetPostString("receiver_mobile");
  1836. entity.receiver_state = GetPostString("receiver_state");
  1837. entity.receiver_city = GetPostString("receiver_city");
  1838. entity.receiver_district = GetPostString("receiver_district");
  1839. entity.receiver_address = GetPostString("receiver_address");
  1840. entity.seller_memo = memo;
  1841. entity.orderFrom = 20;
  1842. entity.orderType = 15;
  1843. if (entity.receiver_state == "" || entity.receiver_city == "")
  1844. {
  1845. returnErrorMsg("收件地址不能为空");
  1846. return;
  1847. }
  1848. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1849. {
  1850. returnErrorMsg("公司自用的单金额才能为0");
  1851. return;
  1852. }
  1853. entity.Create();
  1854. string toWhere = GetPostString("towhere");
  1855. string oldOrder = GetPostString("oldOrder");
  1856. CeErpTradeCell entitycell = new CeErpTradeCell();
  1857. entitycell.ctid = entity.tid;
  1858. //唯一标识
  1859. entitycell.OrderSn = entity.tid;
  1860. string orderSn = dataHelper.getSaleOrderSn();
  1861. if (orderSn != "")
  1862. {
  1863. entitycell.OrderSn = orderSn;
  1864. }
  1865. entitycell.tid = entity.tid;
  1866. //if (preStr == "X_")
  1867. //{
  1868. entitycell.IsOffLineOrder = 1;
  1869. if ("1".Equals(oldOrder))
  1870. {
  1871. entitycell.IsOldCustomer = 1;
  1872. }
  1873. //}
  1874. entitycell.CustomerUserId = CurrentUser.UserID;
  1875. entitycell.PayProofImg = primg;
  1876. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1877. entitycell.ProductId = Convert.ToInt32(productId);
  1878. entitycell.ShopId = shopId;
  1879. entitycell.UpdateTime = DateTime.Now;
  1880. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1881. if (entitycell.ProductId > 0)
  1882. {
  1883. CeErpProduct ceErpProduct = CeErpProduct.GetById(entitycell.ProductId);
  1884. if (ceErpProduct.CreateTime != null && DateTime.Compare(ceErpProduct.CreateTime, DateTime.Now.AddDays(-90)) > 0)
  1885. {
  1886. entitycell.NewProduct = 1;
  1887. }
  1888. }
  1889. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1890. {
  1891. entitycell.IsXianHuo = 1;
  1892. }
  1893. entitycell.pay_time = entity.pay_time;
  1894. if (toWhere == "1")
  1895. {
  1896. entitycell.OrderState = 2;
  1897. }
  1898. else
  1899. {
  1900. entitycell.OrderState = 6;
  1901. entitycell.FinishPlaceTime = entitycell.pay_time;
  1902. }
  1903. if (shopId == 94)
  1904. {
  1905. entitycell.OrderState = 4;
  1906. entitycell.WaitDesignTime = entitycell.pay_time;
  1907. entitycell.StartDesignTime = entitycell.pay_time;
  1908. entitycell.DesignUserId = 218;
  1909. }
  1910. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1911. {
  1912. entitycell.OrderState = -1;//修改12-5
  1913. CeWithdraw ceWithdraw = new CeWithdraw();
  1914. ceWithdraw.tid = entity.tid;
  1915. ceWithdraw.providerid = "-1";
  1916. ceWithdraw.status = -1;
  1917. ceWithdraw.creationtime = DateTime.Now;
  1918. ceWithdraw.userid = 4634;
  1919. ceWithdraw.Create();
  1920. }
  1921. entitycell.Create();
  1922. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1923. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1924. {
  1925. addPlaceRegist(entitycell, CurrentUser.UserID);
  1926. }
  1927. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1928. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1929. return;
  1930. }
  1931. }
  1932. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1933. {
  1934. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1935. entity.PlactTime = tradecell.pay_time;
  1936. entity.AddUserId = userid;
  1937. entity.FileName = tradecell.seller_memo;
  1938. entity.Supplier = 24;
  1939. entity.CreateTime = DateTime.Now;
  1940. entity.Did = tradecell.ctid;
  1941. entity.tid = tradecell.tid;
  1942. entity.splitTag = tradecell.SplitTag;
  1943. entity.CurState = "未完成";
  1944. entity.Create();
  1945. }
  1946. public void get_erp_offlinelist()
  1947. {
  1948. DataStruct dStruct = GetPostStruct();
  1949. List<string> lw = new List<string>();
  1950. string tid = GetPostString("ctid");
  1951. string date1 = GetPostString("date1");
  1952. string date2 = GetPostString("date2");
  1953. if (tid.Length > 0 || date1.Length > 0)
  1954. {
  1955. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1956. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1957. if (dw.Length > 0) lw.Add(dw);
  1958. }
  1959. else
  1960. {
  1961. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1962. }
  1963. string shopname = GetPostString("shopname");
  1964. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1965. string buyernick = GetPostString("buyer_nick");
  1966. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1967. string customer = GetPostString("customer");
  1968. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1969. string design = GetPostString("design");
  1970. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1971. string orderState = GetPostString("orderState");
  1972. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1973. string address = GetPostString("address");
  1974. 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));
  1975. string sellermemo = GetPostString("seller_memo");
  1976. if (sellermemo.Length > 0)
  1977. {
  1978. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1979. }
  1980. string price1 = GetPostString("price1");
  1981. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1982. string price2 = GetPostString("price2");
  1983. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1984. //if (PKey != "admin")
  1985. //{
  1986. // string usershop = CurrentUser.User.pemShop;
  1987. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1988. //}
  1989. //if (ex_psize > 0)
  1990. //{
  1991. dStruct.Order = "pay_time desc";
  1992. //}
  1993. //else
  1994. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1995. lw.Add(string.Format("IsOffLineOrder=1"));
  1996. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1997. DataTable dt = null;
  1998. dt = WebCache.GetData("view_erptradecell", dStruct);
  1999. writeGridDataTableJson(dStruct.TotalCount, dt);
  2000. }
  2001. public void get_erp_returncashrecord()
  2002. {
  2003. DataStruct dStruct = GetPostStruct();
  2004. List<string> lw = new List<string>();
  2005. string tid = GetPostString("ctid");
  2006. if (tid.Length > 0)
  2007. {
  2008. lw.Add(string.Format("tid like '%{0}%'", tid));
  2009. dStruct.Order = "id desc";
  2010. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2011. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  2012. //writeGridDataTableJson(dStruct.TotalCount, dt);
  2013. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2014. return;
  2015. }
  2016. returnErrorMsg("id数据错误!");
  2017. }
  2018. public void ins_erp_returncashrecord()
  2019. {
  2020. if (UrlPostParmsCheck("tid"))
  2021. {
  2022. string tid = GetPostString("tid");
  2023. string retype = GetPostString("type");
  2024. StringBuilder sql = new StringBuilder();
  2025. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  2026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2027. if (dt.Rows.Count > 0)
  2028. {
  2029. returnErrorMsg("相同返现类型记录已存在");
  2030. return;
  2031. }
  2032. CeErpReturnCash entity = new CeErpReturnCash();
  2033. entity.tid = tid;
  2034. entity.seller_nick = GetPostString("seller_nick");
  2035. string pment = GetPostString("payment");
  2036. if (pment.Length > 0)
  2037. {
  2038. entity.payment = Convert.ToDouble(pment);
  2039. }
  2040. entity.buyer_nick = GetPostString("buyer_nick");
  2041. entity.cashstate = 0;
  2042. entity.rtype = retype;
  2043. string rPrice = GetPostString("returnprice");
  2044. if (rPrice.Length > 0)
  2045. {
  2046. entity.returnprice = Convert.ToDouble(rPrice);
  2047. }
  2048. entity.created = DateTime.Now;
  2049. entity.con = GetPostString("con");
  2050. entity.img = GetPostString("img");
  2051. entity.applyuserid = CurrentUser.UserID;
  2052. entity.Create();
  2053. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  2054. returnSuccessMsg("操作成功!");
  2055. return;
  2056. }
  2057. }
  2058. public void set_erp_predelivery()
  2059. {
  2060. if (UrlPostParmsCheck("ctid"))
  2061. {
  2062. string eid = GetPostString("ctid");
  2063. CeErpTradeCell entity = null;
  2064. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2065. if (entity != null)
  2066. {
  2067. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  2068. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  2069. //{
  2070. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  2071. // return;
  2072. //}
  2073. entity.IsPreDelivery = 1;
  2074. entity.Update();
  2075. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2076. returnSuccessMsg("预发货成功!");
  2077. return;
  2078. //string shop = GetPostString("seller_nick");
  2079. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  2080. //string comName = GetPostString("comName");
  2081. //string comCode = GetPostString("comCode");
  2082. //string outSid = GetPostString("outSid");//运单号
  2083. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  2084. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  2085. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  2086. //string apires = "";
  2087. //if (deliveryType == "虚拟发货")
  2088. //{
  2089. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  2090. //}
  2091. //else
  2092. //{
  2093. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  2094. //}
  2095. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  2096. ////{
  2097. //if (apires.IndexOf("发货成功") != -1)
  2098. //{
  2099. // if (deliveryType != "虚拟发货")
  2100. // {
  2101. // //还要插入快递信息到 快递信息表
  2102. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  2103. // exinfo.tid = eid;
  2104. // exinfo.out_sid = outSid;
  2105. // exinfo.company_code = comCode;
  2106. // exinfo.company_name = comName;
  2107. // exinfo.delivery_memo = deliveryMemo;
  2108. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  2109. // exinfo.deliveryType = deliveryType;
  2110. // exinfo.Create();
  2111. // }
  2112. // returnSuccessMsg("发货成功!");
  2113. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  2114. //}
  2115. //else
  2116. //{
  2117. // returnErrorMsg("淘宝发货失败!!");
  2118. //}
  2119. //return;
  2120. }
  2121. returnErrorMsg("找不到订单记录");
  2122. }
  2123. }
  2124. public void get_erp_unusuallist()
  2125. {
  2126. DataStruct dStruct = GetPostStruct();
  2127. List<string> lw = new List<string>();
  2128. string tid = GetPostString("ctid");
  2129. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  2130. string shopname = GetPostString("shopname");
  2131. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2132. string buyernick = GetPostString("buyer_nick");
  2133. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2134. string ResponsibleMan = GetPostString("responsible");
  2135. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2136. string date1 = GetPostString("date1");
  2137. string date2 = GetPostString("date2");
  2138. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2139. if (dw.Length > 0) lw.Add(dw);
  2140. string price1 = GetPostString("price1");
  2141. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2142. string price2 = GetPostString("price2");
  2143. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2144. string orderState = GetPostString("orderState");
  2145. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2146. string sellermemo = GetPostString("seller_memo");
  2147. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2148. lw.Add(string.Format("UnusualTag > 0"));
  2149. lw.Add(string.Format("IsRefund<={0}", 1));
  2150. dStruct.Order = "pay_time desc";
  2151. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2152. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2153. writeGridDataTableJson(dStruct.TotalCount, dt);
  2154. }
  2155. public void set_erp_unusualtonomal()
  2156. {
  2157. if (UrlPostParmsCheck("ctid"))
  2158. {
  2159. string eid = GetPostString("ctid");
  2160. CeErpTradeCell entity = null;
  2161. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2162. if (entity != null)
  2163. {
  2164. entity.UnusualTag = -1;
  2165. entity.Update();
  2166. returnSuccessMsg("忽略成功!");
  2167. return;
  2168. }
  2169. returnErrorMsg("找不到记录");
  2170. }
  2171. }
  2172. public void ins_erp_unusualreason()
  2173. {
  2174. if (UrlPostParmsCheck("ctid"))
  2175. {
  2176. string eid = GetPostString("ctid");
  2177. CeErpTradeCell entity = null;
  2178. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2179. if (entity != null)
  2180. {
  2181. entity.MemoOpt = 4;
  2182. entity.UnusualCon = GetPostString("con");
  2183. entity.Update();
  2184. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  2185. if (trade != null)
  2186. {
  2187. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  2188. }
  2189. //查货是否超时
  2190. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  2191. if (ceErpTradeCellExtend == null)
  2192. {
  2193. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  2194. ceErpTradeCellExtend.ctid = entity.ctid;
  2195. }
  2196. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  2197. {
  2198. ceErpTradeCellExtend.CheckOut += 1;
  2199. }
  2200. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  2201. if (ceErpTradeCellExtend.ID > 0)
  2202. {
  2203. ceErpTradeCellExtend.Update();
  2204. }
  2205. else
  2206. {
  2207. ceErpTradeCellExtend.Create();
  2208. }
  2209. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  2210. returnSuccessMsg("操作成功!");
  2211. return;
  2212. }
  2213. returnErrorMsg("找不到记录");
  2214. }
  2215. }
  2216. public void upd_erp_sampleorder()
  2217. {
  2218. if (UrlPostParmsCheck("ctid"))
  2219. {
  2220. string eid = GetPostString("ctid");
  2221. string[] eArr = eid.Split(',');
  2222. if (eArr.Length > 1)
  2223. {
  2224. List<string> eLst = new List<string>();
  2225. for (int i = 0; i < eArr.Length; i++)
  2226. {
  2227. eLst.Add("'" + eArr[i] + "'");
  2228. }
  2229. eid = string.Join(",", eLst.ToArray());
  2230. }
  2231. else
  2232. {
  2233. eid = "'" + eid + "'";
  2234. }
  2235. StringBuilder sql = new StringBuilder();
  2236. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2237. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2238. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2239. if (dt.Rows.Count > 0)
  2240. {
  2241. string errmsg = "";
  2242. foreach (DataRow dr in dt.Rows)
  2243. {
  2244. StringBuilder sqlsb = new StringBuilder();
  2245. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2246. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2247. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2248. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2249. //string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2250. /*if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2251. {
  2252. continue;
  2253. }
  2254. else
  2255. {
  2256. string emsg = commonHelper.KeepChinese(apires);
  2257. errmsg += emsg;
  2258. }*/
  2259. }
  2260. if (errmsg.Length > 0)
  2261. {
  2262. returnErrorMsg(errmsg);
  2263. return;
  2264. }
  2265. returnSuccessMsg("操作成功");
  2266. return;
  2267. }
  2268. returnErrorMsg("找不到记录");
  2269. }
  2270. }
  2271. public void upd_erp_transcustomer()
  2272. {
  2273. if (UrlPostParmsCheck("ctid"))
  2274. {
  2275. string eid = GetPostString("ctid");
  2276. int userid = GetPostInt("CustomerUserId");
  2277. CeErpTradeCell entity = null;
  2278. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2279. if (entity != null)
  2280. {
  2281. //string[] mlist = entity.seller_memo.Split('-');
  2282. //string sql = "select * from view_erpuser where id=" + userid;
  2283. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2284. //if (dt != null && dt.Rows.Count > 0)
  2285. //{
  2286. // string nmemo = "";
  2287. // for(int i = 0; i < mlist.Length - 1; i++)
  2288. // {
  2289. // nmemo += mlist[i];
  2290. // nmemo += "-";
  2291. // }
  2292. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2293. // entity.seller_memo = nmemo;
  2294. //}
  2295. entity.CustomerUserId = userid;
  2296. entity.Update();
  2297. returnSuccessMsg("操作成功!");
  2298. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2299. return;
  2300. }
  2301. returnErrorMsg("找不到记录");
  2302. }
  2303. }
  2304. public void upd_erp_transdesigner()
  2305. {
  2306. if (UrlPostParmsCheck("ctid"))
  2307. {
  2308. string eids = GetPostString("ctid");
  2309. string[] ctidList = eids.Split(',');
  2310. int userid = GetPostInt("DesignUserId");
  2311. foreach (string ctid in ctidList)
  2312. {
  2313. CeErpTradeCell entity = null;
  2314. CeErpDesignerBill entitys = null;
  2315. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2316. entitys = CeErpDesignerBill.GetByTid(ctid);
  2317. if (entity != null)
  2318. {
  2319. if (entity.OrderState > 4)
  2320. {
  2321. continue;
  2322. }
  2323. //存在退款不能流转
  2324. if (entity.IsRefund > 0)
  2325. {
  2326. continue;
  2327. }
  2328. entity.DesignUserId = userid;
  2329. entity.WaitDesignTime = DateTime.Now;
  2330. entity.Update();
  2331. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2332. }
  2333. }
  2334. returnSuccessMsg("操作成功!");
  2335. }
  2336. }
  2337. public void upd_erp_distributedesigner()
  2338. {
  2339. if (UrlPostParmsCheck("ctid"))
  2340. {
  2341. string eid = GetPostString("ctid");
  2342. int userid = GetPostInt("DesignUserId");
  2343. string[] idlist = eid.Split(',');
  2344. if (idlist.Length <= 0)
  2345. {
  2346. returnErrorMsg("订单不能为空");
  2347. return;
  2348. }
  2349. foreach (string ctid in idlist)
  2350. {
  2351. CeErpTradeCell entity = null;
  2352. CeErpDesignerBill entitys = null;
  2353. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2354. else continue;
  2355. if (entity != null)
  2356. {
  2357. if (userid == 2125 || userid == 3542)
  2358. { }
  2359. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2360. {
  2361. returnErrorMsg("金额错误的订单无法指派");
  2362. return;
  2363. }
  2364. if (entity.OrderState >= 5)
  2365. {
  2366. returnErrorMsg("已经设计完成无法指派");
  2367. return;
  2368. }
  2369. if (entity.OrderState == -1)
  2370. {
  2371. returnErrorMsg("审核中的订单无法指派");
  2372. return;
  2373. }
  2374. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2375. {
  2376. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2377. return;
  2378. }
  2379. //157赖橙帆 159林晨 73 静之颖
  2380. 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)
  2381. {
  2382. returnErrorMsg("指派设计共创无法再次指派!");
  2383. return;
  2384. }
  2385. entity.OrderState = 3;
  2386. if (entity.SupplierId == 0)
  2387. {
  2388. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2389. entity.SupplierId = suid;
  2390. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2391. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2392. }
  2393. if (userid == 2125 && entity.seller_memo != "")
  2394. {
  2395. apiDesign.API_GetPrintData_CreateOrder(entity);
  2396. }
  2397. if (userid == 3542 && entity.seller_memo != "")
  2398. {
  2399. string userPost = CurrentUser.UserPost.Post.Code;
  2400. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, userPost);
  2401. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2402. if (response.msg != "设计共创:成功")
  2403. {
  2404. returnErrorMsg(response.msg);
  2405. return;
  2406. }
  2407. entity.DispatchSort = 2;
  2408. }
  2409. else
  2410. {
  2411. if (entity.DispatchSort == 2)
  2412. {
  2413. ApiVo apiVo = new ApiVo();
  2414. apiVo.actionName = "closeDesign";
  2415. apiVo.orderNumber = entity.ctid;
  2416. designHelper.API_WorkCore(apiVo);//closeDesign
  2417. }
  2418. entity.DispatchSort = 0;
  2419. }
  2420. entity.DesignUserId = userid;
  2421. entity.WaitDesignTime = DateTime.Now;
  2422. entity.UpdateTime = DateTime.Now;
  2423. entity.Update();
  2424. string name = commonHelper.getUserNameById(userid);
  2425. commonHelper.UpdateRelationOrder(entity.ctid);
  2426. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2427. }
  2428. }
  2429. returnSuccessMsg("操作成功!");
  2430. return;
  2431. }
  2432. }
  2433. public string getTidByCtid(string ctid)
  2434. {
  2435. string tid = "";
  2436. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2437. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2438. if (dataTable != null && dataTable.Rows.Count > 0)
  2439. {
  2440. tid = dataTable.Rows[0]["tid"].ToString();
  2441. }
  2442. return tid;
  2443. }
  2444. public List<string> getTidByCtidMore(string ctid)
  2445. {
  2446. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or tid = '{0}' or orderSn = '{0}' or ( ParentSplitNo = '{0}' and IsSample =2) or (ptid = '{0}' and IsSample =2 ))", ctid);
  2447. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2448. List<string> list = new List<string>();
  2449. if (dataTable != null && dataTable.Rows.Count > 0)
  2450. {
  2451. foreach (DataRow item in dataTable.Rows)
  2452. {
  2453. list.Add("'" + item["tid"].ToString() + "'");
  2454. }
  2455. }
  2456. return list;
  2457. }
  2458. public List<string> getTidByCtidLike(string ctid)
  2459. {
  2460. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid = '{0}' or orderSn = '{0}')", ctid);
  2461. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2462. List<string> list = new List<string>();
  2463. if (dataTable != null && dataTable.Rows.Count > 0)
  2464. {
  2465. foreach (DataRow item in dataTable.Rows)
  2466. {
  2467. list.Add("'" + item["tid"].ToString() + "'");
  2468. }
  2469. }
  2470. return list;
  2471. }
  2472. public List<string> getReceiverIdByCtidLike(List<string> tids)
  2473. {
  2474. string sql = string.Format("select receiverId from CE_ErpTrade where tid in ({0})", string.Join(",", tids));
  2475. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2476. List<string> list = new List<string>();
  2477. if (dataTable != null && dataTable.Rows.Count > 0)
  2478. {
  2479. foreach (DataRow item in dataTable.Rows)
  2480. {
  2481. if (string.IsNullOrEmpty(item["receiverId"].ToString()))
  2482. {
  2483. continue;
  2484. }
  2485. list.Add("'" + item["receiverId"].ToString() + "'");
  2486. }
  2487. }
  2488. return list;
  2489. }
  2490. public void get_erp_myorderlist()
  2491. {
  2492. DataStruct dStruct = GetPostStruct();
  2493. List<string> lw = new List<string>();
  2494. string tid = GetPostString("ctid");
  2495. if (tid.Length > 0)
  2496. {
  2497. string select_tid = getTidByCtid(tid);
  2498. lw.Add(string.Format("tid='{0}'", select_tid));
  2499. }
  2500. else
  2501. {
  2502. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2503. }
  2504. //12-1 修改
  2505. string urgent = GetPostString("urgent");
  2506. string back = GetPostString("back");
  2507. string offlineSearch = GetPostString("offlineSearch");
  2508. if (!string.IsNullOrWhiteSpace(urgent))
  2509. {
  2510. if (urgent.Equals("true"))
  2511. {
  2512. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2513. }
  2514. }
  2515. if (!string.IsNullOrWhiteSpace(back))
  2516. {
  2517. if (back.Equals("true"))
  2518. {
  2519. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2520. }
  2521. }
  2522. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2523. {
  2524. if (offlineSearch.Equals("true"))
  2525. {
  2526. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2527. }
  2528. }
  2529. //end
  2530. string shopname = GetPostString("shopname");
  2531. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2532. string buyernick = GetPostString("buyer_nick");
  2533. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2534. string design = GetPostString("design");
  2535. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2536. string orderState = GetPostString("orderState");
  2537. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2538. string sellermemo = GetPostString("seller_memo");
  2539. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2540. string date1 = GetPostString("date1");
  2541. string date2 = GetPostString("date2");
  2542. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2543. if (dw.Length > 0) lw.Add(dw);
  2544. string price1 = GetPostString("price1");
  2545. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2546. string price2 = GetPostString("price2");
  2547. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2548. string urgency = GetPostString("urgency");
  2549. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2550. string after = GetPostString("after");
  2551. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2552. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2553. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2554. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2555. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2556. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2557. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2558. if (dt != null && dt.Rows.Count > 0)
  2559. {
  2560. foreach (DataRow dr in dt.Rows)
  2561. {
  2562. try
  2563. {
  2564. // 对象操作
  2565. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2566. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2567. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2568. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2569. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2570. if (dStruct.PageSize != 100000)
  2571. {
  2572. if (dr["DispatchSort"].ToString() == "2")
  2573. {
  2574. dr["gongchuang"] = 200;
  2575. }
  2576. else if ("外协".Equals(dr["ToType"].ToString()))
  2577. {
  2578. dr["gongchuang"] = 200;
  2579. }
  2580. else if ("内部".Equals(dr["ToType"].ToString()))
  2581. {
  2582. dr["gongchuang"] = -1;
  2583. }
  2584. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2585. {
  2586. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2587. dr["gongchuang"] = response.code;
  2588. }
  2589. }
  2590. }
  2591. catch (NullReferenceException ex)
  2592. {
  2593. }
  2594. }
  2595. }
  2596. writeGridDataTableJson(dStruct.TotalCount, dt);
  2597. }
  2598. public void get_erp_myreturnorderlist()
  2599. {
  2600. DataStruct dStruct = GetPostStruct();
  2601. List<string> lw = new List<string>();
  2602. string tid = GetPostString("ctid");
  2603. if (tid.Length > 0)
  2604. {
  2605. string select_tid = getTidByCtid(tid);
  2606. lw.Add(string.Format("tid='{0}'", select_tid));
  2607. }
  2608. else
  2609. {
  2610. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2611. }
  2612. string shopname = GetPostString("shopname");
  2613. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2614. string buyernick = GetPostString("buyer_nick");
  2615. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2616. string design = GetPostString("design");
  2617. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2618. string orderState = GetPostString("orderState");
  2619. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2620. string sellermemo = GetPostString("seller_memo");
  2621. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2622. string date1 = GetPostString("date1");
  2623. string date2 = GetPostString("date2");
  2624. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2625. if (dw.Length > 0) lw.Add(dw);
  2626. string price1 = GetPostString("price1");
  2627. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2628. string price2 = GetPostString("price2");
  2629. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2630. if (CurrentUser.UserPost.Post.Code == "SysAdmin")
  2631. {
  2632. lw.Add(string.Format("CusOrgID = 94"));
  2633. }
  2634. else if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2635. {
  2636. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2637. }
  2638. else
  2639. {
  2640. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2641. }
  2642. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2643. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2644. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2645. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2646. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2647. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2648. if (dt != null && dt.Rows.Count > 0)
  2649. {
  2650. foreach (DataRow dr in dt.Rows)
  2651. {
  2652. try
  2653. {
  2654. // 对象操作
  2655. if (dStruct.PageSize != 100000)
  2656. {
  2657. if (dr["DispatchSort"].ToString() == "2")
  2658. {
  2659. dr["gongchuang"] = 200;
  2660. }
  2661. else if ("外协".Equals(dr["ToType"].ToString()))
  2662. {
  2663. dr["gongchuang"] = 200;
  2664. }
  2665. else if ("内部".Equals(dr["ToType"].ToString()))
  2666. {
  2667. dr["gongchuang"] = -1;
  2668. }
  2669. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(dr["seller_memo"].ToString()))
  2670. {
  2671. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2672. dr["gongchuang"] = response.code;
  2673. }
  2674. }
  2675. }
  2676. catch (NullReferenceException ex)
  2677. {
  2678. // 处理空引用异常
  2679. }
  2680. }
  2681. }
  2682. writeGridDataTableJson(dStruct.TotalCount, dt);
  2683. }
  2684. public void get_erp_myorderlist_pregather()
  2685. {
  2686. string date1 = GetPostString("date1");
  2687. string date2 = GetPostString("date2");
  2688. int userId = CurrentUser.UserID; //客服id
  2689. string orderWhere = "";
  2690. List<string> lw = new List<string>();
  2691. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2692. if (dw.Length > 0) lw.Add(dw);
  2693. lw.Add(string.Format("CustomerUserId={0}", userId));
  2694. lw.Add(string.Format("OrderState<9"));
  2695. orderWhere = string.Join(" and ", lw.ToArray());
  2696. string orderWhere2 = "";
  2697. List<string> lw2 = new List<string>();
  2698. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2699. if (dw2.Length > 0) lw2.Add(dw2);
  2700. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2701. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2702. string sql = string.Format("select *" +
  2703. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2704. "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 " +
  2705. "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 " +
  2706. "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");
  2707. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2708. //writeGridDataTableJson(dt.Rows.Count, dt);
  2709. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2710. }
  2711. public void upd_erp_publishorder()
  2712. {
  2713. if (UrlPostParmsCheck("ctid"))
  2714. {
  2715. string eid = GetPostString("ctid");
  2716. CeErpTradeCell entity = null;
  2717. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2718. if (entity != null)
  2719. {
  2720. entity.OrderState = 0; //发布后,变为待抢单
  2721. entity.Update();
  2722. commonHelper.UpdateRelationOrder(entity.ctid);
  2723. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2724. returnSuccessMsg("发布成功!");
  2725. return;
  2726. }
  2727. returnErrorMsg("找不到记录");
  2728. }
  2729. }
  2730. public void get_erp_my_tiporder()
  2731. {
  2732. StringBuilder sql = new StringBuilder();
  2733. int userId = 0;
  2734. if (CurrentUser != null) userId = CurrentUser.UserID;
  2735. string posCode = CurrentUser.UserPost.Post.Code;
  2736. string isTipedAfterSaleVerify = GetPostString("af");
  2737. DataTable dt = new DataTable();
  2738. if (posCode != "Supplier")
  2739. {
  2740. if (posCode == "CustomerService" || posCode == "Director")
  2741. {
  2742. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2743. }
  2744. else if (posCode == "Place" || posCode == "PlaceMr")
  2745. {
  2746. }
  2747. else
  2748. {
  2749. string teamIds = CurrentUser.User.TeamIds;
  2750. if (teamIds == "")
  2751. {
  2752. teamIds = "0";
  2753. }
  2754. 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);
  2755. }
  2756. if (sql.Length > 0)
  2757. {
  2758. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2759. }
  2760. }
  2761. if (dt.Rows.Count <= 0)
  2762. {
  2763. string key = "aftersale_order_" + userId;
  2764. if (RedisHelper.HasKey(key))
  2765. {
  2766. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2767. dt.Columns.Add("ctid", typeof(string));
  2768. dt.Columns.Add("IsReadTag", typeof(int));
  2769. foreach (var i in list)
  2770. {
  2771. DataRow data = dt.NewRow();
  2772. data["ctid"] = i;
  2773. data["IsReadTag"] = 4;
  2774. dt.Rows.Add(data);
  2775. }
  2776. RedisHelper.StringDelete(key);
  2777. }
  2778. }
  2779. if (dt.Rows.Count <= 0)
  2780. {
  2781. sql = new StringBuilder();
  2782. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2783. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2784. }
  2785. if (posCode == "Supplier")
  2786. {
  2787. string ids = CurrentUser.User.pemVend;
  2788. if (ids != null && ids.Length > 0)
  2789. {
  2790. string[] ids_list = ids.Split(',');
  2791. foreach (var item in ids_list)
  2792. {
  2793. string key = "return_order_" + item;
  2794. if (RedisHelper.HasKey(key))
  2795. {
  2796. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2797. dt.Columns.Add("ctid", typeof(string));
  2798. dt.Columns.Add("IsReadTag", typeof(int));
  2799. foreach (var i in list)
  2800. {
  2801. DataRow data = dt.NewRow();
  2802. data["ctid"] = i;
  2803. data["IsReadTag"] = 1;
  2804. dt.Rows.Add(data);
  2805. }
  2806. RedisHelper.StringDelete(key);
  2807. }
  2808. }
  2809. }
  2810. if (dt.Rows.Count <= 0)
  2811. {
  2812. sql = new StringBuilder();
  2813. 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);
  2814. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2815. }
  2816. }
  2817. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2818. }
  2819. public void reset_erp_tiporder()
  2820. {
  2821. string ids = GetPostString("ids");
  2822. string[] ctidList = ids.Split(',');
  2823. foreach (string ctid in ctidList)
  2824. {
  2825. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2826. if (enty != null)
  2827. {
  2828. enty.IsReadTag = 0;
  2829. enty.Update();
  2830. }
  2831. }
  2832. returnSuccessMsg("成功!");
  2833. return;
  2834. }
  2835. public void get_erp_designlist()
  2836. {
  2837. DataStruct dStruct = GetPostStruct();
  2838. List<string> lw = new List<string>();
  2839. string tid = GetPostString("ctid");
  2840. if (tid.Length > 0)
  2841. {
  2842. string select_tid = getTidByCtid(tid);
  2843. lw.Add(string.Format("tid='{0}'", select_tid));
  2844. }
  2845. string shopname = GetPostString("shopname");
  2846. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2847. string buyernick = GetPostString("buyer_nick");
  2848. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2849. string customer = GetPostString("customer");
  2850. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2851. string design = GetPostString("design");
  2852. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2853. string orderState = GetPostString("orderState");
  2854. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2855. lw.Add(string.Format("OrderState<6"));
  2856. string address = GetPostString("address");
  2857. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2858. string sellermemo = GetPostString("seller_memo");
  2859. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2860. string date1 = GetPostString("date1");
  2861. string date2 = GetPostString("date2");
  2862. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2863. if (dw.Length > 0) lw.Add(dw);
  2864. string apdate1 = GetPostString("apdate1");
  2865. string apdate2 = GetPostString("apdate2");
  2866. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2867. if (dwap.Length > 0) lw.Add(dwap);
  2868. string price1 = GetPostString("price1");
  2869. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2870. string price2 = GetPostString("price2");
  2871. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2872. string designTime = GetPostString("designtime");
  2873. if (designTime.Length > 0)
  2874. {
  2875. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2876. }
  2877. string usershop = CurrentUser.User.pemShop;
  2878. if (usershop.Length > 0)
  2879. {
  2880. lw.Add(string.Format("shopId in ({0})", usershop));
  2881. }
  2882. int myOrgid = CurrentUser.UserPost.OrgID;
  2883. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2884. if (myOrgCode.IndexOf("Designer") != -1)
  2885. {
  2886. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2887. {
  2888. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2889. }
  2890. else
  2891. {
  2892. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2893. }
  2894. }
  2895. else
  2896. {
  2897. string orgId = GetPostString("designerhd");
  2898. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2899. }
  2900. if (tid.Length > 0 || buyernick.Length > 0)
  2901. {
  2902. lw.Add(string.Format("OrderState >= 3"));
  2903. }
  2904. else
  2905. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2906. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2907. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2910. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2911. if (dt != null && dt.Rows.Count > 0)
  2912. {
  2913. foreach (DataRow dr in dt.Rows)
  2914. {
  2915. try
  2916. {
  2917. // 对象操作
  2918. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2919. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2920. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2921. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2922. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2923. if (dStruct.PageSize != 100000)
  2924. {
  2925. if (dr["DispatchSort"].ToString() == "2")
  2926. {
  2927. dr["gongchuang"] = 200;
  2928. }
  2929. else if ("外协".Equals(dr["ToType"].ToString()))
  2930. {
  2931. dr["gongchuang"] = 200;
  2932. }
  2933. else if ("内部".Equals(dr["ToType"].ToString()))
  2934. {
  2935. dr["gongchuang"] = -1;
  2936. }
  2937. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  2938. {
  2939. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  2940. dr["gongchuang"] = response.code;
  2941. }
  2942. }
  2943. }
  2944. catch (NullReferenceException ex)
  2945. {
  2946. }
  2947. }
  2948. }
  2949. writeGridDataTableJson(dStruct.TotalCount, dt);
  2950. }
  2951. public void get_erp_mydesignlist()
  2952. {
  2953. DataStruct dStruct = GetPostStruct();
  2954. List<string> lw = new List<string>();
  2955. string tid = GetPostString("ctid");
  2956. if (tid.Length > 0)
  2957. {
  2958. string select_tid = getTidByCtid(tid);
  2959. lw.Add(string.Format("tid='{0}'", select_tid));
  2960. }
  2961. string shopname = GetPostString("shopname");
  2962. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2963. string buyernick = GetPostString("buyer_nick");
  2964. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2965. string customer = GetPostString("customer");
  2966. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2967. string orderState = GetPostString("orderState");
  2968. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2969. //lw.Add(string.Format("OrderState<6"));
  2970. string date1 = GetPostString("date1");
  2971. string date2 = GetPostString("date2");
  2972. string dw = GetDateWhere("pay_time", date1, date2);
  2973. if (dw.Length > 0) lw.Add(dw);
  2974. string apdate1 = GetPostString("apdate1");
  2975. string apdate2 = GetPostString("apdate2");
  2976. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2977. if (dwap.Length > 0) lw.Add(dwap);
  2978. string price1 = GetPostString("price1");
  2979. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2980. string price2 = GetPostString("price2");
  2981. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2982. string olddownload = GetPostString("olddown");
  2983. if (olddownload == "1")
  2984. {
  2985. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2986. }
  2987. else if (olddownload == "2")
  2988. {
  2989. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2990. }
  2991. string sellermemo = GetPostString("seller_memo");
  2992. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2993. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2994. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2995. {
  2996. if (CurrentUser.User.TeamIds.Length > 0)
  2997. {
  2998. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2999. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3000. else
  3001. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  3002. }
  3003. else
  3004. {
  3005. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  3006. }
  3007. }
  3008. if (tid.Length <= 0)
  3009. {
  3010. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  3011. }
  3012. lw.Add(string.Format("IsReturn!=3"));
  3013. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  3014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3015. string teamids = CurrentUser.User.TeamIds.ToString();
  3016. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3017. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  3018. if (dt != null && dt.Rows.Count > 0)
  3019. {
  3020. foreach (DataRow dr in dt.Rows)
  3021. {
  3022. try
  3023. {
  3024. // 对象操作
  3025. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  3026. ceErpTradeCell.ctid = dr["ctid"].ToString();
  3027. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  3028. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  3029. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  3030. if (dStruct.PageSize != 100000)
  3031. {
  3032. if (dr["DispatchSort"].ToString() == "2")
  3033. {
  3034. dr["gongchuang"] = 200;
  3035. }
  3036. else if ("外协".Equals(dr["ToType"].ToString()))
  3037. {
  3038. dr["gongchuang"] = 200;
  3039. }
  3040. else if ("内部".Equals(dr["ToType"].ToString()))
  3041. {
  3042. dr["gongchuang"] = -1;
  3043. }
  3044. else if (Convert.ToInt16(dr["OrderState"]) < 4 && !string.IsNullOrEmpty(ceErpTradeCell.seller_memo))
  3045. {
  3046. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString(), dr["ctid"].ToString());
  3047. dr["gongchuang"] = response.code;
  3048. }
  3049. }
  3050. }
  3051. catch (NullReferenceException ex)
  3052. {
  3053. }
  3054. }
  3055. }
  3056. writeGridDataTableJson(dStruct.TotalCount, dt);
  3057. }
  3058. public void set_erp_startdesign()
  3059. {
  3060. if (UrlPostParmsCheck("ctid"))
  3061. {
  3062. string eid = GetPostString("ctid");
  3063. CeErpTradeCell entity = null;
  3064. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3065. if (entity != null)
  3066. {
  3067. if (entity.OrderState != 3)
  3068. {
  3069. returnErrorMsg("请刷新,订单已经设计了");
  3070. return;
  3071. }
  3072. entity.StartDesignTime = DateTime.Now;
  3073. entity.OrderState = 4;
  3074. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  3075. {
  3076. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3077. entity.SupplierId = suid;
  3078. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3079. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3080. }
  3081. entity.UpdateTime = DateTime.Now;
  3082. //entity.MakeSupplier = suname;
  3083. entity.Update();
  3084. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3085. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3086. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  3087. commonHelper.getCytPrice(entity);
  3088. returnSuccessMsg("操作成功!");
  3089. return;
  3090. }
  3091. returnErrorMsg("找不到记录");
  3092. }
  3093. }
  3094. public void ins_erp_designselfmemo()
  3095. {
  3096. if (UrlPostParmsCheck("ctid"))
  3097. {
  3098. string eid = GetPostString("ctid");
  3099. string con = GetPostString("con");
  3100. CeErpTradeCell entity = null;
  3101. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3102. if (entity != null)
  3103. {
  3104. entity.DesignSelfMemo = con;
  3105. entity.Update();
  3106. returnSuccessMsg("操作成功!");
  3107. return;
  3108. }
  3109. returnErrorMsg("找不到记录");
  3110. }
  3111. }
  3112. public void ins_erp_designprice()
  3113. {
  3114. if (UrlPostParmsCheck("ctid"))
  3115. {
  3116. string eid = GetPostString("ctid");
  3117. int uid = CurrentUser.UserID;
  3118. string userName = CurrentUser.UserName;
  3119. CeErpTradeCell entity = null;
  3120. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  3121. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3122. if (entitys == null)
  3123. {
  3124. entitys = new CeErpDesignerBill();
  3125. }
  3126. if (entity != null)
  3127. {
  3128. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  3129. //entity.Number = Convert.ToInt32(GetPostString("number"));
  3130. entity.StartDesignTime = DateTime.Now;
  3131. entity.OrderState = 4;
  3132. string suname = "";
  3133. if (entity.SupplierId == 0)
  3134. {
  3135. int sid = commonHelper.autoDistributeToSupplier(entity);
  3136. entity.SupplierId = sid;
  3137. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3138. }
  3139. entity.Update();
  3140. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  3141. if (ceErpUserPost != null)
  3142. {
  3143. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  3144. if (ceErpPost != null)
  3145. {
  3146. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  3147. {
  3148. entitys.tid = entity.ctid;
  3149. entitys.oid = entity.tid;
  3150. entitys.uid = uid;
  3151. entitys.userName = userName;
  3152. entitys.designerType = 1;
  3153. entitys.designerTypeText = "内部设计师";
  3154. entitys.price = Convert.ToDouble(GetPostString("price"));
  3155. entitys.designNum = GetPostInt("designNum");
  3156. entitys.modifyNum = GetPostInt("modifyNum");
  3157. entitys.designSize = GetPostString("designSize");
  3158. entitys.modifySize = GetPostString("modifySize");
  3159. if (CeErpDesignerBill.GetByTid("ctid") == null)
  3160. {
  3161. entitys.create_time = DateTime.Now;
  3162. entitys.create_u_id = uid;
  3163. entitys.create_u_name = userName;
  3164. entitys.Save();
  3165. }
  3166. else
  3167. {
  3168. entitys.update_time = DateTime.Now;
  3169. entitys.update_u_id = uid;
  3170. entitys.update_u_name = userName;
  3171. entitys.Update();
  3172. }
  3173. }
  3174. }
  3175. }
  3176. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  3177. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  3178. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  3179. if (suname != "")
  3180. {
  3181. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3182. }
  3183. commonHelper.getCytPrice(entity);
  3184. returnSuccessMsg("操作成功!");
  3185. return;
  3186. }
  3187. returnErrorMsg("找不到记录");
  3188. }
  3189. }
  3190. public void upload_erp_filecomplete()
  3191. {
  3192. if (UrlPostParmsCheck("ctid"))
  3193. {
  3194. string eid = GetPostString("ctid");
  3195. CeErpTradeCell entity = null;
  3196. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3197. if (entity != null)
  3198. {
  3199. entity.OrderState = 5; //设计完成
  3200. entity.Update();
  3201. returnSuccessMsg(eid + "上传成功,设计完成!");
  3202. return;
  3203. }
  3204. returnErrorMsg("找不到订单记录");
  3205. }
  3206. }
  3207. public void get_erp_designovertimelist()
  3208. {
  3209. DataStruct dStruct = GetPostStruct();
  3210. List<string> lw = new List<string>();
  3211. string tid = GetPostString("ctid");
  3212. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3213. string shopname = GetPostString("shopname");
  3214. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3215. string buyernick = GetPostString("buyer_nick");
  3216. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3217. string ResponsibleMan = GetPostString("responsible");
  3218. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  3219. string date1 = GetPostString("date1");
  3220. string date2 = GetPostString("date2");
  3221. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3222. if (dw.Length > 0) lw.Add(dw);
  3223. string price1 = GetPostString("price1");
  3224. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3225. string price2 = GetPostString("price2");
  3226. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3227. string orderState = GetPostString("orderState");
  3228. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3229. string sellermemo = GetPostString("seller_memo");
  3230. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3231. lw.Add(string.Format("UnusualTag=3"));
  3232. lw.Add(string.Format("IsRefund<={0}", 1));
  3233. dStruct.Order = "WaitDesignTime desc";
  3234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3235. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3236. writeGridDataTableJson(dStruct.TotalCount, dt);
  3237. }
  3238. //设计管理 获取抢单大厅列表
  3239. public void get_erp_grabinglist()
  3240. {
  3241. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  3242. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  3243. bool oldOrder = false;
  3244. if (org != null)
  3245. {
  3246. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  3247. }
  3248. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  3249. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  3250. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3251. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  3252. //先处理订单数据
  3253. if (dt.Rows.Count > 0)
  3254. {
  3255. Dictionary<string, int> design = null;
  3256. int count = 0;
  3257. foreach (DataRow row in dt.Rows)
  3258. {
  3259. if (map.ContainsKey(row["ShopId"].ToString()))
  3260. {
  3261. map.TryGetValue(row["ShopId"].ToString(), out design);
  3262. }
  3263. else
  3264. {
  3265. design = new Dictionary<string, int>();
  3266. }
  3267. if (design.ContainsKey(row["ProductId"].ToString()))
  3268. {
  3269. design.TryGetValue(row["ProductId"].ToString(), out count);
  3270. }
  3271. count++;
  3272. design[row["ProductId"].ToString()] = count;
  3273. map[row["ShopId"].ToString()] = design;
  3274. }
  3275. }
  3276. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  3277. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3278. //把店铺排序和技能排序分类
  3279. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  3280. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  3281. if (design_dt.Rows.Count > 0)
  3282. {
  3283. Dictionary<string, string> design = null;
  3284. List<string> shopIds = null;
  3285. foreach (DataRow row in design_dt.Rows)
  3286. {
  3287. if ("0".Equals(row["designId"].ToString()))
  3288. {
  3289. if (shop_orders.ContainsKey(row["orders"].ToString()))
  3290. {
  3291. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  3292. }
  3293. else
  3294. {
  3295. shopIds = new List<string>();
  3296. }
  3297. shopIds.Add(row["shopId"].ToString());
  3298. shop_orders[row["orders"].ToString()] = shopIds;
  3299. }
  3300. else
  3301. {
  3302. if (design_orders.ContainsKey(row["shopId"].ToString()))
  3303. {
  3304. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  3305. }
  3306. else
  3307. {
  3308. design = new Dictionary<string, string>();
  3309. }
  3310. design[row["orders"].ToString()] = row["designId"].ToString();
  3311. design_orders[row["shopId"].ToString()] = design;
  3312. }
  3313. }
  3314. //处理成key value后根据key排序
  3315. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3316. foreach (List<string> val in shop_orders.Values)
  3317. {
  3318. if (val != null)
  3319. {
  3320. foreach (string key in val)
  3321. {
  3322. if (design_orders.ContainsKey(key.ToString()))
  3323. {
  3324. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  3325. }
  3326. }
  3327. }
  3328. }
  3329. }
  3330. //校验哪个优先级有订单
  3331. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3332. foreach (string key in shop_orders.Keys)
  3333. {
  3334. List<string> ids = null;
  3335. shop_orders.TryGetValue(key, out ids);
  3336. //id为shopid
  3337. foreach (string id in ids)
  3338. {
  3339. Dictionary<string, int> list = null;
  3340. Dictionary<string, string> desing = null;
  3341. map.TryGetValue(id, out list);
  3342. design_orders.TryGetValue(id, out desing);
  3343. if (list != null && desing != null)
  3344. {
  3345. foreach (var item in desing)
  3346. {
  3347. int count = 0;
  3348. if (list.ContainsKey(item.Value))
  3349. {
  3350. list.TryGetValue(item.Value, out count);
  3351. if (count > 0)
  3352. {
  3353. designIds[id] = item.Value;
  3354. break;
  3355. }
  3356. }
  3357. }
  3358. }
  3359. }
  3360. if (designIds.Count > 0)
  3361. {
  3362. break;
  3363. }
  3364. }
  3365. DataTable table = new DataTable();
  3366. table.Columns.Add("tid", typeof(string));
  3367. table.Columns.Add("ctid", typeof(string));
  3368. table.Columns.Add("seller_nick", typeof(string));
  3369. table.Columns.Add("productName", typeof(string));
  3370. table.Columns.Add("pay_time", typeof(string));
  3371. table.Columns.Add("seller_memo", typeof(string));
  3372. if (designIds.Count > 0)
  3373. {
  3374. string shopId = "";
  3375. string productId = "";
  3376. foreach (var designInfo in designIds)
  3377. {
  3378. shopId = designInfo.Key;
  3379. productId = designInfo.Value;
  3380. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3381. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3382. if (dt.Rows.Count > 0)
  3383. {
  3384. foreach (DataRow row in dt.Rows)
  3385. {
  3386. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3387. {
  3388. DataRow data = table.NewRow();
  3389. data["ctid"] = row["ctid"].ToString();
  3390. data["tid"] = row["tid"].ToString();
  3391. data["seller_nick"] = ceErpShop.ShopName;
  3392. data["pay_time"] = row["pay_time"].ToString();
  3393. data["seller_memo"] = row["seller_memo"].ToString();
  3394. data["productName"] = ceErpProduct.PType;
  3395. table.Rows.Add(data);
  3396. }
  3397. }
  3398. }
  3399. }
  3400. }
  3401. writeGridDataTableJson(table.Rows.Count, table);
  3402. }
  3403. private object rushLockObject = new object();
  3404. public void set_erp_grabingorder()
  3405. {
  3406. if (UrlPostParmsCheck("ctid"))
  3407. {
  3408. int total = CurrentUser.User.Person.Total;
  3409. int userId = CurrentUser.User.ID;
  3410. int noFinish = CurrentUser.User.Person.NoFinish;
  3411. int finalization = CurrentUser.User.Person.Finalization;
  3412. string eids = GetPostString("ctid");
  3413. string key = "RushKey_" + userId;
  3414. int count = 0;
  3415. if (erpRedis.RedisHelper.KeyExists(key))
  3416. {
  3417. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3418. if (redisCount != null)
  3419. {
  3420. count = Convert.ToInt32(redisCount);
  3421. }
  3422. }
  3423. if (count >= total)
  3424. {
  3425. returnErrorMsg("半小时内已经抢" + total + "单");
  3426. return;
  3427. }
  3428. string[] ctidlist = eids.Split(',');
  3429. if (count + ctidlist.Length > total)
  3430. {
  3431. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3432. return;
  3433. }
  3434. int itag = 0;
  3435. lock (rushLockObject)
  3436. {
  3437. if (ctidlist.Length > 0)
  3438. {
  3439. string[] dtList = new string[ctidlist.Length];
  3440. for (int i = 0; i < ctidlist.Length; i++)
  3441. {
  3442. dtList[i] = "'" + ctidlist[i] + "'";
  3443. }
  3444. 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"));
  3445. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3446. if (dt_user.Rows.Count > 0)
  3447. {
  3448. int doing = 0;//未定稿
  3449. int finish = 0;//已完成
  3450. foreach (DataRow dr in dt_user.Rows)
  3451. {
  3452. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3453. {
  3454. doing++;
  3455. }
  3456. else
  3457. {
  3458. finish++;
  3459. }
  3460. }
  3461. if (doing >= noFinish)
  3462. {
  3463. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3464. return;
  3465. }
  3466. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3467. {
  3468. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3469. return;
  3470. }
  3471. }
  3472. //校验选择单子状态
  3473. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3474. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3475. if (dt.Rows.Count > 0)
  3476. {
  3477. List<string> list = new List<string>();
  3478. foreach (DataRow dr in dt.Rows)
  3479. {
  3480. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3481. {
  3482. list.Add(dr["ctid"].ToString());
  3483. }
  3484. }
  3485. if (list.Count > 0)
  3486. {
  3487. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3488. return;
  3489. }
  3490. }
  3491. foreach (string ctid in ctidlist)
  3492. {
  3493. CeErpTradeCell entity = null;
  3494. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3495. if (entity != null)
  3496. {
  3497. entity.OrderState = 3;
  3498. entity.DesignUserId = CurrentUser.UserID;
  3499. entity.WaitDesignTime = DateTime.Now;
  3500. entity.StartDesignTime = DateTime.Now;
  3501. entity.Update();
  3502. commonHelper.UpdateRelationOrder(entity.ctid);
  3503. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3504. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3505. itag++;
  3506. }
  3507. }
  3508. }
  3509. }
  3510. count += ctidlist.Length;
  3511. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3512. if (itag == 0)
  3513. returnErrorMsg("没有找到相关订单");
  3514. else
  3515. returnSuccessMsg("抢单成功!");
  3516. return;
  3517. }
  3518. }
  3519. public void get_erp_waitorderlist()
  3520. {
  3521. DataStruct dStruct = GetPostStruct();
  3522. List<string> lw = new List<string>();
  3523. string tid = GetPostString("ctid");
  3524. if (tid.Length > 0)
  3525. {
  3526. string select_tid = getTidByCtid(tid);
  3527. lw.Add(string.Format("tid='{0}'", select_tid));
  3528. }
  3529. string shopname = GetPostString("shopname");
  3530. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3531. string buyernick = GetPostString("buyer_nick");
  3532. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3533. string customer = GetPostString("customer");
  3534. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3535. string design = GetPostString("design");
  3536. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3537. string orderState = GetPostString("orderState");
  3538. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3539. string supplier = GetPostString("supplier");
  3540. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3541. string sellermemo = GetPostString("seller_memo");
  3542. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3543. string otherMemo = GetPostString("otherMemo");
  3544. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3545. string address = GetPostString("address");
  3546. 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));
  3547. string date1 = GetPostString("date1");
  3548. string date2 = GetPostString("date2");
  3549. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3550. if (dw.Length > 0) lw.Add(dw);
  3551. string price1 = GetPostString("price1");
  3552. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3553. string price2 = GetPostString("price2");
  3554. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3555. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3556. lw.Add(string.Format("IsSample != 2 "));
  3557. lw.Add(string.Format("OrderState = 5 "));
  3558. lw.Add(string.Format("IsRefund<={0}", 1));
  3559. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3560. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3561. string pagesize = GetPostString("pagesize");
  3562. if (pagesize != null)
  3563. {
  3564. dStruct.PageSize = 200;
  3565. }
  3566. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3567. List<string> tids = new List<string>();
  3568. if (dt != null)
  3569. {
  3570. dt.Columns.Add("compenPrice", typeof(double));
  3571. foreach (DataRow dr in dt.Rows)
  3572. {
  3573. if (Convert.IsDBNull(dr["compenPrice"]))
  3574. {
  3575. dr["compenPrice"] = 0;
  3576. }
  3577. tids.Add("'" + dr["tid"].ToString() + "'");
  3578. 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();
  3579. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3580. {
  3581. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3582. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3583. entity.SupplierId = suid;
  3584. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3585. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3586. entity.Update();
  3587. }
  3588. }
  3589. }
  3590. if (tids.Count > 0)
  3591. {
  3592. string sql = string.Format("select ptid,payment from CE_ErpTradeCell where ptid in (" + string.Join(",", tids) + ") and IsSample = 2");
  3593. DataTable dt_price = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3594. if (dt_price != null && dt_price.Rows.Count > 0)
  3595. {
  3596. foreach (DataRow dr in dt_price.Rows)
  3597. {
  3598. foreach (DataRow row in dt.Rows)
  3599. {
  3600. if (row["tid"].Equals(dr["ptid"]))
  3601. {
  3602. row["compenPrice"] = Convert.ToDouble(row["compenPrice"]) + Convert.ToDouble(dr["payment"]);
  3603. break;
  3604. }
  3605. }
  3606. }
  3607. }
  3608. }
  3609. writeGridDataTableJson(dStruct.TotalCount, dt);
  3610. }
  3611. public void get_erp_supplierwaitorderlist()
  3612. {
  3613. DataStruct dStruct = GetPostStruct();
  3614. List<string> lw = new List<string>();
  3615. string tid = GetPostString("ctid");
  3616. if (tid.Length > 0)
  3617. {
  3618. string select_tid = getTidByCtid(tid);
  3619. lw.Add(string.Format("tid='{0}'", select_tid));
  3620. }
  3621. string shopname = GetPostString("shopname");
  3622. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3623. string sellermemo = GetPostString("seller_memo");
  3624. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3625. string date1 = GetPostString("date1");
  3626. string date2 = GetPostString("date2");
  3627. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3628. if (dw.Length > 0) lw.Add(dw);
  3629. lw.Add(string.Format("OrderState = 5 "));
  3630. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3631. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3632. {
  3633. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3634. }
  3635. string supplier = GetPostString("supplier");
  3636. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3637. {
  3638. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3639. }
  3640. lw.Add(string.Format("IsRefund<={0}", 1));
  3641. dStruct.Order = "FinishDesignTime desc";
  3642. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3643. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3644. if (dt != null)
  3645. {
  3646. foreach (DataRow dr in dt.Rows)
  3647. {
  3648. 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();
  3649. }
  3650. }
  3651. writeGridDataTableJson(dStruct.TotalCount, dt);
  3652. }
  3653. public void upd_erp_verifytosupplier()
  3654. {
  3655. if (UrlPostParmsCheck("ctid"))
  3656. {
  3657. string eids = GetPostString("ctid");
  3658. CeErpTradeCell entity = null;
  3659. string[] eidsList = eids.Split(',');
  3660. if (eidsList.Length <= 0)
  3661. {
  3662. returnErrorMsg("订单号不能空");
  3663. return;
  3664. }
  3665. List<string> tLst = new List<string>();
  3666. foreach (string ctidstr in eidsList)
  3667. {
  3668. tLst.Add("'" + ctidstr + "'");
  3669. CeErpDataSendOrderInfo.createObject(ctidstr);
  3670. }
  3671. string needtids = string.Join(",", tLst.ToArray());
  3672. StringBuilder sql = new StringBuilder();
  3673. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3674. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
  3675. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3676. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3677. returnSuccessMsg("操作成功!");
  3678. return;
  3679. /**foreach (string ctidstr in eidsList)
  3680. {
  3681. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3682. if (entity != null)
  3683. {
  3684. if (entity.SupplierId == 0)
  3685. {
  3686. continue;
  3687. }
  3688. entity.IsVerifyToSupplier = true;
  3689. if (entity.IsReturn == 1) //1是供应商打回
  3690. {
  3691. entity.IsReturn = 0;
  3692. }
  3693. entity.FinishPlaceTime = DateTime.Now;
  3694. entity.PlaceUserId = CurrentUser.UserID;
  3695. entity.Update();
  3696. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3697. }
  3698. }
  3699. returnSuccessMsg("操作成功!");
  3700. return;**/
  3701. }
  3702. }
  3703. public void upd_erp_supplierback()
  3704. {
  3705. if (UrlPostParmsCheck("ctid"))
  3706. {
  3707. string eid = GetPostString("ctid");
  3708. string reason = GetPostString("returnreason");
  3709. CeErpTradeCell entity = null;
  3710. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3711. if (entity != null)
  3712. {
  3713. string message = "操作成功!";
  3714. string isDown = "";
  3715. if (entity.OrderState == 6 || entity.IsHaveNewOrder == 2)
  3716. {
  3717. message = "订单有被点击下载。请注意沟通是否已下载完!";
  3718. isDown = "被点击下载";
  3719. }
  3720. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3721. {
  3722. string key = "return_order_" + entity.SupplierId;
  3723. List<string> list = new List<string>();
  3724. if (RedisHelper.HasKey(key))
  3725. {
  3726. object data = RedisHelper.StringGet(key);
  3727. list = Convert.ToString(data).Split(',').ToList();
  3728. }
  3729. list.Add(eid);
  3730. RedisHelper.StringSet(key, string.Join(",", list));
  3731. }
  3732. entity.IsVerifyToSupplier = false;
  3733. entity.IsReturn = 1;
  3734. entity.IsHaveNewOrder = 0;
  3735. entity.ReturnTime = DateTime.Now;
  3736. entity.ReturnReason = reason;
  3737. if (entity.OrderState == 6)
  3738. {
  3739. entity.OrderState = 5;
  3740. }
  3741. entity.Update();
  3742. CeErpSukuraData.createInfo(entity.ctid, 5);
  3743. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason + "-" + isDown, entity.OrderState);
  3744. returnSuccessMsg(message);
  3745. return;
  3746. }
  3747. returnErrorMsg("找不到订单记录");
  3748. }
  3749. }
  3750. public void upd_erp_toaftersaleorder()
  3751. {
  3752. if (UrlPostParmsCheck("ctid"))
  3753. {
  3754. string eid = GetPostString("ctid");
  3755. string reason = GetPostString("returnreason");
  3756. CeErpTradeCell entity = null;
  3757. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3758. if (entity != null)
  3759. {
  3760. if (entity.isAfterSaleOrder != 1)
  3761. {
  3762. returnErrorMsg("带S的售后单才能打回给售后");
  3763. return;
  3764. }
  3765. if (entity.OrderState >= 5)
  3766. {
  3767. returnErrorMsg("已经设计完成了不能打回给售后");
  3768. return;
  3769. }
  3770. entity.OrderState = 0;
  3771. entity.IsReturn = 3;
  3772. entity.ReturnTime = DateTime.Now;
  3773. entity.UpdateTime = DateTime.Now;
  3774. entity.ReturnReason = reason;
  3775. entity.Update();
  3776. CeErpSukuraData.createInfo(entity.ctid, 5);
  3777. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3778. returnSuccessMsg("操作成功!");
  3779. return;
  3780. }
  3781. returnErrorMsg("找不到订单记录");
  3782. }
  3783. }
  3784. public void upd_erp_aftersaletodesign()
  3785. {
  3786. if (UrlPostParmsCheck("ctid"))
  3787. {
  3788. string eid = GetPostString("ctid");
  3789. CeErpTradeCell entity = null;
  3790. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3791. if (entity != null)
  3792. {
  3793. entity.OrderState = 3;
  3794. entity.IsReturn = 0;
  3795. entity.UpdateTime = DateTime.Now;
  3796. entity.Update();
  3797. CeErpSukuraData.createInfo(entity.ctid, 5);
  3798. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3799. returnSuccessMsg("操作成功!");
  3800. return;
  3801. }
  3802. returnErrorMsg("找不到订单记录");
  3803. }
  3804. }
  3805. public void assign_erp_supplier()
  3806. {
  3807. if (UrlPostParmsCheck("ctid"))
  3808. {
  3809. string eids = GetPostString("ctid");
  3810. int sid = GetPostInt("SupplierName");
  3811. string fromTag = GetPostString("tag");
  3812. string[] eidList = eids.Split(',');
  3813. if (eidList.Length <= 0)
  3814. {
  3815. returnErrorMsg("指派不能为空");
  3816. return;
  3817. }
  3818. string errMsg = "";
  3819. string suname = commonHelper.getSupplierNameById(sid);
  3820. foreach (string ctid in eidList)
  3821. {
  3822. CeErpTradeCell entity = null;
  3823. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3824. if (entity != null)
  3825. {
  3826. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3827. {
  3828. errMsg += (ctid + "指派失败!!!");
  3829. continue;
  3830. }
  3831. entity.SupplierId = sid;
  3832. entity.Update();
  3833. commonHelper.UpdateRelationOrder(entity.ctid);
  3834. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3835. if (entity.OrderState >= 6)
  3836. {
  3837. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3838. //{
  3839. // string msl = entity.MakeSupplier;
  3840. // string[] mslist = msl.Split(',');
  3841. // 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);
  3842. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3843. //}
  3844. //else
  3845. //{
  3846. StringBuilder sql = new StringBuilder();
  3847. 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);
  3848. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3849. //}
  3850. }
  3851. }
  3852. else
  3853. {
  3854. continue;
  3855. }
  3856. }
  3857. if (errMsg.Length > 0)
  3858. {
  3859. returnErrorMsg(errMsg);
  3860. return;
  3861. }
  3862. returnSuccessMsg("操作成功!");
  3863. return;
  3864. }
  3865. }
  3866. public void assign_erp_makesupplier()
  3867. {
  3868. if (UrlPostParmsCheck("ctid"))
  3869. {
  3870. string eids = GetPostString("ctid");
  3871. string sname = GetPostString("SupplierName");
  3872. string[] eidList = eids.Split(',');
  3873. if (eidList.Length <= 0)
  3874. {
  3875. returnErrorMsg("指派不能为空");
  3876. return;
  3877. }
  3878. List<string> tLst = new List<string>();
  3879. foreach (string ctid in eidList)
  3880. {
  3881. CeErpTradeCell entity = null;
  3882. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3883. if (entity != null)
  3884. {
  3885. entity.MakeSupplier = sname;
  3886. entity.Update();
  3887. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3888. tLst.Add("'" + ctid + "'");
  3889. }
  3890. else
  3891. {
  3892. continue;
  3893. }
  3894. }
  3895. string ctids = string.Join(",", tLst.ToArray());
  3896. StringBuilder sql2 = new StringBuilder();
  3897. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3898. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3899. returnSuccessMsg("操作成功!");
  3900. return;
  3901. }
  3902. }
  3903. public void ins_erp_returnreason()
  3904. {
  3905. if (UrlPostParmsCheck("ctid"))
  3906. {
  3907. string eid = GetPostString("ctid");
  3908. CeErpTradeCell entity = null;
  3909. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3910. string userpost = CurrentUser.UserPost.Post.Code;
  3911. if (entity != null)
  3912. {
  3913. bool isPlace = false;
  3914. if (entity.OrderState > 6)
  3915. {
  3916. returnErrorMsg("已发货无法打回!");
  3917. return;
  3918. }
  3919. if (entity.OrderState == 6)
  3920. {
  3921. isPlace = true;
  3922. }
  3923. bool isNeedUpdateCell2 = false;
  3924. if (entity.OrderState >= 6)
  3925. {
  3926. isNeedUpdateCell2 = true;
  3927. }
  3928. int returnTag = 2;
  3929. if (userpost == "Supplier")
  3930. {
  3931. returnTag = 1;
  3932. }
  3933. int toType = GetPostInt("totype");
  3934. string fromType = "3";
  3935. if (entity.OrderState < 5)
  3936. {
  3937. fromType = "3";
  3938. }
  3939. else
  3940. {
  3941. fromType = "4";
  3942. }
  3943. if (entity.IsXianHuo == 0)
  3944. {
  3945. if (returnTag == 2)
  3946. {
  3947. if (toType == 1)
  3948. {
  3949. entity.OrderState = 0;
  3950. entity.ReturnUserType = 1;
  3951. string clearman = GetPostString("clearman");
  3952. if (!string.IsNullOrEmpty(clearman))
  3953. {
  3954. entity.DesignUserId = 0;
  3955. }
  3956. }
  3957. else
  3958. {
  3959. entity.OrderState = 3;
  3960. entity.ReturnUserType = 2;
  3961. }
  3962. entity.IsReadTag = 1;
  3963. }
  3964. else if (returnTag == 1)
  3965. {
  3966. entity.OrderState = 5;
  3967. }
  3968. entity.IsVerifyToSupplier = false;
  3969. }
  3970. if (entity.IsXianHuo == 1)
  3971. {
  3972. entity.OrderState = 5;
  3973. }
  3974. entity.UnusualTag = 0;
  3975. entity.UnusualTime = null;
  3976. entity.UnusualCon = "";
  3977. entity.IsReturn = returnTag;
  3978. entity.ReturnTime = DateTime.Now;
  3979. entity.UpdateTime = DateTime.Now;
  3980. entity.ReturnReason = GetPostString("returnreason");
  3981. entity.Update();
  3982. if (entity.OrderState == 3)
  3983. {
  3984. ApiVo apiVo = new ApiVo();
  3985. apiVo.orderNumber = entity.ctid;
  3986. apiVo.actionName = "rebutDesign";
  3987. apiVo.orderRemarks = entity.ReturnReason;
  3988. designHelper.API_WorkCore(apiVo);//rebutDesign
  3989. }
  3990. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3991. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3992. {
  3993. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3994. }
  3995. CeErpSukuraData.createInfo(entity.ctid, 5);
  3996. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3997. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3998. if (isPlace)
  3999. {
  4000. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  4001. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4002. if (dth != null && dth.Rows.Count > 0)
  4003. {
  4004. dataSendOrderBean dataSendOrderBean = null;
  4005. foreach (DataRow item in dth.Rows)
  4006. {
  4007. try
  4008. {
  4009. dataSendOrderBean = new dataSendOrderBean();
  4010. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  4011. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  4012. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  4013. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  4014. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  4015. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  4016. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  4017. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  4018. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  4019. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  4020. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  4021. dataSendOrderBean.Radio1723534706288 = "打回";
  4022. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  4023. if (result != null)
  4024. {
  4025. if ("0".Equals(result.errcode))
  4026. {
  4027. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  4028. }
  4029. else
  4030. {
  4031. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  4032. }
  4033. }
  4034. }
  4035. catch (Exception ex)
  4036. {
  4037. }
  4038. }
  4039. }
  4040. }
  4041. if (isNeedUpdateCell2)
  4042. {
  4043. if (entity.MakeSupplier.IndexOf(",") != -1)
  4044. {
  4045. StringBuilder sql2 = new StringBuilder();
  4046. 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);
  4047. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4048. }
  4049. else
  4050. {
  4051. StringBuilder sql2 = new StringBuilder();
  4052. 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);
  4053. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4054. }
  4055. }
  4056. returnSuccessMsg("操作成功!");
  4057. return;
  4058. }
  4059. returnErrorMsg("找不到订单记录");
  4060. }
  4061. }
  4062. public void cyt_erp_returnreason()
  4063. {
  4064. if (UrlPostParmsCheck("ctid"))
  4065. {
  4066. string eid = GetPostString("ctid");
  4067. CeErpTradeCell entity = null;
  4068. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4069. string userpost = CurrentUser.UserPost.Post.Code;
  4070. if (entity != null)
  4071. {
  4072. if (entity.OrderState > 6)
  4073. {
  4074. returnErrorMsg("已发货无法打回!");
  4075. return;
  4076. }
  4077. JObject jsonObject = new JObject
  4078. {
  4079. { "Userid", "77886" },
  4080. { "Pwd", "lt666888" },
  4081. { "LTOrderId",eid }
  4082. };
  4083. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  4084. JObject jsonObjects = JObject.Parse(response);
  4085. string msg = (string)jsonObjects["msg"];
  4086. if (msg != "取消成功")
  4087. {
  4088. returnErrorMsg(msg);
  4089. return;
  4090. }
  4091. bool isNeedUpdateCell2 = false;
  4092. if (entity.OrderState >= 6)
  4093. {
  4094. isNeedUpdateCell2 = true;
  4095. }
  4096. int returnTag = 2;
  4097. if (userpost == "Supplier")
  4098. {
  4099. returnTag = 1;
  4100. }
  4101. if (entity.IsXianHuo == 0)
  4102. {
  4103. if (returnTag == 2)
  4104. {
  4105. int toType = GetPostInt("totype");
  4106. if (toType == 1)
  4107. {
  4108. entity.OrderState = 0;
  4109. entity.ReturnUserType = 1;
  4110. }
  4111. else
  4112. {
  4113. entity.OrderState = 4;
  4114. entity.ReturnUserType = 2;
  4115. }
  4116. entity.IsReadTag = 1;
  4117. }
  4118. else if (returnTag == 1)
  4119. {
  4120. entity.OrderState = 5;
  4121. }
  4122. entity.IsVerifyToSupplier = false;
  4123. }
  4124. entity.UnusualTag = 0;
  4125. entity.UnusualTime = null;
  4126. entity.UnusualCon = "";
  4127. entity.IsReturn = returnTag;
  4128. entity.ReturnTime = DateTime.Now;
  4129. entity.ReturnReason = GetPostString("returnreason");
  4130. entity.Update();
  4131. if (entity.OrderState == 4)
  4132. {
  4133. ApiVo apiVo = new ApiVo();
  4134. apiVo.orderNumber = entity.ctid;
  4135. apiVo.actionName = "rebutDesign";
  4136. apiVo.orderRemarks = entity.ReturnReason;
  4137. designHelper.API_WorkCore(apiVo);//rebutDesign
  4138. }
  4139. CeErpSukuraData.createInfo(entity.ctid, 5);
  4140. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  4141. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  4142. if (isNeedUpdateCell2)
  4143. {
  4144. if (entity.MakeSupplier.IndexOf(",") != -1)
  4145. {
  4146. StringBuilder sql2 = new StringBuilder();
  4147. 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);
  4148. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4149. }
  4150. else
  4151. {
  4152. StringBuilder sql2 = new StringBuilder();
  4153. 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);
  4154. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  4155. }
  4156. }
  4157. returnSuccessMsg("操作成功!");
  4158. return;
  4159. }
  4160. returnErrorMsg("找不到订单记录");
  4161. }
  4162. }
  4163. public void upd_erp_xianhuoreturntag()
  4164. {
  4165. if (UrlPostParmsCheck("ctid"))
  4166. {
  4167. string eids = GetPostString("ctid");
  4168. string[] ctids = eids.Split(',');
  4169. foreach (string ctid in ctids)
  4170. {
  4171. CeErpTradeCell entity = null;
  4172. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4173. if (entity != null)
  4174. {
  4175. entity.IsReturn = 0;
  4176. entity.Update();
  4177. CeErpSukuraData.createInfo(entity.ctid, 5);
  4178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  4179. }
  4180. }
  4181. returnSuccessMsg("操作成功!");
  4182. return;
  4183. }
  4184. }
  4185. public void get_erp_waitdeliverylist()
  4186. {
  4187. DataStruct dStruct = GetPostStruct();
  4188. List<string> lw = new List<string>();
  4189. string tid = GetPostString("ctid");
  4190. if (tid.Length > 0)
  4191. {
  4192. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4193. if (tid.Length > 5)
  4194. {
  4195. List<string> tids = getTidByCtidLike(tid);
  4196. if (tids.Count > 0 && tids.Count < 10)
  4197. {
  4198. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4199. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4200. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4201. {
  4202. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4203. }*/
  4204. }
  4205. }
  4206. lw.Add(tid_sql);
  4207. }
  4208. string shopname = GetPostString("shopname");
  4209. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4210. string buyernick = GetPostString("buyer_nick");
  4211. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4212. //if (tid.Length == 0 && buyernick.Length == 0)
  4213. //{
  4214. // lw.Add(string.Format("IsRefund<={0}", 1));
  4215. //}
  4216. string customer = GetPostString("customer");
  4217. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4218. string design = GetPostString("design");
  4219. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4220. string orderState = GetPostString("orderState");
  4221. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4222. string address = GetPostString("address");
  4223. 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));
  4224. string sellermemo = GetPostString("seller_memo");
  4225. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4226. string supplier = GetPostString("supplier");
  4227. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4228. string OrderArea = GetPostString("order_area");
  4229. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4230. string placedate1 = GetPostString("placedate1");
  4231. string placedate2 = GetPostString("placedate2");
  4232. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4233. if (fdw.Length > 0) lw.Add(fdw);
  4234. string price1 = GetPostString("price1");
  4235. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4236. string price2 = GetPostString("price2");
  4237. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4238. string unusualCon = GetPostString("unusualcon");
  4239. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4240. string otherMemo = GetPostString("otherMemo");
  4241. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4242. string posTag = CurrentUser.UserPost.Post.Code;
  4243. if (posTag == "Supplier")
  4244. {
  4245. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4246. }
  4247. else
  4248. {
  4249. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4250. {
  4251. string usershop = CurrentUser.User.pemShop;
  4252. lw.Add(string.Format("ShopId in ({0})", usershop));
  4253. }
  4254. }
  4255. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4256. lw.Add(string.Format("type != 'PDD' "));
  4257. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4258. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4259. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4260. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4261. writeGridDataTableJson(dStruct.TotalCount, dt);
  4262. }
  4263. public void get_erp_changedeliverylist()
  4264. {
  4265. DataStruct dStruct = GetPostStruct();
  4266. List<string> lw = new List<string>();
  4267. string tid = GetPostString("ctid");
  4268. if (tid.Length > 0)
  4269. {
  4270. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4271. if (tid.Length > 5)
  4272. {
  4273. List<string> tids = getTidByCtidLike(tid);
  4274. if (tids.Count > 0 && tids.Count < 10)
  4275. {
  4276. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4277. }
  4278. }
  4279. lw.Add(tid_sql);
  4280. }
  4281. string shopname = GetPostString("shopname");
  4282. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4283. string buyernick = GetPostString("buyer_nick");
  4284. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4285. //if (tid.Length == 0 && buyernick.Length == 0)
  4286. //{
  4287. // lw.Add(string.Format("IsRefund<={0}", 1));
  4288. //}
  4289. string customer = GetPostString("customer");
  4290. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4291. string design = GetPostString("design");
  4292. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4293. string orderState = GetPostString("orderState");
  4294. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4295. string address = GetPostString("address");
  4296. 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));
  4297. string sellermemo = GetPostString("seller_memo");
  4298. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4299. string supplier = GetPostString("supplier");
  4300. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4301. string OrderArea = GetPostString("order_area");
  4302. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4303. string placedate1 = GetPostString("placedate1");
  4304. string placedate2 = GetPostString("placedate2");
  4305. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4306. if (fdw.Length > 0) lw.Add(fdw);
  4307. string price1 = GetPostString("price1");
  4308. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4309. string price2 = GetPostString("price2");
  4310. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4311. string unusualCon = GetPostString("unusualcon");
  4312. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4313. string otherMemo = GetPostString("otherMemo");
  4314. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  4315. string posTag = CurrentUser.UserPost.Post.Code;
  4316. if (posTag == "Supplier")
  4317. {
  4318. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4319. }
  4320. else
  4321. {
  4322. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4323. {
  4324. string usershop = CurrentUser.User.pemShop;
  4325. lw.Add(string.Format("ShopId in ({0})", usershop));
  4326. }
  4327. }
  4328. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  4329. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4330. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4331. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4332. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4333. /*if (tid.Length > 0)
  4334. {
  4335. List<string> tids = new List<string>();
  4336. if (dt != null && dt.Rows.Count > 0)
  4337. {
  4338. foreach (DataRow item in dt.Rows)
  4339. {
  4340. tids.Add("'" + item["tid"] + "'");
  4341. }
  4342. }
  4343. if (tids.Count > 0)
  4344. {
  4345. lw.RemoveAt(0);
  4346. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4347. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4348. dt = WebCache.GetData("view_erptradecell", dStruct);
  4349. }
  4350. }*/
  4351. writeGridDataTableJson(dStruct.TotalCount, dt);
  4352. }
  4353. public void get_erp_pddderiving()
  4354. {
  4355. DataStruct dStruct = GetPostStruct();
  4356. List<string> lw = new List<string>();
  4357. string tid = GetPostString("ctid");
  4358. if (tid.Length > 0)
  4359. {
  4360. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4361. if (tid.Length > 5)
  4362. {
  4363. List<string> tids = getTidByCtidLike(tid);
  4364. if (tids.Count > 0 && tids.Count < 10)
  4365. {
  4366. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4367. /* List<string> receiverIds = getReceiverIdByCtidLike(tids);
  4368. if (receiverIds.Count > 0 && receiverIds.Count < 10)
  4369. {
  4370. tid_sql = string.Format("(tid in ({0}) or receiverId in ({1})) ", string.Join(",", tids), string.Join(",", receiverIds));
  4371. }*/
  4372. }
  4373. }
  4374. lw.Add(tid_sql);
  4375. }
  4376. string shopname = GetPostString("shopname");
  4377. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4378. string buyernick = GetPostString("buyer_nick");
  4379. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4380. //if (tid.Length == 0 && buyernick.Length == 0)
  4381. //{
  4382. // lw.Add(string.Format("IsRefund<={0}", 1));
  4383. //}
  4384. string customer = GetPostString("customer");
  4385. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4386. string design = GetPostString("design");
  4387. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4388. string orderState = GetPostString("orderState");
  4389. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4390. string address = GetPostString("address");
  4391. 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));
  4392. string sellermemo = GetPostString("seller_memo");
  4393. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4394. string supplier = GetPostString("supplier");
  4395. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4396. string OrderArea = GetPostString("order_area");
  4397. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4398. string placedate1 = GetPostString("placedate1");
  4399. string placedate2 = GetPostString("placedate2");
  4400. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4401. if (fdw.Length > 0) lw.Add(fdw);
  4402. string price1 = GetPostString("price1");
  4403. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4404. string price2 = GetPostString("price2");
  4405. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4406. string unusualCon = GetPostString("unusualcon");
  4407. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4408. string posTag = CurrentUser.UserPost.Post.Code;
  4409. if (posTag == "Supplier")
  4410. {
  4411. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4412. }
  4413. else
  4414. {
  4415. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4416. {
  4417. string usershop = CurrentUser.User.pemShop;
  4418. lw.Add(string.Format("ShopId in ({0})", usershop));
  4419. }
  4420. }
  4421. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4422. lw.Add(string.Format("type = 'PDD' "));
  4423. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4424. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4425. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4426. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4427. /*if (tid.Length > 0)
  4428. {
  4429. List<string> tids = new List<string>();
  4430. if (dt != null && dt.Rows.Count > 0)
  4431. {
  4432. foreach (DataRow item in dt.Rows)
  4433. {
  4434. tids.Add("'" + item["tid"] + "'");
  4435. }
  4436. }
  4437. if (tids.Count > 0)
  4438. {
  4439. lw.RemoveAt(0);
  4440. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4441. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4442. dt = WebCache.GetData("view_erptradecell", dStruct);
  4443. }
  4444. }*/
  4445. writeGridDataTableJson(dStruct.TotalCount, dt);
  4446. }
  4447. public void get_erp_jdderiving()
  4448. {
  4449. DataStruct dStruct = GetPostStruct();
  4450. List<string> lw = new List<string>();
  4451. string tid = GetPostString("ctid");
  4452. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4453. string shopname = GetPostString("shopname");
  4454. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4455. string buyernick = GetPostString("buyer_nick");
  4456. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4457. //if (tid.Length == 0 && buyernick.Length == 0)
  4458. //{
  4459. // lw.Add(string.Format("IsRefund<={0}", 1));
  4460. //}
  4461. string customer = GetPostString("customer");
  4462. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4463. string design = GetPostString("design");
  4464. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4465. string orderState = GetPostString("orderState");
  4466. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4467. string address = GetPostString("address");
  4468. 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));
  4469. string sellermemo = GetPostString("seller_memo");
  4470. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4471. string supplier = GetPostString("supplier");
  4472. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4473. string OrderArea = GetPostString("order_area");
  4474. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4475. string placedate1 = GetPostString("placedate1");
  4476. string placedate2 = GetPostString("placedate2");
  4477. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4478. if (fdw.Length > 0) lw.Add(fdw);
  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. string unusualCon = GetPostString("unusualcon");
  4484. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4485. string posTag = CurrentUser.UserPost.Post.Code;
  4486. if (posTag == "Supplier")
  4487. {
  4488. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4489. }
  4490. lw.Add(string.Format("OrderState = 6 "));
  4491. lw.Add(string.Format("type = 'JD' "));
  4492. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4493. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4494. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4495. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4496. writeGridDataTableJson(dStruct.TotalCount, dt);
  4497. }
  4498. public void get_erp_demoorderlist()
  4499. {
  4500. DataStruct dStruct = GetPostStruct();
  4501. List<string> lw = new List<string>();
  4502. string tid = GetPostString("ctid");
  4503. if (tid.Length > 0)
  4504. {
  4505. string select_tid = getTidByCtid(tid);
  4506. lw.Add(string.Format("tid='{0}'", select_tid));
  4507. }
  4508. string shopname = GetPostString("shopname");
  4509. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4510. string buyernick = GetPostString("buyer_nick");
  4511. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4512. string customer = GetPostString("customer");
  4513. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4514. string design = GetPostString("design");
  4515. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4516. string orderState = GetPostString("orderState");
  4517. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4518. string address = GetPostString("address");
  4519. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4520. string sellermemo = GetPostString("seller_memo");
  4521. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4522. string supplier = GetPostString("supplier");
  4523. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4524. string OrderArea = GetPostString("order_area");
  4525. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4526. string date1 = GetPostString("date1");
  4527. string date2 = GetPostString("date2");
  4528. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4529. if (dw.Length > 0) lw.Add(dw);
  4530. string price1 = GetPostString("price1");
  4531. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4532. string price2 = GetPostString("price2");
  4533. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4534. string posTag = CurrentUser.UserPost.Post.Code;
  4535. if (posTag == "Supplier")
  4536. {
  4537. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4538. }
  4539. //lw.Add(string.Format("OrderState = 6 "));
  4540. lw.Add(string.Format("IsSample={0}", 3));
  4541. lw.Add(string.Format("IsRefund<={0}", 1));
  4542. dStruct.Order = "pay_time desc";
  4543. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4544. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4545. writeGridDataTableJson(dStruct.TotalCount, dt);
  4546. }
  4547. public void save_erp_checkmemo()
  4548. {
  4549. if (UrlPostParmsCheck("ctid"))
  4550. {
  4551. string ctid = GetPostString("ctid");
  4552. CeErpTradeCell entity = null;
  4553. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4554. if (entity != null)
  4555. {
  4556. entity.CheckMemo = GetPostString("CheckMemo");
  4557. entity.Update();
  4558. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4559. if (trade != null)
  4560. {
  4561. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4562. }
  4563. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4564. returnSuccessMsg("保存成功!");
  4565. return;
  4566. }
  4567. returnErrorMsg("找不到记录");
  4568. }
  4569. }
  4570. public void get_erp_returnlist()
  4571. {
  4572. DataStruct dStruct = GetPostStruct();
  4573. List<string> lw = new List<string>();
  4574. string tid = GetPostString("ctid");
  4575. if (tid.Length > 0)
  4576. {
  4577. string select_tid = getTidByCtid(tid);
  4578. lw.Add(string.Format("tid='{0}'", select_tid));
  4579. }
  4580. string shopname = GetPostString("shopname");
  4581. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4582. string buyernick = GetPostString("buyer_nick");
  4583. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4584. string customer = GetPostString("customer");
  4585. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4586. string design = GetPostString("design");
  4587. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4588. string orderState = GetPostString("orderState");
  4589. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4590. string address = GetPostString("address");
  4591. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4592. string sellermemo = GetPostString("seller_memo");
  4593. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4594. string supplier = GetPostString("supplier");
  4595. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4596. string date1 = GetPostString("date1");
  4597. string date2 = GetPostString("date2");
  4598. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4599. if (dw.Length > 0) lw.Add(dw);
  4600. string bdate1 = GetPostString("backdate1");
  4601. string bdate2 = GetPostString("backdate2");
  4602. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4603. if (dw_back.Length > 0) lw.Add(dw_back);
  4604. string price1 = GetPostString("price1");
  4605. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4606. string price2 = GetPostString("price2");
  4607. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4608. lw.Add(string.Format("IsReturn>0"));
  4609. lw.Add(string.Format("IsXianHuo=0"));
  4610. lw.Add(string.Format("IsReturn!=3"));
  4611. string backtype = GetPostString("backtype");
  4612. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4613. dStruct.Order = "FinishDesignTime desc";
  4614. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4615. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4616. writeGridDataTableJson(dStruct.TotalCount, dt);
  4617. }
  4618. public void get_erp_today_sumreturn()
  4619. {
  4620. DataStruct dStruct = GetPostStruct();
  4621. List<string> lw = new List<string>();
  4622. string bdate1 = GetPostString("returnTimeS");
  4623. string bdate2 = GetPostString("returnTimeE");
  4624. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4625. if (dw_back.Length > 0) lw.Add(dw_back);
  4626. lw.Add(string.Format("IsReturn=0"));
  4627. lw.Add(string.Format("IsXianHuo=0"));
  4628. string mainWhere = string.Join(" and ", lw.ToArray());
  4629. string sql = "";
  4630. if (dw_back.Length > 0)
  4631. {
  4632. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4633. }
  4634. else
  4635. {
  4636. 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 + "'";
  4637. }
  4638. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4639. decimal total = 0, today_finish = 0;
  4640. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4641. {
  4642. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4643. }
  4644. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4645. {
  4646. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4647. }
  4648. var res = new
  4649. {
  4650. data = total,
  4651. data1 = today_finish,
  4652. };
  4653. string ro_jsond = JsonConvert.SerializeObject(res);
  4654. returnSuccess(ro_jsond);
  4655. return;
  4656. }
  4657. public void get_erp_allreturnlist()
  4658. {
  4659. DataStruct dStruct = GetPostStruct();
  4660. List<string> lw = new List<string>();
  4661. string tid = GetPostString("ctid");
  4662. if (tid.Length > 0)
  4663. {
  4664. string select_tid = getTidByCtid(tid);
  4665. lw.Add(string.Format("tid='{0}'", select_tid));
  4666. }
  4667. string shopname = GetPostString("shopname");
  4668. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4669. string buyernick = GetPostString("buyer_nick");
  4670. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4671. string customer = GetPostString("customer");
  4672. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4673. string design = GetPostString("design");
  4674. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4675. string orderState = GetPostString("orderState");
  4676. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4677. string address = GetPostString("address");
  4678. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4679. string sellermemo = GetPostString("seller_memo");
  4680. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4681. string supplier = GetPostString("supplier");
  4682. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4683. string date1 = GetPostString("date1");
  4684. string date2 = GetPostString("date2");
  4685. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4686. if (dw.Length > 0) lw.Add(dw);
  4687. string bdate1 = GetPostString("backdate1");
  4688. string bdate2 = GetPostString("backdate2");
  4689. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4690. if (dw_back.Length > 0) lw.Add(dw_back);
  4691. string price1 = GetPostString("price1");
  4692. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4693. string price2 = GetPostString("price2");
  4694. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4695. string backreason = GetPostString("backreason");
  4696. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4697. lw.Add(string.Format("IsXianHuo=0"));
  4698. lw.Add(string.Format("ReturnTime != ''"));
  4699. string backtype = GetPostString("backtype");
  4700. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4701. string posTag = CurrentUser.UserPost.Post.Code;
  4702. if (posTag == "Supplier")
  4703. {
  4704. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4705. }
  4706. else
  4707. {
  4708. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  4709. {
  4710. string usershop = CurrentUser.User.pemShop;
  4711. lw.Add(string.Format("ShopId in ({0})", usershop));
  4712. }
  4713. }
  4714. dStruct.Order = "FinishDesignTime desc";
  4715. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4716. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4717. writeGridDataTableJson(dStruct.TotalCount, dt);
  4718. }
  4719. public void get_erp_aftersalereturnlist()
  4720. {
  4721. DataStruct dStruct = GetPostStruct();
  4722. List<string> lw = new List<string>();
  4723. string tid = GetPostString("ctid");
  4724. if (tid.Length > 0)
  4725. {
  4726. string select_tid = getTidByCtid(tid);
  4727. lw.Add(string.Format("tid='{0}'", select_tid));
  4728. }
  4729. string shopname = GetPostString("shopname");
  4730. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4731. string buyernick = GetPostString("buyer_nick");
  4732. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4733. string customer = GetPostString("customer");
  4734. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4735. string design = GetPostString("design");
  4736. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4737. string orderState = GetPostString("orderState");
  4738. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4739. string address = GetPostString("address");
  4740. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4741. string sellermemo = GetPostString("seller_memo");
  4742. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4743. string supplier = GetPostString("supplier");
  4744. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4745. string date1 = GetPostString("date1");
  4746. string date2 = GetPostString("date2");
  4747. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4748. if (dw.Length > 0) lw.Add(dw);
  4749. string bdate1 = GetPostString("backdate1");
  4750. string bdate2 = GetPostString("backdate2");
  4751. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4752. if (dw_back.Length > 0) lw.Add(dw_back);
  4753. string price1 = GetPostString("price1");
  4754. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4755. string price2 = GetPostString("price2");
  4756. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4757. lw.Add(string.Format("IsReturn=3"));
  4758. string backtype = GetPostString("backtype");
  4759. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4760. string backreason = GetPostString("backreason");
  4761. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4762. dStruct.Order = "ReturnTime desc";
  4763. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4764. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4765. writeGridDataTableJson(dStruct.TotalCount, dt);
  4766. }
  4767. public void get_erp_xianhuoreturnlist()
  4768. {
  4769. DataStruct dStruct = GetPostStruct();
  4770. List<string> lw = new List<string>();
  4771. string tid = GetPostString("ctid");
  4772. if (tid.Length > 0)
  4773. {
  4774. string select_tid = getTidByCtid(tid);
  4775. lw.Add(string.Format("tid='{0}'", select_tid));
  4776. }
  4777. string shopname = GetPostString("shopname");
  4778. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4779. string buyernick = GetPostString("buyer_nick");
  4780. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4781. string customer = GetPostString("customer");
  4782. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4783. string design = GetPostString("design");
  4784. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4785. string orderState = GetPostString("orderState");
  4786. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4787. string address = GetPostString("address");
  4788. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4789. string sellermemo = GetPostString("seller_memo");
  4790. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4791. string supplier = GetPostString("supplier");
  4792. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4793. string OrderArea = GetPostString("order_area");
  4794. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4795. string date1 = GetPostString("date1");
  4796. string date2 = GetPostString("date2");
  4797. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4798. if (dw.Length > 0) lw.Add(dw);
  4799. string price1 = GetPostString("price1");
  4800. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4801. string price2 = GetPostString("price2");
  4802. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4803. string posTag = CurrentUser.UserPost.Post.Code;
  4804. if (posTag == "Supplier")
  4805. {
  4806. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4807. }
  4808. lw.Add(string.Format("OrderState=6 "));
  4809. lw.Add(string.Format("IsXianHuo=1 "));
  4810. lw.Add(string.Format("IsReturn>0 "));
  4811. lw.Add(string.Format("IsReturn!=3"));
  4812. lw.Add(string.Format("IsRefund<={0}", 1));
  4813. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4814. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4815. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4816. writeGridDataTableJson(dStruct.TotalCount, dt);
  4817. }
  4818. public void set_erp_orderdelivery()
  4819. {
  4820. if (UrlPostParmsCheck("ctid"))
  4821. {
  4822. string eid = GetPostString("ctid");
  4823. CeErpTradeCell entity = null;
  4824. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4825. if (entity != null)
  4826. {
  4827. if (entity.OrderState >= 7)
  4828. {
  4829. returnErrorMsg("此单已发货,无需重复发货");
  4830. return;
  4831. }
  4832. if (entity.OrderState != 6)
  4833. {
  4834. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4835. return;
  4836. }
  4837. string shop = GetPostString("seller_nick");
  4838. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4839. string comName = GetPostString("comName");
  4840. string comCode = GetPostString("comCode");
  4841. string outSid = GetPostString("outSid");
  4842. string deliveryType = GetPostString("deliveryType");
  4843. string deliveryMemo = GetPostString("deliveryMemo");
  4844. outSid = outSid.Trim();
  4845. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4846. if (mainEn == null)
  4847. {
  4848. returnErrorMsg("找不到原始订单记录");
  4849. return;
  4850. }
  4851. bool isInitOrderDeliv = false;
  4852. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4853. {
  4854. isInitOrderDeliv = true;
  4855. }
  4856. string apires = "";
  4857. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4858. 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)
  4859. {
  4860. apires = "发货成功true";
  4861. }
  4862. else
  4863. {
  4864. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4865. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4866. }
  4867. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4868. {
  4869. entity.OrderState = 7;//发货后订单已发货
  4870. entity.OutSid = outSid;
  4871. entity.MemoOpt = 0;
  4872. entity.UpdateTime = DateTime.Now;
  4873. entity.FinishDeliveryTime = DateTime.Now;
  4874. entity.Update();
  4875. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4876. commonHelper.UpdateRelationOrder(entity.ctid);
  4877. //还要插入快递信息到 快递信息表
  4878. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4879. exinfo.tid = eid;
  4880. exinfo.out_sid = outSid;
  4881. exinfo.company_code = comCode;
  4882. exinfo.company_name = comName;
  4883. exinfo.delivery_memo = deliveryMemo;
  4884. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4885. exinfo.deliveryType = deliveryType;
  4886. exinfo.Create();
  4887. returnSuccessMsg("发货操作成功!");
  4888. commonHelper.UpdateRelationOrder(entity.ctid);
  4889. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4890. CeErpSukuraData.createInfo(entity.ctid, 4);
  4891. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  4892. {
  4893. commonHelper.sendCytExpress(exinfo);
  4894. }
  4895. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid + ",备注:" + deliveryMemo, entity.OrderState);
  4897. }
  4898. else
  4899. {
  4900. string errmsg = commonHelper.KeepChinese(apires);
  4901. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4902. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4903. }
  4904. return;
  4905. }
  4906. returnErrorMsg("找不到订单记录");
  4907. }
  4908. }
  4909. public void set_erp_multidelivery()
  4910. {
  4911. string eids = GetPostString("tids");
  4912. string[] eidList = eids.Split(',');
  4913. if (eidList.Length <= 0)
  4914. {
  4915. returnErrorMsg("发货不能为空");
  4916. return;
  4917. }
  4918. foreach (string ctid in eidList)
  4919. {
  4920. if (ctid.Length <= 0) continue;
  4921. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4922. if (expInfo != null)
  4923. {
  4924. StringBuilder sql = new StringBuilder();
  4925. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4926. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4927. if (dt.Rows.Count > 0)
  4928. {
  4929. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4930. {
  4931. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4932. expInfo.state = "异常";
  4933. expInfo.isMultiDelivery = 1;
  4934. expInfo.Update();
  4935. continue;
  4936. }
  4937. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4938. {
  4939. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4940. expInfo.state = "异常";
  4941. expInfo.Update();
  4942. continue;
  4943. }
  4944. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4945. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4946. bool isInitOrderDeliv = false;
  4947. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4948. {
  4949. isInitOrderDeliv = true;
  4950. expInfo.isMultiDelivery = 1;
  4951. }
  4952. if (ctid.IndexOf("N") != -1)
  4953. {
  4954. StringBuilder sqlbucha = new StringBuilder();
  4955. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4956. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4957. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4958. commonHelper.UpdateRelationOrder(ctid);
  4959. expInfo.delivery_memo = "发货成功";
  4960. expInfo.state = "发货成功";
  4961. expInfo.isMultiDelivery = 1;
  4962. expInfo.Update();
  4963. }
  4964. else
  4965. {
  4966. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4967. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4968. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4969. {
  4970. expInfo.delivery_memo = "发货成功";
  4971. expInfo.state = "发货成功";
  4972. expInfo.isMultiDelivery = 1;
  4973. expInfo.Update();
  4974. commonHelper.UpdateRelationOrder(ctid);
  4975. CeErpSukuraData.createInfo(ctid, 4);
  4976. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4977. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4978. }
  4979. else
  4980. {
  4981. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4982. expInfo.state = "异常";
  4983. expInfo.Update();
  4984. }
  4985. }
  4986. }
  4987. }
  4988. }
  4989. returnSuccessMsg("操作完成");
  4990. }
  4991. public void reset_erp_memoopt()
  4992. {
  4993. if (UrlPostParmsCheck("ctid"))
  4994. {
  4995. string eid = GetPostString("ctid");
  4996. CeErpTradeCell entity = null;
  4997. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4998. if (entity != null)
  4999. {
  5000. string stropt = "";
  5001. if (entity.MemoOpt == 1)
  5002. {
  5003. stropt = "“改稿”";
  5004. }
  5005. else if (entity.MemoOpt == 2)
  5006. {
  5007. stropt = "“定稿”";
  5008. }
  5009. else if (entity.MemoOpt == 3)
  5010. {
  5011. stropt = "“完成查货”";
  5012. CeErpSukuraData.createInfo(entity.ctid, 6);
  5013. }
  5014. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  5015. entity.UpdateTime = DateTime.Now;
  5016. entity.MemoOpt = 0;
  5017. entity.Update();
  5018. returnSuccessMsg("操作成功!");
  5019. return;
  5020. }
  5021. returnErrorMsg("找不到记录");
  5022. }
  5023. }
  5024. public void get_erp_deliveryunusual()
  5025. {
  5026. DataStruct dStruct = GetPostStruct();
  5027. List<string> lw = new List<string>();
  5028. string tid = GetPostString("ctid");
  5029. if (tid.Length > 0)
  5030. {
  5031. string select_tid = getTidByCtid(tid);
  5032. lw.Add(string.Format("tid='{0}'", select_tid));
  5033. }
  5034. string shopname = GetPostString("shopname");
  5035. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5036. string buyernick = GetPostString("buyer_nick");
  5037. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5038. string customer = GetPostString("customer");
  5039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5040. string design = GetPostString("design");
  5041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5042. string sellermemo = GetPostString("seller_memo");
  5043. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5044. string supplier = GetPostString("supplier");
  5045. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5046. string date1 = GetPostString("date1");
  5047. string date2 = GetPostString("date2");
  5048. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5049. if (dw.Length > 0) lw.Add(dw);
  5050. string placedate1 = GetPostString("placedate1");
  5051. string placedate2 = GetPostString("placedate2");
  5052. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5053. if (dw_place.Length > 0) lw.Add(dw_place);
  5054. string price1 = GetPostString("price1");
  5055. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5056. string price2 = GetPostString("price2");
  5057. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5058. string unusualCon = GetPostString("unusualcon");
  5059. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  5060. string posTag = CurrentUser.UserPost.Post.Code;
  5061. if (posTag == "Supplier")
  5062. {
  5063. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5064. }
  5065. lw.Add(string.Format("OrderState = 6"));
  5066. lw.Add(string.Format("UnusualTag = 5"));
  5067. lw.Add(string.Format("IsRefund<={0}", 1));
  5068. dStruct.Order = "FinishPlaceTime desc";
  5069. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5070. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5071. writeGridDataTableJson(dStruct.TotalCount, dt);
  5072. }
  5073. public void get_erp_deliveryedlist()
  5074. {
  5075. DataStruct dStruct = GetPostStruct();
  5076. List<string> lw = new List<string>();
  5077. string tid = GetPostString("ctid");
  5078. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5079. string shopname = GetPostString("shopname");
  5080. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5081. string buyernick = GetPostString("buyer_nick");
  5082. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5083. string customer = GetPostString("customer");
  5084. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5085. string design = GetPostString("design");
  5086. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5087. string sellermemo = GetPostString("seller_memo");
  5088. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5089. string logistics = GetPostString("logistics");
  5090. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5091. string date1 = GetPostString("date1");
  5092. string date2 = GetPostString("date2");
  5093. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5094. //if (dw.Length > 0) lw.Add(dw);
  5095. string placedate1 = GetPostString("placedate1");
  5096. string placedate2 = GetPostString("placedate2");
  5097. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5098. if (fdw.Length > 0) lw.Add(fdw);
  5099. string devdate1 = GetPostString("deliverydate1");
  5100. string devdate2 = GetPostString("deliverydate2");
  5101. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5102. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5103. string price1 = GetPostString("price1");
  5104. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5105. string price2 = GetPostString("price2");
  5106. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5107. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5108. {
  5109. if (tid.Length > 0)
  5110. {
  5111. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5112. if (tid.Length > 5)
  5113. {
  5114. List<string> tids = getTidByCtidLike(tid);
  5115. if (tids.Count > 0 && tids.Count < 10)
  5116. {
  5117. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5118. }
  5119. }
  5120. lw.Add(tid_sql);
  5121. }
  5122. if (buyernick.Length > 0)
  5123. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5124. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5125. if (dw.Length > 0) lw.Add(dw);
  5126. }
  5127. else
  5128. {
  5129. lw.Add(string.Format("pay_time >= DATEADD(DAY, -31, GETDATE()) "));
  5130. }
  5131. string posTag = CurrentUser.UserPost.Post.Code;
  5132. if (posTag == "Supplier")
  5133. {
  5134. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5135. }
  5136. else
  5137. {
  5138. string supplier = GetPostString("supplier");
  5139. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5140. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5141. {
  5142. string usershop = CurrentUser.User.pemShop;
  5143. lw.Add(string.Format("ShopId in ({0})", usershop));
  5144. }
  5145. }
  5146. lw.Add(string.Format(" OrderState IN (7, 8)"));
  5147. lw.Add(string.Format("type != 'PDD' "));
  5148. lw.Add(string.Format("IsRefund!={0}", 2));
  5149. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5150. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5151. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5152. /*if (tid.Length > 0)
  5153. {
  5154. List<string> tids = new List<string>();
  5155. if (dt != null && dt.Rows.Count > 0)
  5156. {
  5157. foreach (DataRow item in dt.Rows)
  5158. {
  5159. tids.Add("'" + item["tid"] + "'");
  5160. }
  5161. }
  5162. if (tids.Count > 0)
  5163. {
  5164. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5165. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5166. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5167. dt = WebCache.GetData("view_erptradecell", dStruct);
  5168. }
  5169. }*/
  5170. if (dt != null)
  5171. {
  5172. foreach (DataRow dr in dt.Rows)
  5173. {
  5174. 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();
  5175. }
  5176. }
  5177. writeGridDataTableJson(dStruct.TotalCount, dt);
  5178. }
  5179. public void get_erp_pdddeliveryed()
  5180. {
  5181. DataStruct dStruct = GetPostStruct();
  5182. List<string> lw = new List<string>();
  5183. string tid = GetPostString("ctid");
  5184. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5185. string shopname = GetPostString("shopname");
  5186. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5187. string buyernick = GetPostString("buyer_nick");
  5188. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5189. string customer = GetPostString("customer");
  5190. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5191. string design = GetPostString("design");
  5192. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5193. string sellermemo = GetPostString("seller_memo");
  5194. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5195. string logistics = GetPostString("logistics");
  5196. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  5197. string date1 = GetPostString("date1");
  5198. string date2 = GetPostString("date2");
  5199. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5200. //if (dw.Length > 0) lw.Add(dw);
  5201. string placedate1 = GetPostString("placedate1");
  5202. string placedate2 = GetPostString("placedate2");
  5203. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5204. if (fdw.Length > 0) lw.Add(fdw);
  5205. string devdate1 = GetPostString("deliverydate1");
  5206. string devdate2 = GetPostString("deliverydate2");
  5207. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5208. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5209. string price1 = GetPostString("price1");
  5210. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5211. string price2 = GetPostString("price2");
  5212. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5213. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5214. {
  5215. if (tid.Length > 0)
  5216. {
  5217. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  5218. if (tid.Length > 5)
  5219. {
  5220. List<string> tids = getTidByCtidLike(tid);
  5221. if (tids.Count > 0 && tids.Count < 10)
  5222. {
  5223. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  5224. }
  5225. }
  5226. lw.Add(tid_sql);
  5227. }
  5228. if (buyernick.Length > 0)
  5229. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5230. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5231. if (dw.Length > 0) lw.Add(dw);
  5232. }
  5233. else
  5234. {
  5235. lw.Add(string.Format("datediff(d,pay_time,getdate())<=61 "));
  5236. }
  5237. string posTag = CurrentUser.UserPost.Post.Code;
  5238. if (posTag == "Supplier")
  5239. {
  5240. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5241. }
  5242. else
  5243. {
  5244. if (posTag != "wxDesigner" && posTag != "Designer" && posTag != "DesignerMr" && posTag != "wxDesignerMr" && posTag != "SysAdmin")
  5245. {
  5246. string usershop = CurrentUser.User.pemShop;
  5247. lw.Add(string.Format("ShopId in ({0})", usershop));
  5248. }
  5249. string supplier = GetPostString("supplier");
  5250. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5251. }
  5252. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5253. lw.Add(string.Format("type = 'PDD' "));
  5254. lw.Add(string.Format("IsRefund!={0}", 2));
  5255. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5256. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5257. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5258. /* if (tid.Length > 0)
  5259. {
  5260. List<string> tids = new List<string>();
  5261. if (dt != null && dt.Rows.Count > 0)
  5262. {
  5263. foreach (DataRow item in dt.Rows)
  5264. {
  5265. tids.Add("'" + item["tid"] + "'");
  5266. }
  5267. }
  5268. if (tids.Count > 0)
  5269. {
  5270. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  5271. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  5272. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5273. dt = WebCache.GetData("view_erptradecell", dStruct);
  5274. }
  5275. }*/
  5276. foreach (DataRow dr in dt.Rows)
  5277. {
  5278. 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();
  5279. }
  5280. writeGridDataTableJson(dStruct.TotalCount, dt);
  5281. }
  5282. public void get_erp_jddeliveryed()
  5283. {
  5284. DataStruct dStruct = GetPostStruct();
  5285. List<string> lw = new List<string>();
  5286. string tid = GetPostString("ctid");
  5287. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  5288. string shopname = GetPostString("shopname");
  5289. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5290. string buyernick = GetPostString("buyer_nick");
  5291. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5292. string customer = GetPostString("customer");
  5293. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5294. string design = GetPostString("design");
  5295. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5296. string sellermemo = GetPostString("seller_memo");
  5297. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5298. string date1 = GetPostString("date1");
  5299. string date2 = GetPostString("date2");
  5300. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5301. //if (dw.Length > 0) lw.Add(dw);
  5302. string placedate1 = GetPostString("placedate1");
  5303. string placedate2 = GetPostString("placedate2");
  5304. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5305. if (fdw.Length > 0) lw.Add(fdw);
  5306. string devdate1 = GetPostString("deliverydate1");
  5307. string devdate2 = GetPostString("deliverydate2");
  5308. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  5309. if (dw_dev.Length > 0) lw.Add(dw_dev);
  5310. string price1 = GetPostString("price1");
  5311. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5312. string price2 = GetPostString("price2");
  5313. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5314. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  5315. {
  5316. if (tid.Length > 0)
  5317. lw.Add(string.Format("ctid like '%{0}%'", tid));
  5318. if (buyernick.Length > 0)
  5319. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5320. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5321. if (dw.Length > 0) lw.Add(dw);
  5322. }
  5323. else
  5324. {
  5325. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5326. }
  5327. string posTag = CurrentUser.UserPost.Post.Code;
  5328. if (posTag == "Supplier")
  5329. {
  5330. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5331. }
  5332. else
  5333. {
  5334. string supplier = GetPostString("supplier");
  5335. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5336. }
  5337. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  5338. lw.Add(string.Format("type = 'JD' "));
  5339. lw.Add(string.Format("IsRefund!={0}", 2));
  5340. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5341. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5342. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5343. foreach (DataRow dr in dt.Rows)
  5344. {
  5345. 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();
  5346. }
  5347. writeGridDataTableJson(dStruct.TotalCount, dt);
  5348. }
  5349. public void get_erp_allplacelist()
  5350. {
  5351. DataStruct dStruct = GetPostStruct();
  5352. List<string> lw = new List<string>();
  5353. string tid = GetPostString("ctid");
  5354. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5355. string shopname = GetPostString("shopname");
  5356. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5357. string buyernick = GetPostString("buyer_nick");
  5358. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5359. string customer = GetPostString("customer");
  5360. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5361. string design = GetPostString("design");
  5362. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5363. string sellermemo = GetPostString("seller_memo");
  5364. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5365. string supplier = GetPostString("supplier");
  5366. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5367. string date1 = GetPostString("date1");
  5368. string date2 = GetPostString("date2");
  5369. string pldate1 = GetPostString("placedate1");
  5370. string pldate2 = GetPostString("placedate2");
  5371. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5372. //if (dw.Length > 0) lw.Add(dw);
  5373. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5374. {
  5375. if (tid.Length > 0)
  5376. {
  5377. string select_tid = getTidByCtid(tid);
  5378. lw.Add(string.Format("tid='{0}'", select_tid));
  5379. }
  5380. if (buyernick.Length > 0)
  5381. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5382. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5383. if (dw.Length > 0) lw.Add(dw);
  5384. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5385. if (dw_place.Length > 0) lw.Add(dw_place);
  5386. }
  5387. else
  5388. {
  5389. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5390. {
  5391. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5392. }
  5393. }
  5394. string price1 = GetPostString("price1");
  5395. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5396. string price2 = GetPostString("price2");
  5397. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5398. string posTag = CurrentUser.UserPost.Post.Code;
  5399. if (posTag == "Supplier")
  5400. {
  5401. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5402. }
  5403. lw.Add(string.Format("OrderState >= 6"));
  5404. lw.Add(string.Format("IsSample != 2 "));
  5405. //lw.Add(string.Format("isDianziOrder = 0 "));
  5406. lw.Add(string.Format("SupplierId > 0 "));
  5407. //lw.Add(string.Format("IsRefund<={0}", 1));
  5408. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5409. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5410. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  5411. foreach (DataRow dr in dt.Rows)
  5412. {
  5413. 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();
  5414. }
  5415. writeGridDataTableJson(dStruct.TotalCount, dt);
  5416. }
  5417. public void get_erp_financeallplacelist()
  5418. {
  5419. DataStruct dStruct = GetPostStruct();
  5420. List<string> lw = new List<string>();
  5421. string tid = GetPostString("ctid");
  5422. string shopname = GetPostString("shopname");
  5423. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5424. string buyernick = GetPostString("buyer_nick");
  5425. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5426. string customer = GetPostString("customer");
  5427. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5428. string design = GetPostString("design");
  5429. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5430. string sellermemo = GetPostString("seller_memo");
  5431. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5432. string supplier = GetPostString("supplier");
  5433. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5434. string date1 = GetPostString("date1");
  5435. string date2 = GetPostString("date2");
  5436. string pldate1 = GetPostString("placedate1");
  5437. string pldate2 = GetPostString("placedate2");
  5438. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5439. {
  5440. if (tid.Length > 0)
  5441. {
  5442. string select_tid = getTidByCtid(tid);
  5443. lw.Add(string.Format("tid='{0}'", select_tid));
  5444. }
  5445. if (buyernick.Length > 0)
  5446. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5447. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5448. if (dw.Length > 0) lw.Add(dw);
  5449. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5450. if (dw_place.Length > 0) lw.Add(dw_place);
  5451. }
  5452. else
  5453. {
  5454. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5455. {
  5456. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5457. }
  5458. }
  5459. string price1 = GetPostString("price1");
  5460. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5461. string price2 = GetPostString("price2");
  5462. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5463. string posTag = CurrentUser.UserPost.Post.Code;
  5464. if (posTag == "Supplier")
  5465. {
  5466. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5467. }
  5468. //lw.Add(string.Format("OrderState >= 6"));
  5469. lw.Add(string.Format("IsSample != 2 "));
  5470. lw.Add(string.Format("isDianziOrder = 0 "));
  5471. //lw.Add(string.Format("IsRefund<={0}", 1));
  5472. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5473. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5474. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5475. foreach (DataRow dr in dt.Rows)
  5476. {
  5477. 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();
  5478. }
  5479. writeGridDataTableJson(dStruct.TotalCount, dt);
  5480. }
  5481. public void get_erp_expresslist()
  5482. {
  5483. int listtype = GetInt("ltype");
  5484. DataStruct dStruct = GetPostStruct();
  5485. List<string> lw = new List<string>();
  5486. string tid = GetPostString("tid");
  5487. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5488. string outsid = GetPostString("out_sid");
  5489. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5490. string importer = GetPostString("ImportUserName");
  5491. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5492. string file = GetPostString("import_file");
  5493. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5494. string printman = GetPostString("printman");
  5495. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5496. string date1 = GetPostString("date1");
  5497. string date2 = GetPostString("date2");
  5498. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5499. if (dw.Length > 0) lw.Add(dw);
  5500. string fdate1 = GetPostString("finishdate1");
  5501. string fdate2 = GetPostString("finishdate2");
  5502. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5503. if (fdw.Length > 0) lw.Add(fdw);
  5504. string supplierId = GetPostString("supplierId");
  5505. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5506. if (listtype == 1)
  5507. {
  5508. lw.Add(string.Format("importUserId !=0"));
  5509. }
  5510. string posTag = CurrentUser.UserPost.Post.Code;
  5511. if (posTag == "Supplier")
  5512. {
  5513. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5514. }
  5515. if (dStruct.PageSize != 100000)
  5516. {
  5517. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5518. }
  5519. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5520. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5521. writeGridDataTableJson(dStruct.TotalCount, dt);
  5522. }
  5523. public void set_erp_buchaorderdelivery()
  5524. {
  5525. if (UrlPostParmsCheck("ctid"))
  5526. {
  5527. string eid = GetPostString("ctid");
  5528. CeErpTradeCell entity = null;
  5529. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5530. if (entity != null)
  5531. {
  5532. if (entity.IsSample != 2)
  5533. {
  5534. returnErrorMsg("补差价单才能标记为已发货");
  5535. return;
  5536. }
  5537. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5538. entity.OrderState = 7;
  5539. entity.Update();
  5540. returnSuccessMsg("操作成功!");
  5541. return;
  5542. }
  5543. returnErrorMsg("找不到记录");
  5544. }
  5545. }
  5546. public void get_stdtemplates()
  5547. {
  5548. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5549. //string res = taobaoHelper.test();
  5550. string res = apiHelper.API_PrintTemplate();
  5551. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5552. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5553. {
  5554. int sidx = res.IndexOf("error_code");
  5555. int eidx = res.IndexOf("success");
  5556. string msg = res.Substring(sidx, eidx - sidx);
  5557. returnErrorMsg(msg);
  5558. return;
  5559. }
  5560. if (res.Length <= 0)
  5561. {
  5562. returnErrorMsg("模板数据为空!");
  5563. return;
  5564. }
  5565. ReturnSuccess(res);
  5566. }
  5567. public void cancel_print_order()
  5568. {
  5569. if (UrlPostParmsCheck("ctid"))
  5570. {
  5571. string ctid = GetPostString("ctid");
  5572. CeErpTradeCell entity = null;
  5573. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5574. if (entity != null)
  5575. {
  5576. string res = "";
  5577. string code = entity.LastBillWaybillCode;
  5578. if (code == "")
  5579. {
  5580. code = entity.OutSid;
  5581. }
  5582. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5583. XLog.SaveLog(0, "取消面单" + res);
  5584. }
  5585. }
  5586. }
  5587. public void set_erp_printwaybill()
  5588. {
  5589. if (UrlPostParmsCheck("ctid"))
  5590. {
  5591. string ctid = GetPostString("ctid");
  5592. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5593. string cpName = GetPostString("cpname");
  5594. string isTogether = GetPostString("together");
  5595. string printType = GetPostString("printType");
  5596. //var res_obj = new
  5597. //{
  5598. // restype = 1,
  5599. // 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\"}"
  5600. //};
  5601. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5602. //ReturnSuccess(ro_json);
  5603. //return;
  5604. bool isUseLastWayBillCode = false;
  5605. CeErpTradeCell entity = null;
  5606. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5607. if (entity != null)
  5608. {
  5609. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5610. {
  5611. isUseLastWayBillCode = true;
  5612. }
  5613. if (entity.OrderState == 7 && "delivering".Equals(printType))
  5614. {
  5615. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5616. return;
  5617. }
  5618. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5619. {
  5620. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5621. return;
  5622. }
  5623. if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
  5624. {
  5625. returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
  5626. return;
  5627. }
  5628. }
  5629. string res = "";
  5630. Api_waybill_code_response_Obj fullObj = null;
  5631. string pData_str = "";
  5632. string curUseWayBillCode = "";
  5633. if (isUseLastWayBillCode == false)
  5634. {
  5635. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5636. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5637. if (res.IndexOf("failure") != -1)
  5638. {
  5639. //int idx = res.IndexOf("sub_message");
  5640. //int idx2 = res.IndexOf("flag");
  5641. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5642. string errMsgNeed = commonHelper.KeepChinese(res);
  5643. var res_objd = new
  5644. {
  5645. restype = 0,
  5646. data = "获取面单失败" + errMsgNeed
  5647. };
  5648. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5649. returnSuccess(ro_jsond);
  5650. if (res.IndexOf("停发") != -1)
  5651. {
  5652. entity.UnusualCon = "物流停发";
  5653. entity.Update();
  5654. }
  5655. //returnErrorMsg("获取面单失败,"+emsg);
  5656. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5657. return;
  5658. }
  5659. else if (res.IndexOf("errorMsg") != -1)
  5660. {
  5661. //int idx = res.IndexOf("errorMsg");
  5662. //int idx2 = res.IndexOf("}]}");
  5663. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5664. string errMsgNeed = commonHelper.KeepChinese(res);
  5665. var res_objf = new
  5666. {
  5667. restype = 0,
  5668. data = "获取面单失败2" + errMsgNeed
  5669. };
  5670. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5671. if (res.IndexOf("停发") != -1)
  5672. {
  5673. entity.UnusualCon = "物流停发";
  5674. entity.Update();
  5675. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5676. if (trade != null)
  5677. {
  5678. //string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5679. }
  5680. }
  5681. returnSuccess(ro_jsonf);
  5682. //returnErrorMsg("获取面单失败," + emsg);
  5683. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5684. return;
  5685. }
  5686. try
  5687. {
  5688. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5689. //res = res.Replace(" ", "");
  5690. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5691. }
  5692. catch (Exception ex)
  5693. {
  5694. XLog.SaveLog(0, "生成fullObj" + res);
  5695. var res_objf = new
  5696. {
  5697. restype = 0,
  5698. data = "生成fullObj发生错误" + ex.Message
  5699. };
  5700. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5701. returnSuccess(ro_jsonf);
  5702. return;
  5703. }
  5704. if (fullObj.response.data.content.Count > 0)
  5705. {
  5706. ContentItem codeObj = fullObj.response.data.content[0];
  5707. if (cpCode.IndexOf("SFFQ-") != -1)
  5708. {
  5709. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5710. }
  5711. else
  5712. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5713. curUseWayBillCode = codeObj.waybillCode;
  5714. }
  5715. else
  5716. {
  5717. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5718. var res_objf = new
  5719. {
  5720. restype = 0,
  5721. data = "生成fullObj找不到快递单号waybillCode"
  5722. };
  5723. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5724. returnSuccess(ro_jsonf);
  5725. return;
  5726. }
  5727. }
  5728. else
  5729. {
  5730. //使用上次打印的快递单号
  5731. if (cpCode == "SFFQ-LY")
  5732. {
  5733. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5734. }
  5735. else
  5736. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5737. curUseWayBillCode = entity.LastBillWaybillCode;
  5738. }
  5739. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5740. {
  5741. var res_obje = new
  5742. {
  5743. restype = 0,
  5744. data = "获取加密打印数据失败"
  5745. };
  5746. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5747. returnSuccess(ro_jsone);
  5748. entity.LastBillCpCode = cpCode;
  5749. entity.LastBillWaybillCode = curUseWayBillCode;
  5750. entity.Update();
  5751. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5752. //returnErrorMsg("获取加密打印数据失败");
  5753. return;
  5754. }
  5755. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5756. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5757. string btnType = "";
  5758. string errorMsg = "";
  5759. if (entity != null)
  5760. {
  5761. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5762. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5763. //cpcode是 YTO-CAINIAO
  5764. //string comCode = cpCode.Split('-')[0].ToString();
  5765. string apires = "";
  5766. string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
  5767. //isTogether=2是新的合包弹窗
  5768. if ((!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1) || (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 0) || string.IsNullOrEmpty(isTogether))
  5769. {
  5770. if (ctid.IndexOf("N") != -1)
  5771. {
  5772. apires = "发货成功";
  5773. }
  5774. else
  5775. {
  5776. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5777. }
  5778. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5779. //打单后发货
  5780. StringBuilder sql = new StringBuilder();
  5781. sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
  5782. if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
  5783. {
  5784. sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
  5785. }
  5786. else
  5787. {
  5788. sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
  5789. }
  5790. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5791. foreach (DataRow row in dt.Rows)
  5792. {
  5793. entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5794. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5795. {
  5796. try
  5797. {
  5798. btnType = "待发货";
  5799. entity.OutSid = curUseWayBillCode;
  5800. entity.OrderState = 7;
  5801. entity.IsUrgency = false;
  5802. entity.LastBillCpCode = "";
  5803. entity.LastBillWaybillCode = "";
  5804. entity.FinishDeliveryTime = DateTime.Now;
  5805. entity.IsReturn = 0;
  5806. entity.MemoOpt = 0;
  5807. entity.UpdateTime = DateTime.Now;
  5808. entity.Update();
  5809. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5810. //还要插入快递信息到 快递信息表
  5811. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5812. exinfo.tid = entity.ctid;
  5813. exinfo.out_sid = curUseWayBillCode;
  5814. exinfo.company_code = cpCode;
  5815. exinfo.company_name = cpName;
  5816. exinfo.supplierUserName = supplierName;
  5817. exinfo.deliveryType = "发货成功";
  5818. exinfo.print_time = DateTime.Now;
  5819. exinfo.printUser = CurrentUser.UserName;
  5820. exinfo.postData = pData_str;
  5821. exinfo.Create();
  5822. commonHelper.UpdateRelationOrder(entity.ctid);
  5823. CeErpSukuraData.createInfo(ctid, 4);
  5824. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5825. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5826. {
  5827. commonHelper.sendCytExpress(exinfo);
  5828. }
  5829. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5830. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5831. }
  5832. catch (Exception ex)
  5833. {
  5834. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5835. }
  5836. }
  5837. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5838. {
  5839. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5840. if (entity.OrderState == 6)
  5841. {
  5842. entity.OrderState = 7;
  5843. }
  5844. entity.UpdateTime = DateTime.Now;
  5845. entity.FinishDeliveryTime = DateTime.Now;
  5846. btnType = "已发货";
  5847. entity.Update();
  5848. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5849. exinfo.tid = entity.ctid;
  5850. exinfo.out_sid = curUseWayBillCode;
  5851. exinfo.company_code = cpCode;
  5852. exinfo.company_name = cpName;
  5853. exinfo.supplierUserName = supplierName;
  5854. exinfo.deliveryType = "发货成功";
  5855. exinfo.print_time = DateTime.Now;
  5856. exinfo.printUser = CurrentUser.UserName;
  5857. exinfo.postData = pData_str;
  5858. exinfo.Create();
  5859. commonHelper.UpdateRelationOrder(entity.ctid);
  5860. CeErpSukuraData.createInfo(entity.ctid, 4);
  5861. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  5862. {
  5863. commonHelper.sendCytExpress(exinfo);
  5864. }
  5865. //不处理
  5866. }
  5867. else
  5868. {
  5869. entity.UpdateTime = DateTime.Now;
  5870. entity.LastBillCpCode = cpCode;
  5871. entity.LastBillWaybillCode = curUseWayBillCode;
  5872. entity.Update();
  5873. string errmsg = commonHelper.KeepChinese(apires);
  5874. var res_objz = new
  5875. {
  5876. restype = 0,
  5877. data = "打单后发货失败"
  5878. };
  5879. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5880. returnSuccess(ro_jsonz);
  5881. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5882. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5883. return;
  5884. }
  5885. }
  5886. }
  5887. else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
  5888. {
  5889. string ctids = GetPostString("ctids");
  5890. DataTable dt = commonHelper.getSameOrderList(entity, mainEn);
  5891. List<string> list = new List<string>();
  5892. List<string> send_list = new List<string>();
  5893. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  5894. CeErpTrade ceErpTrade = new CeErpTrade();
  5895. //可合包的合并一起发货
  5896. if (dt == null && string.IsNullOrEmpty(ctids))
  5897. {
  5898. var res_objz = new
  5899. {
  5900. restype = 0,
  5901. data = "打单后发货失败"
  5902. };
  5903. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5904. returnSuccess(ro_jsonz);
  5905. return;
  5906. }
  5907. if (!string.IsNullOrEmpty(ctids))
  5908. {
  5909. StringBuilder sql = new StringBuilder();
  5910. sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where ctid in ({0})", "'" + ctids.Replace(",", "','") + "'");
  5911. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  5912. }
  5913. foreach (DataRow row in dt.Rows)
  5914. {
  5915. list.Add("'" + row["ctid"] + "'");
  5916. ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
  5917. ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  5918. if (ctid.IndexOf("N") != -1)
  5919. {
  5920. apires = "发货成功";
  5921. }
  5922. else
  5923. {
  5924. if (!send_list.Contains(ceErpTrade.tid))
  5925. {
  5926. apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5927. }
  5928. else
  5929. {
  5930. apires = "发货成功";
  5931. }
  5932. }
  5933. if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5934. {
  5935. send_list.Add(ceErpTrade.tid);
  5936. try
  5937. {
  5938. btnType = "待发货";
  5939. ceErpTradeCell.OutSid = curUseWayBillCode;
  5940. ceErpTradeCell.OrderState = 7;
  5941. ceErpTradeCell.IsUrgency = false;
  5942. ceErpTradeCell.LastBillCpCode = "";
  5943. ceErpTradeCell.LastBillWaybillCode = "";
  5944. ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
  5945. ceErpTradeCell.IsReturn = 0;
  5946. ceErpTradeCell.MemoOpt = 0;
  5947. ceErpTradeCell.UpdateTime = DateTime.Now;
  5948. ceErpTradeCell.Update();
  5949. commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
  5950. //还要插入快递信息到 快递信息表
  5951. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5952. exinfo.tid = ceErpTradeCell.ctid;
  5953. exinfo.out_sid = curUseWayBillCode;
  5954. exinfo.company_code = cpCode;
  5955. exinfo.company_name = cpName;
  5956. exinfo.supplierUserName = supplierName;
  5957. exinfo.deliveryType = "发货成功";
  5958. exinfo.print_time = DateTime.Now;
  5959. exinfo.printUser = CurrentUser.UserName;
  5960. exinfo.postData = pData_str;
  5961. exinfo.Create();
  5962. commonHelper.UpdateRelationOrder(ceErpTradeCell.ctid);
  5963. CeErpSukuraData.createInfo(ctid, 4);
  5964. commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
  5965. if (ceErpTradeCell.SupplierId == 64 || ceErpTradeCell.SupplierId == 80 || entity.SupplierId == 126)
  5966. {
  5967. commonHelper.sendCytExpress(exinfo);
  5968. }
  5969. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5970. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5971. }
  5972. catch (Exception ex)
  5973. {
  5974. XLog.SaveLog(0, "发货成功后更新数据失败," + ex);
  5975. }
  5976. }
  5977. else
  5978. {
  5979. ceErpTradeCell.UpdateTime = DateTime.Now;
  5980. ceErpTradeCell.LastBillCpCode = cpCode;
  5981. ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
  5982. ceErpTradeCell.Update();
  5983. string errmsg = commonHelper.KeepChinese(apires);
  5984. XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
  5985. errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
  5986. }
  5987. }
  5988. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
  5989. }
  5990. }
  5991. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5992. var res_obj = new
  5993. {
  5994. restype = 1,
  5995. data = pData_str,
  5996. errorMsg
  5997. };
  5998. string ro_json = JsonConvert.SerializeObject(res_obj);
  5999. ReturnSuccess(ro_json);
  6000. return;
  6001. }
  6002. }
  6003. private string GetUTF8String(byte[] vs)
  6004. {
  6005. throw new NotImplementedException();
  6006. }
  6007. public void set_erp_printwaybill_cn()
  6008. {
  6009. if (UrlPostParmsCheck("ctid"))
  6010. {
  6011. string ctid = GetPostString("ctid");
  6012. string cpCode = GetPostString("cpcode");
  6013. string cpName = GetPostString("cpname");
  6014. string tempUrl = GetPostString("tempurl");
  6015. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6016. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  6017. //string res = taobaoHelper.test();
  6018. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6019. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  6020. {
  6021. int sidx = res.IndexOf("errorMsg");
  6022. int eidx = res.IndexOf("}");
  6023. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  6024. var res_objzxx = new
  6025. {
  6026. restype = 0,
  6027. data = msg
  6028. };
  6029. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  6030. returnSuccess(ro_jsonzxx);
  6031. //returnErrorMsg(msg);
  6032. return;
  6033. }
  6034. int idx = res.IndexOf("waybillCode");
  6035. int idx2 = res.IndexOf("printData");
  6036. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  6037. string eid = GetPostString("ctid");
  6038. CeErpTradeCell entity = null;
  6039. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6040. if (entity != null)
  6041. {
  6042. string osid = entity.OutSid;
  6043. entity.OutSid = osid + "," + outsid;
  6044. entity.FinishDeliveryTime = DateTime.Now;
  6045. entity.OrderState = 7;
  6046. entity.UpdateTime = DateTime.Now;
  6047. entity.IsReturn = 0;
  6048. entity.Update();
  6049. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  6050. exinfo.tid = entity.ctid;
  6051. exinfo.out_sid = outsid;
  6052. exinfo.company_code = cpCode;
  6053. exinfo.company_name = cpName;
  6054. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  6055. exinfo.deliveryType = "发货成功";
  6056. exinfo.print_time = DateTime.Now;
  6057. exinfo.printUser = CurrentUser.UserName;
  6058. exinfo.Create();
  6059. if (entity.SupplierId == 64 || entity.SupplierId == 80 || entity.SupplierId == 126)
  6060. {
  6061. commonHelper.sendCytExpress(exinfo);
  6062. }
  6063. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  6064. }
  6065. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  6066. var res_objz = new
  6067. {
  6068. restype = 1,
  6069. data = res
  6070. };
  6071. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  6072. returnSuccess(ro_jsonz);
  6073. //ReturnSuccess(res);
  6074. }
  6075. }
  6076. ////打单,打印面单 获取面单号
  6077. //public void set_erp_printwaybill()
  6078. //{
  6079. // if (UrlPostParmsCheck("ctid"))
  6080. // {
  6081. // string ctid = GetPostString("ctid");
  6082. // string cpCode = GetPostString("cpcode");
  6083. // string tempUrl = GetPostString("tempurl");
  6084. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  6085. // //string res = taobaoHelper.test();
  6086. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  6087. // if (res.IndexOf("error_response") != -1)
  6088. // {
  6089. // int sidx = res.IndexOf("sub_msg");
  6090. // int eidx = res.IndexOf("request_id");
  6091. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  6092. // returnErrorMsg(msg);
  6093. // return;
  6094. // }
  6095. // int idx = res.IndexOf("waybill_code");
  6096. // int idx2 = res.IndexOf("}]}");
  6097. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  6098. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  6099. // ReturnSuccess(res);
  6100. // }
  6101. //}
  6102. public void cancel_erp_aftersale()
  6103. {
  6104. if (UrlPostParmsCheck("ctid"))
  6105. {
  6106. string eid = GetPostString("ctid");
  6107. CeErpTradeCell entity = null;
  6108. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6109. if (entity != null)
  6110. {
  6111. //有过处理的售后,取消也不能删除 售 字,保留
  6112. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  6113. {
  6114. entity.AfterSaleState = 4;
  6115. }
  6116. else
  6117. entity.AfterSaleState = 0;
  6118. entity.UpdateTime = DateTime.Now;
  6119. entity.Update();
  6120. returnSuccessMsg("操作成功!");
  6121. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  6122. return;
  6123. }
  6124. returnErrorMsg("找不到订单记录");
  6125. }
  6126. }
  6127. public void get_erp_aftersalelist()
  6128. {
  6129. DataStruct dStruct = GetPostStruct();
  6130. List<string> lw = new List<string>();
  6131. int st = GetInt("st");
  6132. string tid = GetPostString("ctid");
  6133. if (st == 3)
  6134. {
  6135. if (tid.Length > 0)
  6136. {
  6137. string select_tid = getTidByCtid(tid);
  6138. lw.Add(string.Format("tid='{0}'", select_tid));
  6139. }
  6140. }
  6141. else
  6142. {
  6143. if (tid.Length > 0)
  6144. {
  6145. string select_tid = getTidByCtid(tid);
  6146. lw.Add(string.Format("tid='{0}'", select_tid));
  6147. }
  6148. }
  6149. string shopname = GetPostString("shopname");
  6150. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6151. string buyernick = GetPostString("buyer_nick");
  6152. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  6153. string sellermemo = GetPostString("seller_memo");
  6154. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6155. string orderState = GetPostString("orderState");
  6156. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  6157. string afterState = GetPostString("afterstate");
  6158. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6159. string date1 = GetPostString("date1");
  6160. string date2 = GetPostString("date2");
  6161. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6162. if (dw.Length > 0) lw.Add(dw);
  6163. string price1 = GetPostString("price1");
  6164. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6165. string price2 = GetPostString("price2");
  6166. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6167. //lw.Add(string.Format("IsRefund!={0}", 1));
  6168. string reason = GetPostString("reason");
  6169. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6170. string method = GetPostString("method");
  6171. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6172. string handler = GetPostString("handler");
  6173. if (handler.Length > 0)
  6174. {
  6175. lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6176. }
  6177. string handledate1 = GetPostString("handledate1");
  6178. string handledate2 = GetPostString("handledate2");
  6179. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6180. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6181. string finish1 = GetPostString("finishdate1");
  6182. string finish2 = GetPostString("finishdate2");
  6183. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6184. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6185. string afterdate1 = GetPostString("afterdate1");
  6186. string afterdate2 = GetPostString("afterdate2");
  6187. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6188. if (afterDate.Length > 0) lw.Add(afterDate);
  6189. string supplier = GetPostString("supplier");
  6190. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6191. string responsible = GetPostString("responsibleman");
  6192. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6193. string customer = GetPostString("customer");
  6194. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6195. string design = GetPostString("design");
  6196. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6197. string afterMemoType = GetPostString("aftermemotype");
  6198. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6199. string posCode = CurrentUser.UserPost.Post.Code;
  6200. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  6201. //{
  6202. // string vstate = GetPostString("vstate");
  6203. // if (vstate.Length > 0)
  6204. // {
  6205. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6206. // }
  6207. // if (posCode == "Supplier")
  6208. // {
  6209. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6210. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6211. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6212. // }
  6213. // else
  6214. // {
  6215. // lw.Add(string.Format("AfterSaleState = {0}", st));
  6216. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  6217. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  6218. // {
  6219. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  6220. // }
  6221. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  6222. // {
  6223. // int orgid = CurrentUser.UserPost.OrgID;
  6224. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  6225. // }
  6226. // else if (CurrentUser.UserPost.Post.Code == "Director")
  6227. // {
  6228. // string shopid = CurrentUser.User.pemShop;
  6229. // lw.Add(string.Format("shopId in ({0})", shopid));
  6230. // }
  6231. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6232. // //{
  6233. // // int org_id = CurrentUser.UserPost.OrgID;
  6234. // // lw.Add(string.Format("OrgID={0}", org_id));
  6235. // //}
  6236. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  6237. // }
  6238. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6239. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6240. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6241. //}
  6242. if (st == 5)
  6243. {
  6244. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  6245. {
  6246. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  6247. {
  6248. string shopid = CurrentUser.User.pemShop;
  6249. lw.Add(string.Format("shopId in ({0})", shopid));
  6250. }
  6251. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  6252. {
  6253. int mrOrgid = CurrentUser.UserPost.OrgID;
  6254. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  6255. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  6256. }
  6257. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  6258. //{
  6259. // int mrOrgid = CurrentUser.UserPost.OrgID;
  6260. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  6261. //}
  6262. else
  6263. {
  6264. string userIdStr = "";
  6265. if (posCode == "CustomerService")
  6266. {
  6267. userIdStr = CurrentUser.UserID + "_k";
  6268. }
  6269. else if (posCode == "Designer" || posCode == "wxDesigner")
  6270. {
  6271. userIdStr = CurrentUser.UserID + "_s";
  6272. }
  6273. else if (posCode == "Place")
  6274. {
  6275. userIdStr = CurrentUser.UserID + "_x";
  6276. }
  6277. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  6278. }
  6279. }
  6280. string placedate1 = GetPostString("placedate1");
  6281. string placedate2 = GetPostString("placedate2");
  6282. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  6283. if (dwplace.Length > 0) lw.Add(dwplace);
  6284. string supState = GetPostString("supState");
  6285. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  6286. string searchType = GetPostString("searchType");
  6287. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  6288. {
  6289. lw.Add(string.Format("BackNum>1"));
  6290. }
  6291. lw.Add(string.Format("AfterSaleState>0"));
  6292. if (ex_psize > 0)
  6293. {
  6294. if (CurrentUser.UserPost.Post.Code == "Finance")
  6295. dStruct.Order = "pay_time desc";
  6296. else
  6297. dStruct.Order = "HandleTime desc";
  6298. }
  6299. else
  6300. dStruct.Order = "HandleTime desc";
  6301. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6302. DataTable dt = WebCache.GetData("view_test", dStruct);
  6303. writeGridDataTableJson(dStruct.TotalCount, dt);
  6304. }
  6305. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  6306. //{
  6307. // lw.Add(string.Format("AfterSaleState=4"));
  6308. // string code = CurrentUser.UserPost.Post.Code;
  6309. // if (code == "CustomerService")
  6310. // {
  6311. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  6312. // }
  6313. // else if (code == "Designer" || code == "DesignerMr")
  6314. // {
  6315. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  6316. // }
  6317. // else if (code == "Place" || code == "PlaceMr")
  6318. // {
  6319. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  6320. // }
  6321. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6322. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6323. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6324. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6325. //}
  6326. //else //处理中的售后,待处理和处理中合并
  6327. //{
  6328. // if (afterState.Length <= 0)
  6329. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6330. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6331. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6332. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6333. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6334. //}
  6335. }
  6336. public void get_erp_disagreeftersalelist()
  6337. {
  6338. DataStruct dStruct = GetPostStruct();
  6339. List<string> lw = new List<string>();
  6340. int st = 2;
  6341. string tid = GetPostString("ctid");
  6342. if (tid.Length > 0)
  6343. {
  6344. string select_tid = getTidByCtid(tid);
  6345. lw.Add(string.Format("tid='{0}'", select_tid));
  6346. }
  6347. string shopname = GetPostString("shopname");
  6348. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6349. string buyernick = GetPostString("buyer_nick");
  6350. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6351. string sellermemo = GetPostString("seller_memo");
  6352. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6353. string orderState = GetPostString("orderState");
  6354. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6355. string afterState = GetPostString("afterstate");
  6356. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6357. string date1 = GetPostString("date1");
  6358. string date2 = GetPostString("date2");
  6359. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6360. if (dw.Length > 0) lw.Add(dw);
  6361. string price1 = GetPostString("price1");
  6362. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6363. string price2 = GetPostString("price2");
  6364. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6365. //lw.Add(string.Format("IsRefund!={0}", 1));
  6366. string reason = GetPostString("reason");
  6367. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6368. string method = GetPostString("method");
  6369. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6370. string handler = GetPostString("handler");
  6371. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6372. string handledate1 = GetPostString("handledate1");
  6373. string handledate2 = GetPostString("handledate2");
  6374. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6375. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6376. string afterdate1 = GetPostString("afterdate1");
  6377. string afterdate2 = GetPostString("afterdate2");
  6378. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6379. if (afterDate.Length > 0) lw.Add(afterDate);
  6380. string backdate1 = GetPostString("backdate1");
  6381. string backdate2 = GetPostString("backdate2");
  6382. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  6383. if (backDate.Length > 0) lw.Add(backDate);
  6384. string supplier = GetPostString("supplier");
  6385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6386. string responsible = GetPostString("responsibleman");
  6387. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6388. string customer = GetPostString("customer");
  6389. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6390. string design = GetPostString("design");
  6391. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6392. string afterSaleMemo = GetPostString("afterSaleMemo");
  6393. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6394. string afterMemoType = GetPostString("aftermemotype");
  6395. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6396. string aftersakereason = GetPostString("aftersakereason");
  6397. if (aftersakereason.Length > 0)
  6398. {
  6399. if (aftersakereason == "1")
  6400. {
  6401. lw.Add(string.Format("AfterSaleResSupId > 0"));
  6402. }
  6403. if (aftersakereason == "2")
  6404. {
  6405. lw.Add(string.Format("AfterSaleResSupId = 0"));
  6406. }
  6407. }
  6408. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6409. string poscode = CurrentUser.UserPost.Post.Code;
  6410. if (poscode != "SysAdmin")
  6411. {
  6412. string shopid = CurrentUser.User.pemShop;
  6413. lw.Add(string.Format("shopId in ({0})", shopid));
  6414. }
  6415. string searchType = GetPostString("searchType");
  6416. if (searchType == "wait")
  6417. {
  6418. lw.Add(string.Format("HandleTime is null"));
  6419. }
  6420. if (searchType == "handling")
  6421. {
  6422. lw.Add(string.Format("HandleTime is not null "));
  6423. }
  6424. if (searchType == "back" || searchType == "puBack")
  6425. {
  6426. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6427. }
  6428. if (searchType == "reBack")
  6429. {
  6430. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6431. }
  6432. if (searchType == "moreBack")
  6433. {
  6434. lw.Add(string.Format("backNum > 1"));
  6435. }
  6436. lw.Add(string.Format("(AfterSaleState=5)"));
  6437. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  6438. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6439. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6440. writeGridDataTableJson(dStruct.TotalCount, dt);
  6441. }
  6442. public void get_erp_handlingaftersalelist()
  6443. {
  6444. DataStruct dStruct = GetPostStruct();
  6445. List<string> lw = new List<string>();
  6446. int st = 2;
  6447. string tid = GetPostString("ctid");
  6448. if (tid.Length > 0)
  6449. {
  6450. string select_tid = getTidByCtid(tid);
  6451. lw.Add(string.Format("tid='{0}'", select_tid));
  6452. }
  6453. string shopname = GetPostString("shopname");
  6454. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6455. string buyernick = GetPostString("buyer_nick");
  6456. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6457. string sellermemo = GetPostString("seller_memo");
  6458. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6459. string orderState = GetPostString("orderState");
  6460. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6461. string afterState = GetPostString("afterstate");
  6462. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6463. string date1 = GetPostString("date1");
  6464. string date2 = GetPostString("date2");
  6465. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6466. if (dw.Length > 0) lw.Add(dw);
  6467. string price1 = GetPostString("price1");
  6468. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6469. string price2 = GetPostString("price2");
  6470. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6471. //lw.Add(string.Format("IsRefund!={0}", 1));
  6472. string reason = GetPostString("reason");
  6473. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6474. string method = GetPostString("method");
  6475. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6476. string handler = GetPostString("handler");
  6477. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6478. string handledate1 = GetPostString("handledate1");
  6479. string handledate2 = GetPostString("handledate2");
  6480. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6481. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6482. string afterdate1 = GetPostString("afterdate1");
  6483. string afterdate2 = GetPostString("afterdate2");
  6484. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6485. if (afterDate.Length > 0) lw.Add(afterDate);
  6486. string supplier = GetPostString("supplier");
  6487. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6488. string responsible = GetPostString("responsibleman");
  6489. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6490. string customer = GetPostString("customer");
  6491. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6492. string design = GetPostString("design");
  6493. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6494. string afterSaleMemo = GetPostString("afterSaleMemo");
  6495. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6496. string afterMemoType = GetPostString("aftermemotype");
  6497. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6498. string afterresult = GetPostString("afterresult");
  6499. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  6500. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  6501. string poscode = CurrentUser.UserPost.Post.Code;
  6502. if (poscode != "SysAdmin")
  6503. {
  6504. string shopid = CurrentUser.User.pemShop;
  6505. lw.Add(string.Format("shopId in ({0})", shopid));
  6506. }
  6507. string searchType = GetPostString("searchType");
  6508. if (searchType == "wait")
  6509. {
  6510. lw.Add(string.Format("HandleTime is null"));
  6511. }
  6512. if (searchType == "documentary")
  6513. {
  6514. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6515. }
  6516. if (searchType == "handling")
  6517. {
  6518. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6519. }
  6520. if (searchType == "back" || searchType == "puBack")
  6521. {
  6522. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6523. }
  6524. if (searchType == "reBack")
  6525. {
  6526. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6527. }
  6528. if (afterState.Length <= 0)
  6529. {
  6530. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6531. }
  6532. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6533. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6534. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6535. writeGridDataTableJson(dStruct.TotalCount, dt);
  6536. }
  6537. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6538. //public void get_erp_back_handlingaftersalelist()
  6539. //{
  6540. // DataStruct dStruct = GetPostStruct();
  6541. // List<string> lw = new List<string>();
  6542. // string tid = GetPostString("ctid");
  6543. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6544. // string shopname = GetPostString("shopname");
  6545. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6546. // string buyernick = GetPostString("buyer_nick");
  6547. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6548. // string sellermemo = GetPostString("seller_memo");
  6549. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6550. // string orderState = GetPostString("orderState");
  6551. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6552. // string afterState = GetPostString("afterstate");
  6553. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6554. // string date1 = GetPostString("date1");
  6555. // string date2 = GetPostString("date2");
  6556. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6557. // if (dw.Length > 0) lw.Add(dw);
  6558. // string price1 = GetPostString("price1");
  6559. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6560. // string price2 = GetPostString("price2");
  6561. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6562. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6563. // string reason = GetPostString("reason");
  6564. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6565. // string method = GetPostString("method");
  6566. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6567. // string handler = GetPostString("handler");
  6568. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6569. // string handledate1 = GetPostString("handledate1");
  6570. // string handledate2 = GetPostString("handledate2");
  6571. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6572. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6573. // string afterdate1 = GetPostString("afterdate1");
  6574. // string afterdate2 = GetPostString("afterdate2");
  6575. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6576. // if (afterDate.Length > 0) lw.Add(afterDate);
  6577. // string supplier = GetPostString("supplier");
  6578. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6579. // string responsible = GetPostString("responsibleman");
  6580. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6581. // string customer = GetPostString("customer");
  6582. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6583. // string design = GetPostString("design");
  6584. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6585. // string afterMemoType = GetPostString("aftermemotype");
  6586. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6587. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6588. // if (afterState.Length <= 0)
  6589. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6590. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6591. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6592. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6593. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6594. //}
  6595. public void get_erp_aftersaleverifylist()
  6596. {
  6597. DataStruct dStruct = GetPostStruct();
  6598. List<string> lw = new List<string>();
  6599. string tid = GetPostString("ctid");
  6600. if (tid.Length > 0)
  6601. {
  6602. string select_tid = getTidByCtid(tid);
  6603. lw.Add(string.Format("otid='{0}'", select_tid));
  6604. }
  6605. string shopname = GetPostString("shopname");
  6606. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6607. string buyernick = GetPostString("buyer_nick");
  6608. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6609. string sellermemo = GetPostString("seller_memo");
  6610. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6611. string orderState = GetPostString("orderState");
  6612. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6613. //lw.Add(string.Format("IsRefund!={0}", 1));
  6614. string reason = GetPostString("reason");
  6615. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6616. string method = GetPostString("method");
  6617. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6618. string handler = GetPostString("handler");
  6619. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6620. string handledate1 = GetPostString("handledate1");
  6621. string handledate2 = GetPostString("handledate2");
  6622. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6623. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6624. string finish1 = GetPostString("finishdate1");
  6625. string finish2 = GetPostString("finishdate2");
  6626. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6627. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6628. string supplier = GetPostString("supplier");
  6629. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6630. string responsible = GetPostString("responsibleman");
  6631. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6632. string posCode = CurrentUser.UserPost.Post.Code;
  6633. string vstate = GetPostString("vstate");
  6634. if (vstate.Length > 0)
  6635. {
  6636. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6637. }
  6638. if (posCode == "Supplier")
  6639. {
  6640. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6641. lw.Add(string.Format("VerifyState = 0"));
  6642. lw.Add("type = 1");
  6643. lw.Add(string.Format("AfterSaleState={0}", 3));
  6644. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6645. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6646. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6647. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6648. writeGridDataTableJson(dStruct.TotalCount, dt);
  6649. }
  6650. else if (posCode == "logistics")
  6651. {
  6652. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6653. lw.Add(string.Format("VerifyState = 0"));
  6654. lw.Add("type = 2");
  6655. lw.Add(string.Format("AfterSaleState={0}", 3));
  6656. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6657. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6658. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6659. writeGridDataTableJson(dStruct.TotalCount, dt);
  6660. }
  6661. else
  6662. {
  6663. lw.Add(string.Format("(AfterSaleState = 3)"));
  6664. lw.Add("type = 0");
  6665. string reasonState = GetPostString("reasonState");
  6666. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "Summarize" || posCode == "Finance")
  6667. {
  6668. if (reasonState == "2")
  6669. {
  6670. lw.Add("VerifyState = 3");
  6671. }
  6672. else if (reasonState == "1")
  6673. {
  6674. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6675. }
  6676. else
  6677. {
  6678. lw.Add("VerifyState in (0,3)");
  6679. }
  6680. //不加条件,可以看全部
  6681. }
  6682. 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")
  6683. {
  6684. int orgid = CurrentUser.UserPost.OrgID;
  6685. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6686. if (string.IsNullOrEmpty(manageOrgId))
  6687. {
  6688. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6689. }
  6690. else
  6691. {
  6692. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6693. }
  6694. if (reasonState == "1")
  6695. {
  6696. lw.Add("VerifyState = 3");
  6697. }
  6698. else if (reasonState == "2")
  6699. {
  6700. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6701. }
  6702. else
  6703. {
  6704. }
  6705. }
  6706. else
  6707. {
  6708. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6709. }
  6710. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6711. //{
  6712. // int org_id = CurrentUser.UserPost.OrgID;
  6713. // lw.Add(string.Format("OrgID={0}", org_id));
  6714. //}
  6715. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6716. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6717. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6718. writeGridDataTableJson(dStruct.TotalCount, dt);
  6719. }
  6720. }
  6721. public void get_erp_finishaftersalelist()
  6722. {
  6723. DataStruct dStruct = GetPostStruct();
  6724. List<string> lw = new List<string>();
  6725. int st = 4;
  6726. string tid = GetPostString("ctid");
  6727. if (tid.Length > 0)
  6728. {
  6729. string select_tid = getTidByCtid(tid);
  6730. lw.Add(string.Format("otid='{0}'", select_tid));
  6731. }
  6732. string shopname = GetPostString("shopname");
  6733. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6734. //lw.Add(string.Format("IsRefund!={0}", 1));
  6735. string reason = GetPostString("reason");
  6736. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6737. string method = GetPostString("method");
  6738. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6739. string buyernick = GetPostString("buyer_nick");
  6740. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6741. string handler = GetPostString("handler");
  6742. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6743. string handledate1 = GetPostString("handledate1");
  6744. string handledate2 = GetPostString("handledate2");
  6745. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6746. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6747. string finish1 = GetPostString("finishdate1");
  6748. string finish2 = GetPostString("finishdate2");
  6749. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6750. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6751. string supplier = GetPostString("supplier");
  6752. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  6753. string responsible = GetPostString("responsibleman");
  6754. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6755. string vstate = GetPostString("vstate");
  6756. if (vstate.Length > 0)
  6757. {
  6758. if ("3".Equals(vstate))
  6759. {
  6760. lw.Add(string.Format("IsTem=1"));
  6761. }
  6762. else
  6763. {
  6764. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6765. }
  6766. }
  6767. lw.Add(string.Format("AfterSaleState=4"));
  6768. string code = CurrentUser.UserPost.Post.Code;
  6769. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6770. {
  6771. //不加条件,可以看全部
  6772. }
  6773. else if (code == "Supplier")
  6774. {
  6775. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6776. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6777. lw.Add("type = 1");
  6778. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6779. }
  6780. else if (code == "logistics")
  6781. {
  6782. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6783. lw.Add("type = 2");
  6784. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6785. }
  6786. 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")
  6787. {
  6788. lw.Add("type = 0");
  6789. int orgid = CurrentUser.UserPost.OrgID;
  6790. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6791. if (string.IsNullOrEmpty(manageOrgIds))
  6792. {
  6793. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6794. }
  6795. else
  6796. {
  6797. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6798. }
  6799. }
  6800. else
  6801. {
  6802. lw.Add("type = 0");
  6803. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6804. }
  6805. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6806. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6807. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6808. writeGridDataTableJson(dStruct.TotalCount, dt);
  6809. }
  6810. public void handle_erp_aftersale()
  6811. {
  6812. if (UrlPostParmsCheck("ctid"))
  6813. {
  6814. string eid = GetPostString("ctid");
  6815. string responStr = GetPostString("AfterSaleResponsible");
  6816. if (responStr.Length <= 0)
  6817. {
  6818. returnErrorMsg("售后责任人不能为空");
  6819. return;
  6820. }
  6821. bool isDesign = false;
  6822. double designFree = 0.00;
  6823. int responsibleId = 0;
  6824. CeErpTradeCell entity = null;
  6825. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6826. if (entity != null)
  6827. {
  6828. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6829. string afterMethod = GetPostString("AfterSaleMethod");
  6830. if (isNeedNewOrder == 1)
  6831. {
  6832. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6833. bool ishav = true;
  6834. if (newentity == null)
  6835. {
  6836. newentity = entity.Clone() as CeErpTradeCell;
  6837. ishav = false;
  6838. newentity.ctid = "S_" + entity.ctid;
  6839. newentity.OrderState = 0;
  6840. //唯一标识
  6841. newentity.OrderSn = newentity.ctid;
  6842. string orderSn = dataHelper.getSaleOrderSn();
  6843. if (orderSn != "")
  6844. {
  6845. newentity.OrderSn = orderSn;
  6846. }
  6847. }
  6848. newentity.UpdateTime = DateTime.Now;
  6849. newentity.AfterSaleState = 0;
  6850. newentity.AfterSaleMethod = afterMethod;
  6851. if (!ishav)
  6852. {
  6853. string memo_str = newentity.seller_memo;
  6854. memo_str = memo_str.Replace("(", "(");
  6855. memo_str = memo_str.Replace(")", ")");
  6856. int sIndex = memo_str.IndexOf("(");
  6857. int eIndex = memo_str.IndexOf(")");
  6858. if (sIndex == -1 || eIndex == -1)
  6859. {
  6860. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6861. return;
  6862. }
  6863. string first = memo_str.Substring(0, sIndex + 1);
  6864. string memoCtid = newentity.OrderSn;
  6865. //if (memoCtid.IndexOf("C") != -1)
  6866. //{
  6867. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6868. //if (CIdx.IndexOf("+") != -1)
  6869. //{
  6870. //CIdx = "C" + CIdx.Split('+')[1];
  6871. //}
  6872. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6873. //}
  6874. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6875. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6876. string newMemo = first + memoCtid + last;
  6877. newentity.seller_memo = newMemo;
  6878. newentity.FinishPlaceTime = null;
  6879. newentity.UnusualTag = 0;
  6880. newentity.UnusualCon = "";
  6881. newentity.UnusualTime = null;
  6882. newentity.AfterSaleMemo = "";
  6883. newentity.AfterSaleMethod = afterMethod;
  6884. newentity.AfterSalePreTime = null;
  6885. newentity.AfterSaleReason = "";
  6886. newentity.AfterSaleResponsible = "";
  6887. newentity.AfterSaleState = 0;
  6888. newentity.AfterSaleTime = null;
  6889. newentity.AfterSaleUserId = 0;
  6890. newentity.AfterSaleSupplierState = 0;
  6891. newentity.LastBillWaybillCode = "";
  6892. newentity.LastBillCpCode = "";
  6893. newentity.FinishAfterSaleTime = null;
  6894. newentity.HandleTime = null;
  6895. newentity.IsSF = 0;
  6896. newentity.IsOldCustomer = 0;
  6897. newentity.UrgencyTime = null;
  6898. newentity.ResponsibleUserId = "";
  6899. newentity.IsVerifyToSupplier = false;
  6900. newentity.payment = 0;
  6901. newentity.CheckMemo = "";
  6902. newentity.OutSid = "";
  6903. newentity.CheckOrderTime = null;
  6904. newentity.MemoOpt = 0;
  6905. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6906. }
  6907. newentity.isAfterSaleOrder = 1;
  6908. newentity.IsRefund = 0;
  6909. string receiveMobile = GetPostString("receiver_mobile");
  6910. if (receiveMobile.Length > 0)
  6911. {
  6912. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6913. if (trade != null)
  6914. {
  6915. trade.receiver_name = GetPostString("receiver_name");
  6916. trade.receiver_mobile = receiveMobile;
  6917. trade.receiver_state = GetPostString("receiver_state");
  6918. trade.receiver_city = GetPostString("receiver_city");
  6919. trade.receiver_district = GetPostString("receiver_district");
  6920. trade.receiver_address = GetPostString("receiver_address");
  6921. newentity.IsOffLineOrder = 1;
  6922. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6923. }
  6924. }
  6925. string st = GetPostString("ToState");
  6926. if (st.Length > 0)
  6927. {
  6928. if (newentity.OrderState <= 3)
  6929. {
  6930. newentity.WaitDesignTime = DateTime.Now;
  6931. newentity.StartDesignTime = null;
  6932. newentity.FinishDesignTime = null;
  6933. newentity.OrderState = 3;
  6934. if (st == "下单员")
  6935. {
  6936. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6937. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6938. {
  6939. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6940. }
  6941. }
  6942. else
  6943. {
  6944. newentity.WaitDesignTime = DateTime.Now;
  6945. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6946. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6947. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6948. {
  6949. DataRow user = dt1.Rows[0];
  6950. //找主管
  6951. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6952. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6953. if (dt != null && dt.Rows.Count > 0)
  6954. {
  6955. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6956. newentity.DesignUserId = designMr;
  6957. string key = "aftersale_order_" + designMr;
  6958. if (RedisHelper.HasKey(key))
  6959. {
  6960. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6961. list.Add(newentity.ctid);
  6962. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6963. }
  6964. }
  6965. //账号正常
  6966. if (user["State"].ToString() == "0")
  6967. {
  6968. newentity.DesignUserId = entity.DesignUserId;
  6969. string key = "aftersale_order_" + entity.DesignUserId;
  6970. if (RedisHelper.HasKey(key))
  6971. {
  6972. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6973. list.Add(newentity.ctid);
  6974. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6975. }
  6976. }
  6977. }
  6978. }
  6979. }
  6980. if (entity.IsXianHuo == 1)
  6981. {
  6982. newentity.OrderState = 6;
  6983. entity.FinishPlaceTime = DateTime.Now;
  6984. }
  6985. }
  6986. if (ishav)
  6987. {
  6988. newentity.Update();
  6989. }
  6990. else
  6991. {
  6992. newentity.Create();
  6993. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6994. newCellExtend.ctid = newentity.ctid;
  6995. newCellExtend.orderFrom = 20;
  6996. newCellExtend.orderType = 30;
  6997. if (st == "下单员")
  6998. {
  6999. }
  7000. else
  7001. {
  7002. newCellExtend.ReprintTime = DateTime.Now;
  7003. }
  7004. newCellExtend.Create();
  7005. }
  7006. if (st != "下单员")
  7007. {
  7008. if (entity.DispatchSort == 2)
  7009. {
  7010. designApiResponseVo response = designHelper.API_GetPrintData_CreateAfterOrder(newentity);
  7011. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后单生成指派:" + response.msg, newentity.OrderState, 1);
  7012. }
  7013. }
  7014. }
  7015. //处理售后扩展
  7016. string resIdStr = GetPostString("ResponsibleUserId");
  7017. string refundFees = GetPostString("refundFrees");
  7018. int IsComplain = GetPostInt("isComplain");
  7019. int IsBad = GetPostInt("isBad");
  7020. string IsOriginal = GetPostString("isOriginal");
  7021. double diffResultPrice = GetPostDouble("diffResultPrice");
  7022. string textResult = GetPostString("textResult");
  7023. string supplierResponsible = GetPostString("supplierResponsible");
  7024. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  7025. if (ceErpTradeAfterSaleExtend == null)
  7026. {
  7027. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7028. ceErpTradeAfterSaleExtend.tid = eid;
  7029. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7030. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7031. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7032. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7033. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7034. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7035. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7036. ceErpTradeAfterSaleExtend.Create();
  7037. }
  7038. else
  7039. {
  7040. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  7041. {
  7042. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  7043. }
  7044. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  7045. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  7046. ceErpTradeAfterSaleExtend.TextResult = textResult;
  7047. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  7048. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  7049. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  7050. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  7051. ceErpTradeAfterSaleExtend.Update();
  7052. }
  7053. int gysid = GetPostInt("ResponsibleSupId");
  7054. if (entity.AfterSaleUserId == 0)
  7055. {
  7056. entity.AfterSaleUserId = CurrentUser.UserID;
  7057. }
  7058. entity.ResponsibleUserId = resIdStr;
  7059. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  7060. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  7061. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  7062. {
  7063. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7064. int backNum = 0;
  7065. if (number != null)
  7066. {
  7067. backNum = number.BackNum;
  7068. }
  7069. char[] separator = { ',' };
  7070. string[] sArray = resIdStr.Split(separator);
  7071. string[] refundFreeList = { };
  7072. if (refundFees.Length > 0)
  7073. {
  7074. refundFreeList = refundFees.Split(separator);
  7075. }
  7076. int index = -1;
  7077. List<int> responsibleIds = new List<int>();
  7078. foreach (string i in sArray)
  7079. {
  7080. index++;
  7081. if (i.Length <= 0) continue;
  7082. char[] separator2 = { '_' };
  7083. string idstr = i.Split(separator2)[0];
  7084. string idtype = i.Split(separator2)[1];
  7085. double refudFree = 0;
  7086. if (refundFreeList.Length > 0)
  7087. {
  7088. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  7089. }
  7090. if (idtype == "s")
  7091. {
  7092. isDesign = true;
  7093. designFree = refudFree;
  7094. }
  7095. int userId = Convert.ToInt32(idstr);
  7096. int type = 0;
  7097. if (idtype == "g")
  7098. {
  7099. type = 1;
  7100. }
  7101. if (idtype == "w")
  7102. {
  7103. type = 2;
  7104. }
  7105. if (idtype == "t")
  7106. {
  7107. type = 3;
  7108. }
  7109. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  7110. if (ceErpTradeResponsible == null)
  7111. {
  7112. ceErpTradeResponsible = new CeErpTradeResponsible();
  7113. ceErpTradeResponsible.tid = eid;
  7114. ceErpTradeResponsible.UserId = userId;
  7115. ceErpTradeResponsible.createdTime = DateTime.Now;
  7116. ceErpTradeResponsible.type = type;
  7117. if (type == 1)
  7118. {
  7119. ceErpTradeResponsible.IsSup = 1;
  7120. }
  7121. if (type == 2)
  7122. {
  7123. ceErpTradeResponsible.IsFlow = 1;
  7124. }
  7125. }
  7126. int state = 0;
  7127. //已认可的不需要再次认可
  7128. if (sArray.Length > 1 && ceErpTradeResponsible.VerifyState == 1)
  7129. {
  7130. state = 1;
  7131. }
  7132. ceErpTradeResponsible.RefundFee = refudFree;
  7133. ceErpTradeResponsible.VerifyState = state;
  7134. if (userId == 2125 || idtype == "w")
  7135. {
  7136. ceErpTradeResponsible.VerifyState = 1;
  7137. }
  7138. if (idtype == "w" && userId == 101)
  7139. {
  7140. ceErpTradeResponsible.VerifyState = state;
  7141. }
  7142. if (ceErpTradeResponsible.ID > 0)
  7143. {
  7144. ceErpTradeResponsible.Update();
  7145. }
  7146. else
  7147. {
  7148. ceErpTradeResponsible.Create();
  7149. }
  7150. if (isDesign)
  7151. {
  7152. responsibleId = ceErpTradeResponsible.ID;
  7153. }
  7154. responsibleIds.Add(ceErpTradeResponsible.ID);
  7155. }
  7156. CeErpTradeResponsible.ExecuteNonQuery(string.Format("update CE_ErpTradeResponsible set VerifyState =-1 where tid='" + eid + "' and ID NOT IN (" + string.Join(",", responsibleIds) + ")"));
  7157. CeErpTradeResponsible.NumByTid(backNum, eid);
  7158. }
  7159. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  7160. if (ceErpTradeCellExtend != null)
  7161. {
  7162. ceErpTradeCellExtend.returnVisit = 0;
  7163. ceErpTradeCellExtend.Update();
  7164. }
  7165. if (entity.HandleTime != null)
  7166. {
  7167. if (entity.AfterSaleState == 1)
  7168. {
  7169. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  7170. }
  7171. else
  7172. {
  7173. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  7174. }
  7175. }
  7176. else
  7177. {
  7178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  7179. entity.HandleTime = DateTime.Now;
  7180. }
  7181. bool isCompale = false;
  7182. if (entity.AfterSaleState == 5)
  7183. {
  7184. isCompale = true;
  7185. entity.AfterSaleState = 3;
  7186. }
  7187. entity.AfterSaleSupplierState = 0;
  7188. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  7189. {
  7190. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  7191. }
  7192. string sImgs = GetPostString("img");
  7193. entity.AfterSaleSupplierImg = sImgs;
  7194. entity.supRefundType = GetPostString("supRefundType");
  7195. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  7196. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  7197. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  7198. entity.AfterSaleMemoType = GetPostString("MemoType");
  7199. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  7200. {
  7201. //entity.AfterSaleSupplierState = 2;
  7202. }
  7203. string df = GetPostString("DeductFee");
  7204. if (df == "")
  7205. {
  7206. df = "0";
  7207. }
  7208. string rf = GetPostString("RefundFee");
  7209. if (rf == "")
  7210. {
  7211. rf = "0";
  7212. }
  7213. string pm = GetPostString("AfterSalePayment");
  7214. if (pm == "")
  7215. {
  7216. pm = "0";
  7217. }
  7218. entity.AfterSalePayment = Convert.ToDouble(pm);
  7219. entity.DeductFee = Convert.ToDouble(df);
  7220. entity.RefundFee = Convert.ToDouble(rf);
  7221. entity.UpdateTime = DateTime.Now;
  7222. entity.Update();
  7223. string toState = GetPostString("ToState");
  7224. string original = GetPostString("isOriginal");
  7225. ApiVo apiVo = new ApiVo();
  7226. apiVo.orderNumber = entity.ctid;
  7227. apiVo.actionName = "afterDesign";
  7228. apiVo.orderRemarks = entity.AfterSaleMethod;
  7229. apiVo.reasonRemarks = entity.AfterSaleReason;
  7230. apiVo.isDesign = isDesign;
  7231. apiVo.designFree = designFree;
  7232. apiVo.responsibleId = responsibleId;
  7233. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  7234. if (toState == "设计师")
  7235. {
  7236. apiVo.isOriginal = Convert.ToBoolean(original);
  7237. }
  7238. designHelper.API_WorkCore(apiVo);//afterDesign
  7239. CeErpMethod methodSql = new CeErpMethod();
  7240. methodSql.con = entity.AfterSaleMethod;
  7241. methodSql.addTime = DateTime.Now;
  7242. methodSql.Create();
  7243. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  7244. CeErpMethod.ExecuteNonQuery(delsql);
  7245. if (isCompale)
  7246. {
  7247. aftersale_data_change(entity.ctid);
  7248. }
  7249. returnSuccessMsg("操作成功!");
  7250. return;
  7251. }
  7252. returnErrorMsg("找不到订单记录");
  7253. }
  7254. }
  7255. public void ins_erp_toresponsible()
  7256. {
  7257. if (UrlPostParmsCheck("ctid"))
  7258. {
  7259. string eid = GetPostString("ctid");
  7260. CeErpTradeCell entity = null;
  7261. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7262. if (entity != null)
  7263. {
  7264. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7265. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  7266. {
  7267. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  7268. return;
  7269. }
  7270. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  7271. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7272. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7273. if (entity.AfterSalePreTime == null)
  7274. {
  7275. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  7276. {
  7277. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  7278. }
  7279. }
  7280. entity.AfterSalePreTime = DateTime.Now;
  7281. //预完成给售后主管审核客户问题直接完成
  7282. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  7283. {
  7284. if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  7285. {
  7286. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  7287. }
  7288. }
  7289. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  7290. ceErpTradeAfterSaleExtend.Update();
  7291. entity.AfterSaleState = 2;
  7292. entity.UpdateTime = DateTime.Now;
  7293. entity.Update();
  7294. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  7295. aftersale_data_change(entity.ctid);
  7296. returnSuccessMsg("操作成功!");
  7297. return;
  7298. }
  7299. returnErrorMsg("找不到订单记录");
  7300. }
  7301. }
  7302. public void cancel_erp_aftersaleanddelnew()
  7303. {
  7304. if (UrlPostParmsCheck("ctid"))
  7305. {
  7306. string eid = GetPostString("ctid");
  7307. CeErpTradeCell entity = null;
  7308. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7309. if (entity != null)
  7310. {
  7311. entity.AfterSaleState = 0;
  7312. entity.AfterSaleReason = "";
  7313. entity.AfterSaleMethod = "";
  7314. entity.AfterSaleMemo = "";
  7315. entity.AfterSaleResponsible = "";
  7316. entity.ResponsibleUserId = "";
  7317. entity.DeductFee = 0;
  7318. entity.RefundFee = 0;
  7319. entity.IsArbitrate = 0;
  7320. CeErpTradeResponsible.DelByTid(eid, -1);
  7321. entity.Update();
  7322. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  7323. if (after != null)
  7324. {
  7325. if (after.OrderState < 5)
  7326. CeErpTradeCell.DelByCtid("S_" + eid);
  7327. }
  7328. returnSuccessMsg("操作成功!");
  7329. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  7330. return;
  7331. }
  7332. returnErrorMsg("找不到订单记录");
  7333. }
  7334. }
  7335. public void get_erp_aftersale_pregather()
  7336. {
  7337. List<string> lw = new List<string>();
  7338. int st = GetInt("st");
  7339. string tid = GetPostString("ctid");
  7340. if (tid.Length > 0)
  7341. {
  7342. string select_tid = getTidByCtid(tid);
  7343. lw.Add(string.Format("tid='{0}'", select_tid));
  7344. }
  7345. string shopname = GetPostString("shopname");
  7346. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7347. string buyernick = GetPostString("buyer_nick");
  7348. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7349. string sellermemo = GetPostString("seller_memo");
  7350. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7351. string orderState = GetPostString("orderState");
  7352. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7353. string reason = GetPostString("reason");
  7354. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7355. string method = GetPostString("method");
  7356. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7357. string handler = GetPostString("handler");
  7358. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7359. string handledate1 = GetPostString("handledate1");
  7360. string handledate2 = GetPostString("handledate2");
  7361. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7362. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7363. string supplier = GetPostString("supplier");
  7364. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  7365. string responsible = GetPostString("responsibleman");
  7366. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  7367. string customer = GetPostString("customer");
  7368. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7369. string design = GetPostString("design");
  7370. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7371. string afterMemoType = GetPostString("aftermemotype");
  7372. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7373. string afterSaleMemo = GetPostString("afterSaleMemo");
  7374. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  7375. string afterresult = GetPostString("afterresult");
  7376. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  7377. string poscode = CurrentUser.UserPost.Post.Code;
  7378. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  7379. {
  7380. string shopid = CurrentUser.User.pemShop;
  7381. lw.Add(string.Format("shopId in ({0})", shopid));
  7382. }
  7383. var mainwhere = string.Join(" and ", lw.ToArray());
  7384. string ro_json = "";
  7385. string type = GetPostString("gather_type");
  7386. int number = 0;
  7387. if (poscode == "AfterSale")
  7388. {
  7389. //处理中
  7390. if (type == "Handling")
  7391. {
  7392. 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) : ""));
  7393. DataTable dt = null;
  7394. try
  7395. {
  7396. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7397. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7398. }
  7399. catch (Exception e)
  7400. {
  7401. dt = new DataTable();
  7402. }
  7403. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7404. return;
  7405. }
  7406. if (type == "Wait")
  7407. {
  7408. //待处理
  7409. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7410. DataTable dt1 = null;
  7411. try
  7412. {
  7413. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7414. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7415. }
  7416. catch (Exception e)
  7417. {
  7418. dt1 = new DataTable();
  7419. }
  7420. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7421. return;
  7422. }
  7423. if (type == "back")
  7424. {
  7425. //打回
  7426. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7427. DataTable dt2 = null;
  7428. try
  7429. {
  7430. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7431. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7432. }
  7433. catch (Exception e)
  7434. {
  7435. dt2 = new DataTable();
  7436. }
  7437. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  7438. return;
  7439. }
  7440. if (type == "preCompletion")
  7441. {
  7442. //预完成
  7443. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7444. DataTable dt3 = null;
  7445. try
  7446. {
  7447. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7448. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7449. }
  7450. catch (Exception e)
  7451. {
  7452. dt3 = new DataTable();
  7453. }
  7454. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  7455. return;
  7456. }
  7457. if (type == "documentary")
  7458. {
  7459. //跟单中
  7460. 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) : ""));
  7461. DataTable dt4 = null;
  7462. try
  7463. {
  7464. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7465. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7466. }
  7467. catch (Exception e)
  7468. {
  7469. dt4 = new DataTable();
  7470. }
  7471. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7472. return;
  7473. }
  7474. if (type == "reBack")
  7475. {
  7476. //被打回
  7477. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7478. DataTable dt1 = null;
  7479. try
  7480. {
  7481. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7482. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7483. }
  7484. catch (Exception e)
  7485. {
  7486. dt1 = new DataTable();
  7487. }
  7488. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7489. return;
  7490. }
  7491. }
  7492. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  7493. {
  7494. if (type == "puBack")
  7495. {
  7496. //退回
  7497. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7498. DataTable dt = null;
  7499. try
  7500. {
  7501. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7502. number = Convert.ToInt32(dt.Rows[0]["number"]);
  7503. }
  7504. catch (Exception e)
  7505. {
  7506. dt = new DataTable();
  7507. }
  7508. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  7509. return;
  7510. }
  7511. if (type == "reBack")
  7512. {
  7513. //打回
  7514. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7515. DataTable dt1 = null;
  7516. try
  7517. {
  7518. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  7519. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  7520. }
  7521. catch (Exception e)
  7522. {
  7523. dt1 = new DataTable();
  7524. }
  7525. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7526. return;
  7527. }
  7528. if (type == "examEd")
  7529. {
  7530. //已审核
  7531. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7532. DataTable dt2 = null;
  7533. try
  7534. {
  7535. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7536. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7537. }
  7538. catch (Exception e)
  7539. {
  7540. dt2 = new DataTable();
  7541. }
  7542. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7543. return;
  7544. }
  7545. if (type == "waitExam")
  7546. {
  7547. //待审核
  7548. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7549. DataTable dt3 = null;
  7550. try
  7551. {
  7552. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7553. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7554. }
  7555. catch (Exception e)
  7556. {
  7557. dt3 = new DataTable();
  7558. }
  7559. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7560. return;
  7561. }
  7562. if (type == "Handling")
  7563. {
  7564. //处理中
  7565. 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) : ""));
  7566. DataTable dt4 = null;
  7567. try
  7568. {
  7569. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7570. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7571. }
  7572. catch (Exception e)
  7573. {
  7574. dt4 = new DataTable();
  7575. }
  7576. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7577. return;
  7578. }
  7579. if (type == "Wait")
  7580. {
  7581. //待处理
  7582. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7583. DataTable dt5 = null;
  7584. try
  7585. {
  7586. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7587. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7588. }
  7589. catch (Exception e)
  7590. {
  7591. dt5 = new DataTable();
  7592. }
  7593. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7594. return;
  7595. }
  7596. if (type == "documentary")
  7597. {
  7598. //跟单中
  7599. 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) : ""));
  7600. DataTable dt6 = null;
  7601. try
  7602. {
  7603. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7604. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7605. }
  7606. catch (Exception e)
  7607. {
  7608. dt6 = new DataTable();
  7609. }
  7610. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7611. return;
  7612. }
  7613. }
  7614. returnSuccess(ro_json);
  7615. }
  7616. public void end_erp_aftersale()
  7617. {
  7618. if (UrlPostParmsCheck("ctid"))
  7619. {
  7620. string eid = GetPostString("ctid");
  7621. CeErpTradeCell entity = null;
  7622. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7623. if (entity != null)
  7624. {
  7625. string stype = GetPostString("stype");
  7626. string typeStr = stype;
  7627. entity.AfterSaleState = 4;
  7628. entity.FinishAfterSaleTime = DateTime.Now;
  7629. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7630. entity.Update();
  7631. ApiVo apiVo = new ApiVo();
  7632. apiVo.orderNumber = entity.ctid;
  7633. apiVo.actionName = "afterOver";
  7634. designHelper.API_WorkCore(apiVo); //afterOver
  7635. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7636. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7637. CeErpSukuraData.createInfo(entity.ctid, 8);
  7638. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7639. returnSuccessMsg("操作成功!");
  7640. return;
  7641. }
  7642. returnErrorMsg("找不到订单记录");
  7643. }
  7644. }
  7645. public void ins_erp_finishaftersale()
  7646. {
  7647. if (UrlPostParmsCheck("id"))
  7648. {
  7649. string eid = GetPostString("id");
  7650. CeErpTradeResponsible entity = null;
  7651. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7652. if (entity != null)
  7653. {
  7654. entity.VerifyState = 1;
  7655. entity.VerifyTime = DateTime.Now;
  7656. entity.Update();
  7657. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7658. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7659. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7660. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7661. if (dt.Rows.Count <= 0)
  7662. {
  7663. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7664. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7665. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7666. CeErpSukuraData.createInfo(entity.tid, 8);
  7667. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7668. {
  7669. CeErpDesignerBill.Del(entity.tid);
  7670. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7671. }
  7672. }
  7673. returnSuccessMsg("操作成功!");
  7674. return;
  7675. }
  7676. returnErrorMsg("找不到订单记录");
  7677. }
  7678. }
  7679. public void upd_erp_arbitrateaftersale()
  7680. {
  7681. if (UrlPostParmsCheck("id"))
  7682. {
  7683. string eid = GetPostString("id");
  7684. CeErpTradeResponsible entity = null;
  7685. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7686. if (entity != null)
  7687. {
  7688. entity.IsArbitrate = 1;
  7689. entity.ArbitradeMemo = GetPostString("reason");
  7690. entity.VerifyState = 2;
  7691. entity.Update();
  7692. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7693. if (tradecell != null)
  7694. {
  7695. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7696. tradecell.IsArbitrate = 1;
  7697. tradecell.Update();
  7698. }
  7699. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7700. returnSuccessMsg("操作成功!");
  7701. return;
  7702. }
  7703. returnErrorMsg("找不到订单记录");
  7704. }
  7705. }
  7706. public void upd_erp_backaftersale()
  7707. {
  7708. if (UrlPostParmsCheck("tid"))
  7709. {
  7710. string eid = GetPostString("tid");
  7711. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7712. int backNum = 0;
  7713. if (number != null)
  7714. {
  7715. backNum = number.BackNum;
  7716. }
  7717. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7718. CeErpTradeCell entity = null;
  7719. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7720. if (entity != null)
  7721. {
  7722. entity.AfterSaleBackReason = GetPostString("backreason");
  7723. entity.AfterSaleState = 1;
  7724. entity.AfterSaleSupplierState = 0;
  7725. entity.UpdateTime = DateTime.Now;
  7726. entity.Update();
  7727. returnSuccessMsg("操作成功!");
  7728. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7729. return;
  7730. }
  7731. returnErrorMsg("找不到订单记录");
  7732. }
  7733. }
  7734. public void get_erp_supplieraftersalelist()
  7735. {
  7736. DataStruct dStruct = GetPostStruct();
  7737. List<string> lw = new List<string>();
  7738. string tid = GetPostString("ctid");
  7739. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7740. string shopname = GetPostString("shopname");
  7741. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7742. string buyernick = GetPostString("buyer_nick");
  7743. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7744. string sellermemo = GetPostString("seller_memo");
  7745. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7746. string orderState = GetPostString("orderState");
  7747. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7748. string afterState = GetPostString("afterstate");
  7749. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7750. string date1 = GetPostString("date1");
  7751. string date2 = GetPostString("date2");
  7752. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7753. if (dw.Length > 0) lw.Add(dw);
  7754. string price1 = GetPostString("price1");
  7755. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7756. string price2 = GetPostString("price2");
  7757. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7758. string reason = GetPostString("reason");
  7759. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7760. string method = GetPostString("method");
  7761. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7762. string handledate1 = GetPostString("handledate1");
  7763. string handledate2 = GetPostString("handledate2");
  7764. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7765. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7766. string handler = GetPostString("handler");
  7767. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7768. string afterdate1 = GetPostString("afterdate1");
  7769. string afterdate2 = GetPostString("afterdate2");
  7770. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7771. if (afterDate.Length > 0) lw.Add(afterDate);
  7772. string customer = GetPostString("customer");
  7773. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7774. string design = GetPostString("design");
  7775. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7776. string afterMemoType = GetPostString("aftermemotype");
  7777. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7778. string vstate = GetPostString("vstate");
  7779. if (vstate.Length > 0)
  7780. {
  7781. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7782. }
  7783. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7784. string supplier = GetPostString("supplier");
  7785. int supid = commonHelper.getSupplierIDByName(supplier);
  7786. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7787. string posCode = CurrentUser.UserPost.Post.Code;
  7788. if (posCode == "Supplier")
  7789. {
  7790. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7791. }
  7792. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7793. {
  7794. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7795. }
  7796. else
  7797. {
  7798. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7799. }
  7800. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7801. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7802. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7803. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7804. writeGridDataTableJson(dStruct.TotalCount, dt);
  7805. }
  7806. public void upd_erp_supverifyaftersale()
  7807. {
  7808. if (UrlPostParmsCheck("id"))
  7809. {
  7810. string id = GetPostString("id");
  7811. int st = GetPostInt("afterstate");
  7812. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7813. CeErpTradeCell entity = null;
  7814. if (ceErpTradeResponsible != null)
  7815. {
  7816. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7817. }
  7818. string afmemo = GetPostString("supmemo");
  7819. string image = GetPostString("image");
  7820. if (entity != null)
  7821. {
  7822. entity.AfterSaleSupplierState = st;
  7823. entity.AfterSaleSupplierMemo = afmemo;
  7824. if (st == 1)
  7825. {
  7826. ceErpTradeResponsible.VerifyState = 1;
  7827. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7828. ceErpTradeResponsible.Update();
  7829. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7830. if (isAll)
  7831. {
  7832. entity.AfterSaleState = 4;
  7833. entity.FinishAfterSaleTime = DateTime.Now;
  7834. }
  7835. }
  7836. else
  7837. {
  7838. CeErpTradeResponsible.dateByTid(entity.ctid);
  7839. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7840. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7841. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7842. if (num <= 1)
  7843. {
  7844. entity.AfterSaleState = 1;
  7845. }
  7846. else
  7847. {
  7848. entity.AfterSaleState = 5;
  7849. }
  7850. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7851. if (ceErpTradeAfterSaleExtend != null)
  7852. {
  7853. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7854. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7855. ceErpTradeAfterSaleExtend.Update();
  7856. }
  7857. else
  7858. {
  7859. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7860. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7861. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7862. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7863. ceErpTradeAfterSaleExtend.Create();
  7864. }
  7865. }
  7866. if (entity.AfterSaleState == 4)
  7867. {
  7868. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7869. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7870. {
  7871. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7872. }
  7873. ApiVo apiVo = new ApiVo();
  7874. apiVo.orderNumber = entity.ctid;
  7875. apiVo.actionName = "afterOver";
  7876. designHelper.API_WorkCore(apiVo); //afterOver
  7877. }
  7878. entity.UpdateTime = DateTime.Now;
  7879. entity.Update();
  7880. returnSuccessMsg("操作成功!");
  7881. CeErpSukuraData.createInfo(entity.ctid, 8);
  7882. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7883. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7884. return;
  7885. }
  7886. returnErrorMsg("找不到订单记录");
  7887. }
  7888. }
  7889. public void upd_erp_masteraftersale()
  7890. {
  7891. if (UrlPostParmsCheck("id"))
  7892. {
  7893. string id = GetPostString("id");
  7894. int st = GetPostInt("afterstate");
  7895. string afmemo = GetPostString("supmemo");
  7896. string image = GetPostString("image");
  7897. string textResult = GetPostString("textResult");
  7898. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7899. if (ceErpTradeResponsible != null)
  7900. {
  7901. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7902. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7903. ceErpTradeResponsible.Update();
  7904. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7905. if (entity != null)
  7906. {
  7907. entity.AfterSaleSupplierState = st;
  7908. entity.AfterSaleSupplierMemo = afmemo;
  7909. if (st == 1)
  7910. {
  7911. }
  7912. else
  7913. {
  7914. CeErpTradeResponsible.dateByTid(entity.ctid);
  7915. //退回到售后
  7916. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7917. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7918. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7919. if (num <= 1)
  7920. {
  7921. entity.AfterSaleState = 1;
  7922. }
  7923. else
  7924. {
  7925. entity.AfterSaleState = 5;
  7926. }
  7927. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7928. if (ceErpTradeAfterSaleExtend != null)
  7929. {
  7930. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7931. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7932. ceErpTradeAfterSaleExtend.Update();
  7933. }
  7934. else
  7935. {
  7936. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7937. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7938. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7939. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7940. ceErpTradeAfterSaleExtend.Create();
  7941. }
  7942. }
  7943. entity.UpdateTime = DateTime.Now;
  7944. entity.Update();
  7945. returnSuccessMsg("操作成功!");
  7946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7947. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7948. return;
  7949. }
  7950. }
  7951. returnErrorMsg("找不到订单记录");
  7952. }
  7953. }
  7954. public void upd_erp_personaftersale()
  7955. {
  7956. if (UrlPostParmsCheck("id"))
  7957. {
  7958. //林小连
  7959. if (CurrentUser.UserID == 36 || CurrentUser.UserID == 1760 || CurrentUser.UserID == 33)
  7960. {
  7961. upd_erp_masteraftersale();
  7962. return;
  7963. }
  7964. string id = GetPostString("id");
  7965. int st = GetPostInt("afterstate");
  7966. string afmemo = GetPostString("supmemo");
  7967. string image = GetPostString("image");
  7968. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7969. if (ceErpTradeResponsible != null)
  7970. {
  7971. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7972. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7973. ceErpTradeResponsible.Update();
  7974. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7975. if (entity != null)
  7976. {
  7977. entity.AfterSaleSupplierMemo = afmemo;
  7978. entity.AfterSaleSupplierState = st;
  7979. if (st == 1)
  7980. {
  7981. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7982. if (isAll)
  7983. {
  7984. entity.AfterSaleState = 4;
  7985. entity.FinishAfterSaleTime = DateTime.Now;
  7986. }
  7987. }
  7988. else
  7989. {
  7990. CeErpTradeResponsible.dateByTid(entity.ctid);
  7991. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7992. if (ceErpTradeAfterSaleExtend != null)
  7993. {
  7994. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7995. ceErpTradeAfterSaleExtend.Update();
  7996. }
  7997. else
  7998. {
  7999. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  8000. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  8001. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  8002. ceErpTradeAfterSaleExtend.Create();
  8003. }
  8004. //退回到主管
  8005. //entity.AfterSaleState = 2;
  8006. }
  8007. if (entity.AfterSaleState == 4)
  8008. {
  8009. ApiVo apiVo = new ApiVo();
  8010. apiVo.orderNumber = entity.ctid;
  8011. apiVo.actionName = "afterOver";
  8012. designHelper.API_WorkCore(apiVo); //afterOver
  8013. }
  8014. entity.UpdateTime = DateTime.Now;
  8015. entity.Update();
  8016. returnSuccessMsg("操作成功!");
  8017. CeErpSukuraData.createInfo(entity.ctid, 8);
  8018. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  8019. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  8020. return;
  8021. }
  8022. }
  8023. returnErrorMsg("找不到订单记录");
  8024. }
  8025. }
  8026. public void set_erp_supplierrefundtag()
  8027. {
  8028. if (UrlPostParmsCheck("ctid"))
  8029. {
  8030. string eid = GetPostString("ctid");
  8031. CeErpTradeCell entity = null;
  8032. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8033. if (entity != null)
  8034. {
  8035. entity.IsSupplierRefund = GetPostInt("tag");
  8036. entity.Update();
  8037. returnSuccessMsg("操作成功!");
  8038. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  8039. return;
  8040. }
  8041. returnErrorMsg("找不到订单记录");
  8042. }
  8043. }
  8044. public void get_erp_refundlist()
  8045. {
  8046. DataStruct dStruct = GetPostStruct();
  8047. List<string> lw = new List<string>();
  8048. string tid = GetPostString("tid");
  8049. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8050. //string rid = GetPostString("refund_id");
  8051. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  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 design = GetPostString("design");
  8059. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8060. string sellermemo = GetPostString("seller_memo");
  8061. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8062. //string date1 = GetPostString("date1");
  8063. //string date2 = GetPostString("date2");
  8064. //string dateType = GetPostString("dateType");
  8065. //if (dateType.Length > 0)
  8066. //{
  8067. // if (dateType == "1001") dateType = "0";
  8068. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  8069. // if (searchDT.Count == 2)
  8070. // {
  8071. // date1 = searchDT[0].ToString();
  8072. // date2 = searchDT[1].ToString();
  8073. // }
  8074. //}
  8075. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8076. //if (dw.Length > 0) lw.Add(dw);
  8077. string redate1 = GetPostString("refunddate1");
  8078. string redate2 = GetPostString("refunddate2");
  8079. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8080. if (dwdate.Length > 0) lw.Add(dwdate);
  8081. string price1 = GetPostString("price1");
  8082. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8083. string price2 = GetPostString("price2");
  8084. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8085. string ispartrefund = GetPostString("ispartrefund");
  8086. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8087. string refundState = GetPostString("refundvstate");
  8088. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  8089. int st = GetInt("st");
  8090. if (st == 2) //待确认列表中,把state=3已确认的也显示
  8091. {
  8092. string responsible = GetPostString("responsibleman");
  8093. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8094. lw.Add(string.Format("RefundState>={0}", st));
  8095. string code = CurrentUser.UserPost.Post.Code;
  8096. if (code == "CustomerService")
  8097. {
  8098. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  8099. }
  8100. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  8101. {
  8102. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  8103. }
  8104. else if (code == "Place" || code == "PlaceMr")
  8105. {
  8106. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  8107. }
  8108. dStruct.Order = "RefundState asc,created desc";
  8109. }
  8110. else if (st == 10)
  8111. {
  8112. string responsible = GetPostString("responsibleman");
  8113. if (responsible == "空白")
  8114. {
  8115. lw.Add(string.Format("ResponsibleUserName = ''"));
  8116. }
  8117. else if (responsible.Length > 0)
  8118. {
  8119. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8120. }
  8121. lw.Add(string.Format("RefundState>=0"));
  8122. dStruct.Order = "created desc";
  8123. }
  8124. else
  8125. {
  8126. string responsible = GetPostString("responsibleman");
  8127. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  8128. lw.Add(string.Format("RefundState={0}", st));
  8129. dStruct.Order = "created desc";
  8130. }
  8131. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8132. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  8133. dt.Columns.Add("refund_fees");
  8134. foreach (DataRow dr in dt.Rows)
  8135. {
  8136. String status = dr["status"].ToString();
  8137. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8138. {
  8139. dr["refund_fees"] = dr["refund_fee"];
  8140. }
  8141. else
  8142. {
  8143. dr["refund_fees"] = "0.0";
  8144. }
  8145. }
  8146. writeGridDataTableJson(dStruct.TotalCount, dt);
  8147. }
  8148. public void get_erp_refunddesignlist()
  8149. {
  8150. DataStruct dStruct = GetPostStruct();
  8151. List<string> lw = new List<string>();
  8152. string tid = GetPostString("tid");
  8153. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8154. string shopname = GetPostString("shopname");
  8155. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8156. string buyernick = GetPostString("buyer_nick");
  8157. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8158. string customer = GetPostString("customer");
  8159. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8160. string design = GetPostString("design");
  8161. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8162. string sellermemo = GetPostString("seller_memo");
  8163. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8164. string redate1 = GetPostString("refunddate1");
  8165. string redate2 = GetPostString("refunddate2");
  8166. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  8167. if (dwdate.Length > 0) lw.Add(dwdate);
  8168. string price1 = GetPostString("price1");
  8169. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8170. string price2 = GetPostString("price2");
  8171. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8172. string ispartrefund = GetPostString("ispartrefund");
  8173. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  8174. string designerorg = GetPostString("designerorg");
  8175. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  8176. string refundState = GetPostString("refundState");
  8177. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  8178. int myOrgid = CurrentUser.UserPost.OrgID;
  8179. string myOrgCode = CurrentUser.UserPost.Post.Code;
  8180. if ("Designer".Equals(myOrgCode))//设计师能看到的
  8181. {
  8182. if (CurrentUser.User.TeamIds.Length > 0)
  8183. {
  8184. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  8185. }
  8186. else
  8187. {
  8188. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  8189. }
  8190. }
  8191. else if ("SysAdmin".Equals(myOrgCode))
  8192. {
  8193. }
  8194. else
  8195. {
  8196. if (CurrentUser.User.ManageOrgIds.Length > 0)
  8197. {
  8198. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  8199. }
  8200. else
  8201. {
  8202. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  8203. }
  8204. }
  8205. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  8206. dStruct.Order = "created desc";
  8207. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8208. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  8209. dt.Columns.Add("refund_fees");
  8210. foreach (DataRow dr in dt.Rows)
  8211. {
  8212. String status = dr["status"].ToString();
  8213. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  8214. {
  8215. dr["refund_fees"] = dr["refund_fee"];
  8216. }
  8217. else
  8218. {
  8219. dr["refund_fees"] = "0.0";
  8220. }
  8221. }
  8222. writeGridDataTableJson(dStruct.TotalCount, dt);
  8223. }
  8224. public void handle_erp_refundtag()
  8225. {
  8226. if (UrlPostParmsCheck("refund_id"))
  8227. {
  8228. string eid = GetPostString("refund_id");
  8229. string respMan = GetPostString("ResponsibleName");
  8230. if (respMan.Length <= 0)
  8231. {
  8232. returnErrorMsg("责任人不能为空");
  8233. return;
  8234. }
  8235. CeErpTradeRefund entity = null;
  8236. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8237. if (entity != null)
  8238. {
  8239. entity.ResponsibleUserName = respMan;
  8240. string userid = GetPostString("ResponsibleUserId");
  8241. if (userid.Length > 0)
  8242. {
  8243. entity.ResponsibleUserId = userid;
  8244. }
  8245. entity.Memo = GetPostString("Memo");
  8246. if (respMan.IndexOf("客服") != -1 ||
  8247. respMan.IndexOf("设计师") != -1 ||
  8248. respMan.IndexOf("下单员") != -1)
  8249. {
  8250. entity.RefundState = 2;
  8251. }
  8252. else
  8253. {
  8254. entity.RefundState = 3;
  8255. }
  8256. entity.modified = DateTime.Now;
  8257. entity.Update();
  8258. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  8259. returnSuccessMsg("操作成功!");
  8260. return;
  8261. }
  8262. returnErrorMsg("找不到订单记录");
  8263. }
  8264. }
  8265. public void handle_erp_designrefundtag()
  8266. {
  8267. if (UrlPostParmsCheck("refund_id"))
  8268. {
  8269. string eid = GetPostString("refund_id");
  8270. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  8271. if (ceErpTradeCellExtend == null)
  8272. {
  8273. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  8274. ceErpTradeCellExtend.ctid = eid;
  8275. }
  8276. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  8277. if (ceErpTradeCellExtend.ID > 0)
  8278. {
  8279. ceErpTradeCellExtend.Update();
  8280. }
  8281. else
  8282. {
  8283. ceErpTradeCellExtend.Create();
  8284. }
  8285. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  8286. returnSuccessMsg("操作成功!");
  8287. return;
  8288. }
  8289. returnErrorMsg("找不到订单记录");
  8290. }
  8291. public void upd_erp_refundverify()
  8292. {
  8293. if (UrlPostParmsCheck("refund_id"))
  8294. {
  8295. string eid = GetPostString("refund_id");
  8296. CeErpTradeRefund entity = null;
  8297. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8298. if (entity != null)
  8299. {
  8300. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  8301. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  8302. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  8303. {
  8304. entity.RefundState = 2;
  8305. }
  8306. else
  8307. {
  8308. entity.RefundState = 3;
  8309. }
  8310. entity.Update();
  8311. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  8312. returnSuccessMsg("操作成功!");
  8313. return;
  8314. }
  8315. returnErrorMsg("找不到订单记录");
  8316. }
  8317. }
  8318. public void upd_erp_refundapprove()
  8319. {
  8320. if (UrlPostParmsCheck("refund_id"))
  8321. {
  8322. string eid = GetPostString("refund_id");
  8323. CeErpTradeRefund entity = null;
  8324. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  8325. if (entity != null)
  8326. {
  8327. int apr = GetPostInt("approve");
  8328. if (apr == 0)
  8329. {
  8330. entity.RefundState = 1;
  8331. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  8332. }
  8333. else if (apr == 1)
  8334. {
  8335. entity.RefundState = 3;
  8336. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  8337. }
  8338. entity.modified = DateTime.Now;
  8339. entity.Update();
  8340. returnSuccessMsg("操作成功!");
  8341. return;
  8342. }
  8343. returnErrorMsg("找不到订单记录");
  8344. }
  8345. }
  8346. public void get_erp_billlist()
  8347. {
  8348. DataStruct dStruct = GetPostStruct();
  8349. List<string> lw = new List<string>();
  8350. string title = GetPostString("title");
  8351. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  8352. string tid = GetPostString("tid");
  8353. string tids = GetPostString("tids");
  8354. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8355. if (tids.Length > 0)
  8356. {
  8357. tids = "'" + tids + "'";
  8358. tids = tids.Replace(",", "','");
  8359. lw.Add(string.Format("tid in ({0})", tids));
  8360. }
  8361. string shopname = GetPostString("shopname");
  8362. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8363. string buyernick = GetPostString("buyer_nick");
  8364. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8365. string customer = GetPostString("customer");
  8366. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8367. string date1 = GetPostString("date1");
  8368. string date2 = GetPostString("date2");
  8369. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8370. if (dw.Length > 0) lw.Add(dw);
  8371. string price1 = GetPostString("price1");
  8372. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8373. string price2 = GetPostString("price2");
  8374. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8375. string returndate1 = GetPostString("returndate1");
  8376. string returndate2 = GetPostString("returndate2");
  8377. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  8378. if (dw1.Length > 0) lw.Add(dw1);
  8379. string billtype = GetPostString("billtype");
  8380. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  8381. string billstate = GetPostString("billstate");
  8382. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  8383. string usershop = CurrentUser.User.pemShop;
  8384. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  8385. dStruct.Order = "createTime desc";
  8386. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8387. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  8388. //foreach (DataRow dr in dt.Rows)
  8389. //{
  8390. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  8391. //}
  8392. writeGridDataTableJson(dStruct.TotalCount, dt);
  8393. }
  8394. public void modify_erp_billinfo()
  8395. {
  8396. if (UrlPostParmsCheck("ID"))
  8397. {
  8398. string eid = GetPostString("ID");
  8399. CeErpBill bill_entity = null;
  8400. if (eid != "") bill_entity = CeErpBill.Get(eid);
  8401. if (bill_entity != null)
  8402. {
  8403. bill_entity.tid = GetPostString("tid");
  8404. bill_entity.title = GetPostString("title");
  8405. bill_entity.tax = GetPostString("tax");
  8406. bill_entity.bank = GetPostString("bank");
  8407. bill_entity.bankac = GetPostString("bankac");
  8408. bill_entity.address = GetPostString("address");
  8409. bill_entity.phone = GetPostString("phone");
  8410. bill_entity.price = GetPostString("price");
  8411. bill_entity.productId = GetPostInt("ProductName");
  8412. bill_entity.num = GetPostInt("num");
  8413. bill_entity.unit = GetPostString("unit");
  8414. bill_entity.type = GetPostString("type");
  8415. bill_entity.sendType = GetPostString("SendType");
  8416. bill_entity.email = GetPostString("email");
  8417. bill_entity.buyer_nick = GetPostString("buyer_nick");
  8418. bill_entity.shopName = GetPostString("ShopName");
  8419. bill_entity.applymemo = GetPostString("applymemo");
  8420. bill_entity.modifyTime = DateTime.Now;
  8421. bill_entity.createTime = DateTime.Now;
  8422. bill_entity.state = 0;
  8423. bill_entity.Update();
  8424. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  8425. returnSuccessMsg("发票修改成功!");
  8426. return;
  8427. }
  8428. returnErrorMsg("找不到对应记录");
  8429. }
  8430. }
  8431. public void set_erp_invoicing()
  8432. {
  8433. if (UrlPostParmsCheck("id"))
  8434. {
  8435. try
  8436. {
  8437. string eid = GetPostString("id");
  8438. CeErpBill bill_entity = null;
  8439. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8440. if (bill_entity != null)
  8441. {
  8442. int ComId = GetPostInt("ComId");
  8443. //string memo = GetPostString("Memo");
  8444. int allInfo = GetPostInt("allinfo");
  8445. string clert = CurrentUser.User.Name;
  8446. //string detailValue = GetPostString("detailvalue");
  8447. string billId = bill_entity.billOrderId;
  8448. string[] billIdList = billId.Split(',');
  8449. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  8450. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  8451. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  8452. {
  8453. billCount += 1;
  8454. }
  8455. if (billId.Length <= 0 || billIdList.Length != billCount)
  8456. {
  8457. bill_entity.billOrderId = "";
  8458. string prebill = "ltb";
  8459. for (int idx = 1; idx <= billCount; idx++)
  8460. {
  8461. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  8462. string billoid = prebill + idx + dtstr;
  8463. bill_entity.billOrderId += billoid;
  8464. if (idx < billCount)
  8465. {
  8466. bill_entity.billOrderId += ",";
  8467. }
  8468. }
  8469. }
  8470. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8471. if (bill_entity.state == 5)
  8472. {
  8473. string errMsg = bill_entity.failerror;
  8474. string[] errlist = errMsg.Split('|');
  8475. string[] errTags = new string[errlist.Length];
  8476. for (int itag = 0; itag < errlist.Length; itag++)
  8477. {
  8478. if (errlist[itag].Length <= 0) continue;
  8479. errTags[itag] = errlist[itag].Split('&')[0];
  8480. }
  8481. for (int iii = 0; iii < errTags.Length; iii++)
  8482. {
  8483. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  8484. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  8485. if (billOrderList.Length >= erroBillOrderTag)
  8486. {
  8487. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  8488. if (needModifyBillId.Length <= 19)
  8489. {
  8490. needModifyBillId = needModifyBillId + "1";
  8491. }
  8492. else
  8493. {
  8494. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  8495. last = last + 1;
  8496. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  8497. }
  8498. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  8499. }
  8500. }
  8501. }
  8502. bool isHaveBillSucces = false;
  8503. string totalRes = "";
  8504. bill_entity.failerror = "";
  8505. for (int ii = 1; ii <= billOrderList.Length; ii++)
  8506. {
  8507. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  8508. totalRes += res;
  8509. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  8510. {
  8511. isHaveBillSucces = true;
  8512. bill_entity.comId = ComId;
  8513. bill_entity.state = 1;
  8514. bill_entity.executeTime = DateTime.Now;
  8515. bill_entity.executeUser = clert;
  8516. }
  8517. else
  8518. {
  8519. bill_entity.state = 5;
  8520. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  8521. }
  8522. }
  8523. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  8524. bill_entity.Update();
  8525. if (isHaveBillSucces)
  8526. {
  8527. StringBuilder sql = new StringBuilder();
  8528. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8529. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8530. }
  8531. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8532. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8533. {
  8534. returnErrorMsg("开票失败");
  8535. }
  8536. else
  8537. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8538. return;
  8539. }
  8540. returnErrorMsg("找不到对应记录");
  8541. }
  8542. catch (Exception ex)
  8543. {
  8544. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8545. returnErrorMsg("操作失败");
  8546. }
  8547. }
  8548. }
  8549. public void get_erp_invoicing_back()
  8550. {
  8551. if (UrlPostParmsCheck("id"))
  8552. {
  8553. try
  8554. {
  8555. string id = GetPostString("id");
  8556. CeErpBill entiy = CeErpBill.Get(id);
  8557. if (entiy != null)
  8558. {
  8559. if (entiy.state == 0)
  8560. {
  8561. returnErrorMsg("发票还未开具");
  8562. return;
  8563. }
  8564. string[] billOrderList = entiy.billOrderId.Split(',');
  8565. int iTag = 0;
  8566. entiy.fplsh = "";
  8567. entiy.fpdm = "";
  8568. entiy.fphm = "";
  8569. foreach (string billOrderId in billOrderList)
  8570. {
  8571. iTag++;
  8572. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8573. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8574. {
  8575. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8576. try
  8577. {
  8578. Invoicing_get_response_Obj iObj = null;
  8579. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8580. if (iObj != null)
  8581. {
  8582. entiy.state = 2;
  8583. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8584. entiy.fpdm += iObj.list[0].c_fpdm;
  8585. entiy.fphm += iObj.list[0].c_fphm;
  8586. if (iTag < billOrderList.Length)
  8587. {
  8588. entiy.fplsh += ",";
  8589. entiy.fpdm += ",";
  8590. entiy.fphm += ",";
  8591. }
  8592. entiy.Update();
  8593. }
  8594. StringBuilder sql = new StringBuilder();
  8595. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8596. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8597. returnSuccessMsg("开票成功");
  8598. }
  8599. catch (Exception ex)
  8600. {
  8601. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8602. }
  8603. return;
  8604. }
  8605. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8606. {
  8607. var res_obj = new
  8608. {
  8609. data = "开票中"
  8610. };
  8611. string ro_json = JsonConvert.SerializeObject(res_obj);
  8612. returnSuccess(ro_json);
  8613. return;
  8614. }
  8615. else
  8616. {
  8617. int eidx = res.IndexOf("c_resultmsg");
  8618. int lidx = res.IndexOf("c_status");
  8619. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8620. entiy.state = 5;
  8621. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8622. entiy.Update();
  8623. returnErrorMsg("开票失败");
  8624. return;
  8625. }
  8626. }
  8627. }
  8628. }
  8629. catch (Exception ex)
  8630. {
  8631. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8632. }
  8633. return;
  8634. }
  8635. }
  8636. public void get_erp_invoicing()
  8637. {
  8638. if (UrlPostParmsCheck("id"))
  8639. {
  8640. try
  8641. {
  8642. string id = GetPostString("id");
  8643. CeErpBill entiy = CeErpBill.Get(id);
  8644. if (entiy != null)
  8645. {
  8646. if (entiy.state == 0)
  8647. {
  8648. returnErrorMsg("发票还未开具");
  8649. return;
  8650. }
  8651. if (entiy.sendType == "纸质发票")
  8652. {
  8653. if (entiy.img.Length <= 0)
  8654. {
  8655. returnErrorMsg("查无纸质发票");
  8656. return;
  8657. }
  8658. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8659. returnSuccess(returnres);
  8660. return;
  8661. }
  8662. string[] billOrderList = entiy.billOrderId.Split(',');
  8663. int iTag = 0;
  8664. string fpUrl = "";
  8665. entiy.fplsh = "";
  8666. entiy.fpdm = "";
  8667. entiy.fphm = "";
  8668. foreach (string billOrderId in billOrderList)
  8669. {
  8670. iTag++;
  8671. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8672. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8673. {
  8674. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8675. Invoicing_get_response_Obj iObj = null;
  8676. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8677. if (iObj != null)
  8678. {
  8679. //entiy.state = 2;
  8680. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8681. entiy.fpdm += iObj.list[0].c_fpdm;
  8682. entiy.fphm += iObj.list[0].c_fphm;
  8683. if (iTag < billOrderList.Length)
  8684. {
  8685. entiy.fplsh += ",";
  8686. entiy.fpdm += ",";
  8687. entiy.fphm += ",";
  8688. }
  8689. entiy.Update();
  8690. fpUrl += iObj.list[0].c_url + ",";
  8691. }
  8692. //returnSuccess(res);
  8693. StringBuilder sql = new StringBuilder();
  8694. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8695. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8696. }
  8697. else
  8698. {
  8699. int eidx = res.IndexOf("c_resultmsg");
  8700. //int lidx = res.IndexOf("c_status");
  8701. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8702. //开票失败
  8703. entiy.state = 5;
  8704. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8705. entiy.Update();
  8706. returnErrorMsg("开票失败");
  8707. return;
  8708. }
  8709. }
  8710. var returnObj = new
  8711. {
  8712. data = fpUrl
  8713. };
  8714. string ro_json = JsonConvert.SerializeObject(returnObj);
  8715. returnSuccess(ro_json);
  8716. }
  8717. }
  8718. catch (Exception ex)
  8719. {
  8720. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8721. }
  8722. return;
  8723. }
  8724. }
  8725. public void save_erp_billimg()
  8726. {
  8727. if (UrlPostParmsCheck("id"))
  8728. {
  8729. string eid = GetPostString("id");
  8730. CeErpBill bill_entity = null;
  8731. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8732. if (bill_entity != null)
  8733. {
  8734. bill_entity.img = GetPostString("img");
  8735. bill_entity.executeTime = DateTime.Now;
  8736. bill_entity.state = 2;
  8737. bill_entity.Update();
  8738. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8739. returnSuccessMsg("保存成功");
  8740. }
  8741. return;
  8742. }
  8743. }
  8744. public void upd_erp_billreturnback()
  8745. {
  8746. if (UrlPostParmsCheck("id"))
  8747. {
  8748. int eid = GetPostInt("id");
  8749. CeErpBill bill_entity = null;
  8750. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8751. if (bill_entity != null)
  8752. {
  8753. bill_entity.state = 3;
  8754. bill_entity.returnReason = GetPostString("reason");
  8755. bill_entity.Update();
  8756. returnSuccessMsg("驳回成功!");
  8757. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8758. }
  8759. return;
  8760. }
  8761. }
  8762. public void cancel_erp_bill()
  8763. {
  8764. if (UrlPostParmsCheck("id"))
  8765. {
  8766. int eid = GetPostInt("id");
  8767. int detailValue = GetPostInt("detailvalue");
  8768. CeErpBill bill_entity = null;
  8769. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8770. string cres = "";
  8771. string gres = "";
  8772. if (bill_entity != null)
  8773. {
  8774. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8775. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8776. {
  8777. int iTag = 0;
  8778. bill_entity.fplsh = "";
  8779. bill_entity.fpdm = "";
  8780. bill_entity.fphm = "";
  8781. foreach (string billOrderId in billOrderList)
  8782. {
  8783. iTag++;
  8784. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8785. if (gres.IndexOf("success") != -1)
  8786. {
  8787. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8788. Invoicing_get_response_Obj iObj = null;
  8789. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8790. if (iObj != null)
  8791. {
  8792. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8793. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8794. bill_entity.fphm += iObj.list[0].c_fphm;
  8795. if (iTag < billOrderList.Length)
  8796. {
  8797. bill_entity.fplsh += ",";
  8798. bill_entity.fpdm += ",";
  8799. bill_entity.fphm += ",";
  8800. }
  8801. bill_entity.Update();
  8802. }
  8803. }
  8804. else
  8805. {
  8806. returnErrorMsg(gres);
  8807. return;
  8808. }
  8809. }
  8810. }
  8811. if (bill_entity.sendType == "纸质发票")
  8812. {
  8813. //作废
  8814. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8815. //if (DateTime.Now.Month == extime.Month)
  8816. //{
  8817. //cres = taobaoHelper.cancel_invoicing(eid);
  8818. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8819. //{
  8820. bill_entity.state = 4;//已作废
  8821. bill_entity.Update();
  8822. returnSuccessMsg("发票已作废");
  8823. return;
  8824. //}
  8825. //else
  8826. //{
  8827. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8828. // bill_entity.Update();
  8829. // returnErrorMsg(cres);
  8830. // return;
  8831. //}
  8832. //}
  8833. //else
  8834. //{
  8835. // returnErrorMsg("纸质发票只能作废本月的发票");
  8836. // return;
  8837. //}
  8838. }
  8839. //红冲
  8840. int redTag = 0;
  8841. string[] fpdmList = bill_entity.fpdm.Split(',');
  8842. string[] fphmList = bill_entity.fphm.Split(',');
  8843. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8844. {
  8845. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8846. return;
  8847. }
  8848. foreach (string billOrderId in billOrderList)
  8849. {
  8850. redTag++;
  8851. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8852. cres += onecres;
  8853. cres += ",";
  8854. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8855. {
  8856. bill_entity.state = 4;//已作废
  8857. //bill_entity.Update();
  8858. //returnSuccessMsg("发票已红冲");
  8859. }
  8860. else if (onecres.IndexOf("重复冲红") != -1)
  8861. {
  8862. bill_entity.state = 4;//已作废
  8863. //bill_entity.Update();
  8864. //returnSuccessMsg("发票已红冲");
  8865. }
  8866. else
  8867. {
  8868. string errmsg = commonHelper.KeepChinese(onecres);
  8869. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8870. }
  8871. }
  8872. bill_entity.Update();
  8873. if (cres.IndexOf("失败") != -1)
  8874. returnErrorMsg("红冲失败");
  8875. else
  8876. returnSuccessMsg("发票已红冲");
  8877. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8878. return;
  8879. }
  8880. return;
  8881. }
  8882. }
  8883. public void del_erp_billorder()
  8884. {
  8885. if (UrlPostParmsCheck("id"))
  8886. {
  8887. string eid = GetPostString("id");
  8888. CeErpBill.Del(eid);
  8889. CeErpBill bill = CeErpBill.Get(eid);
  8890. if (bill != null)
  8891. {
  8892. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8893. }
  8894. returnSuccessMsg("删除成功");
  8895. }
  8896. }
  8897. public void finish_erp_bill()
  8898. {
  8899. if (UrlPostParmsCheck("ids"))
  8900. {
  8901. string eids = GetPostString("ids");
  8902. string[] list = eids.Split(',');
  8903. foreach (string eid in list)
  8904. {
  8905. CeErpBill bill = CeErpBill.Get(eid);
  8906. if (bill != null)
  8907. {
  8908. bill.state = 2;
  8909. bill.Update();
  8910. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8911. }
  8912. }
  8913. returnSuccessMsg("操作成功");
  8914. }
  8915. }
  8916. public void get_erp_returncash()
  8917. {
  8918. DataStruct dStruct = GetPostStruct();
  8919. List<string> lw = new List<string>();
  8920. string tid = GetPostString("tid");
  8921. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8922. string shopname = GetPostString("shopname");
  8923. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8924. string buyernick = GetPostString("buyer_nick");
  8925. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8926. string customer = GetPostString("customer");
  8927. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8928. string returndate1 = GetPostString("returndate1");
  8929. string returndate2 = GetPostString("returndate2");
  8930. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8931. if (dw.Length > 0) lw.Add(dw);
  8932. string finishDate1 = GetPostString("finishdate1");
  8933. string finishDate2 = GetPostString("finishdate2");
  8934. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8935. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8936. string returntype = GetPostString("returntype");
  8937. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8938. string returnvstate = GetPostString("returnvstate");
  8939. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8940. dStruct.Order = "created desc";
  8941. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8942. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8943. writeGridDataTableJson(dStruct.TotalCount, dt);
  8944. }
  8945. public void get_erp_staygoods()
  8946. {
  8947. DataStruct dStruct = GetPostStruct();
  8948. List<string> lw = new List<string>();
  8949. string tid = GetPostString("tid");
  8950. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8951. string shopname = GetPostString("shopname");
  8952. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8953. string wangwang = GetPostString("wangwang");
  8954. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8955. string customer = GetPostString("customer");
  8956. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8957. string returndate1 = GetPostString("returndate1");
  8958. string returndate2 = GetPostString("returndate2");
  8959. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8960. if (dw.Length > 0) lw.Add(dw);
  8961. string finishDate1 = GetPostString("finishdate1");
  8962. string finishDate2 = GetPostString("finishdate2");
  8963. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8964. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8965. string returnvstate = GetPostString("returnvstate");
  8966. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8967. string persuadetype = GetPostString("persuadetype");
  8968. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8969. string customerOrg = GetPostString("customerOrg");
  8970. if (customerOrg.Length > 0)
  8971. {
  8972. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8973. }
  8974. string designerorg = GetPostString("designerorg");
  8975. if (designerorg.Length > 0)
  8976. {
  8977. lw.Add(string.Format("OrgID = {0}", designerorg));
  8978. }
  8979. dStruct.Order = "creata_time desc";
  8980. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8981. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8982. writeGridDataTableJson(dStruct.TotalCount, dt);
  8983. }
  8984. public void upd_erp_staygoods()
  8985. {
  8986. if (UrlPostParmsCheck("id"))
  8987. {
  8988. int eid = GetPostInt("id");
  8989. CeErpStayGoods entity = null;
  8990. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8991. if (entity != null)
  8992. {
  8993. entity.audit_type = 1;
  8994. entity.audit_time = DateTime.Now;
  8995. entity.audit_u_id = CurrentUser.UserID;
  8996. entity.audit_u_name = CurrentUser.UserName;
  8997. entity.Update();
  8998. returnSuccessMsg("审核成功!");
  8999. return;
  9000. }
  9001. returnErrorMsg("找不到订单记录");
  9002. }
  9003. }
  9004. public void upd_erp_stayGoodsback()
  9005. {
  9006. if (UrlPostParmsCheck("id"))
  9007. {
  9008. int eid = GetPostInt("id");
  9009. CeErpStayGoods entity = null;
  9010. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  9011. if (entity != null)
  9012. {
  9013. entity.audit_text = GetPostString("reason");
  9014. entity.audit_type = 2;
  9015. entity.audit_time = DateTime.Now;
  9016. entity.audit_u_id = CurrentUser.UserID;
  9017. entity.audit_u_name = CurrentUser.UserName;
  9018. entity.Update();
  9019. returnSuccessMsg("退回成功!");
  9020. return;
  9021. }
  9022. returnErrorMsg("找不到订单记录");
  9023. }
  9024. }
  9025. public void upd_erp_returncashverify()
  9026. {
  9027. if (UrlPostParmsCheck("ID"))
  9028. {
  9029. int eid = GetPostInt("ID");
  9030. CeErpReturnCash entity = null;
  9031. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9032. if (entity != null)
  9033. {
  9034. entity.cashstate = 1;
  9035. entity.verifytime = DateTime.Now;
  9036. entity.verifyuserid = CurrentUser.UserID;
  9037. entity.Update();
  9038. returnSuccessMsg("审核成功!");
  9039. return;
  9040. }
  9041. returnErrorMsg("找不到订单记录");
  9042. }
  9043. }
  9044. public void upd_all_erp_returncashverify()
  9045. {
  9046. if (UrlPostParmsCheck("ID"))
  9047. {
  9048. String[] list = GetPostString("ID").Split(',');
  9049. CeErpReturnCash entity = null;
  9050. for (int i = 0; i < list.Length; i++)
  9051. {
  9052. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  9053. if (entity != null)
  9054. {
  9055. if (entity.cashstate == 1)
  9056. {
  9057. returnErrorMsg("已审核过的订单不需要在审核!");
  9058. return;
  9059. }
  9060. entity.cashstate = 1;
  9061. entity.verifytime = DateTime.Now;
  9062. entity.verifyuserid = CurrentUser.UserID;
  9063. entity.Update();
  9064. }
  9065. }
  9066. returnSuccessMsg("审核成功!");
  9067. return;
  9068. }
  9069. }
  9070. public void upd_erp_returncashback()
  9071. {
  9072. if (UrlPostParmsCheck("ID"))
  9073. {
  9074. int eid = GetPostInt("ID");
  9075. CeErpReturnCash entity = null;
  9076. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9077. if (entity != null)
  9078. {
  9079. entity.backreason = GetPostString("reason");
  9080. entity.cashstate = 2;
  9081. entity.verifytime = DateTime.Now;
  9082. entity.verifyuserid = CurrentUser.UserID;
  9083. entity.Update();
  9084. returnSuccessMsg("退回成功!");
  9085. return;
  9086. }
  9087. returnErrorMsg("找不到订单记录");
  9088. }
  9089. }
  9090. public void upd_erp_returnprice()
  9091. {
  9092. if (UrlPostParmsCheck("ID"))
  9093. {
  9094. int eid = GetPostInt("ID");
  9095. CeErpReturnCash entity = null;
  9096. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  9097. if (entity != null)
  9098. {
  9099. if (entity.cashstate == 1)
  9100. {
  9101. returnErrorMsg("审核通过了不能改");
  9102. return;
  9103. }
  9104. entity.returnprice = GetPostDouble("returnprice");
  9105. entity.Update();
  9106. returnSuccessMsg("修改成功!");
  9107. return;
  9108. }
  9109. returnErrorMsg("找不到订单记录");
  9110. }
  9111. }
  9112. public void del_erp_returncash()
  9113. {
  9114. if (UrlPostParmsCheck("ID"))
  9115. {
  9116. int eid = GetPostInt("ID");
  9117. CeErpReturnCash.Del(eid);
  9118. returnSuccessMsg("操作成功");
  9119. return;
  9120. }
  9121. }
  9122. public void test_for_do_sql()
  9123. {
  9124. string sql = GetPostString("sqlstr");
  9125. if (sql.Length > 0)
  9126. {
  9127. try
  9128. {
  9129. DbHelper.DbConn.ExecuteNonQuery(sql);
  9130. var res_obj = new
  9131. {
  9132. data = "成功",
  9133. };
  9134. string ro_json = JsonConvert.SerializeObject(res_obj);
  9135. returnSuccess(ro_json);
  9136. }
  9137. catch (Exception ex)
  9138. {
  9139. var res_obj = new
  9140. {
  9141. data = ex.Message,
  9142. };
  9143. string ro_json = JsonConvert.SerializeObject(res_obj);
  9144. returnSuccess(ro_json);
  9145. }
  9146. }
  9147. }
  9148. public void get_user_info()
  9149. {
  9150. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  9151. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  9152. }
  9153. public void get_total_data()
  9154. {
  9155. int userId = CurrentUser.UserID;
  9156. string sql = "";
  9157. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9158. {
  9159. 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);
  9160. }
  9161. else
  9162. {
  9163. 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 " +
  9164. "(select ID from CE_ErpUser where ID = {0}) d " +
  9165. "left join " +
  9166. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  9167. ") a on d.ID = a.id left join " +
  9168. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  9169. ") b on a.id = b.id1 left join" +
  9170. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  9171. ") c on a.id = c.id2;", userId);
  9172. }
  9173. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9174. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9175. }
  9176. public void get_date_area_total_data2()
  9177. {
  9178. int userId = CurrentUser.UserID;
  9179. string date_type = GetPostString("timetype");
  9180. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9181. string sql = "";
  9182. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9183. {
  9184. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  9185. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  9186. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9187. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9188. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9189. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  9190. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9191. ") a on e.ID = a.id left join " +
  9192. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  9193. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9194. ") b on a.id = b.id1 " +
  9195. "left join " +
  9196. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9197. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  9198. ") c on a.id = c.id2 " +
  9199. "left join " +
  9200. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9201. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9202. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9203. }
  9204. else
  9205. {
  9206. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  9207. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  9208. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  9209. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  9210. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  9211. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  9212. ") a on e.ID = a.id left join " +
  9213. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  9214. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  9215. ") c on a.id = c.id2 " +
  9216. "left join " +
  9217. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  9218. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  9219. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  9220. }
  9221. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9222. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9223. }
  9224. public void get_date_area_total_data()
  9225. {
  9226. int userId = CurrentUser.UserID;
  9227. string date_type = GetPostString("timetype");
  9228. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9229. string date1 = searchDT[0].ToString();
  9230. string date2 = searchDT[1].ToString();
  9231. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  9232. {
  9233. SqlParameter[] sqlParameter ={
  9234. new SqlParameter("@userId", SqlDbType.Int,4),
  9235. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9236. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9237. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9238. };
  9239. sqlParameter[0].Value = userId;
  9240. sqlParameter[1].Value = date1;
  9241. sqlParameter[2].Value = date2;
  9242. sqlParameter[3].Direction = ParameterDirection.Output;
  9243. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  9244. string res = sqlParameter[3].Value.ToString();
  9245. var res_obj = new
  9246. {
  9247. data = res
  9248. };
  9249. string ro_json = JsonConvert.SerializeObject(res_obj);
  9250. returnSuccess(ro_json);
  9251. }
  9252. else
  9253. {
  9254. SqlParameter[] sqlParameter ={
  9255. new SqlParameter("@userId", SqlDbType.Int,4),
  9256. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  9257. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  9258. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  9259. };
  9260. sqlParameter[0].Value = userId;
  9261. sqlParameter[1].Value = date1;
  9262. sqlParameter[2].Value = date2;
  9263. sqlParameter[3].Direction = ParameterDirection.Output;
  9264. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  9265. string res = sqlParameter[3].Value.ToString();
  9266. var res_obj = new
  9267. {
  9268. data = res
  9269. };
  9270. string ro_json = JsonConvert.SerializeObject(res_obj);
  9271. returnSuccess(ro_json);
  9272. }
  9273. //writeGridDataViewJson(dt.Rows.Count, dv);
  9274. }
  9275. public void get_order_list()
  9276. {
  9277. string strFields = GetPostString("paraFields");
  9278. string strOrder = GetPostString("paraOrder");
  9279. string strWhere = GetPostString("paraWhere");
  9280. string strPageSize = GetPostString("paraPageSize");
  9281. DataStruct dStruct = GetPostStruct();
  9282. dStruct.PageSize = int.Parse(strPageSize);
  9283. dStruct.Fileds = strFields;
  9284. dStruct.Order = strOrder;
  9285. dStruct.MainWhere = strWhere;
  9286. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9287. writeGridDataTableJson(dStruct.TotalCount, dt);
  9288. }
  9289. ////获取待开始订单列表
  9290. //public void get_wait_design_order_list()
  9291. //{
  9292. // string date_type = GetPostString("date_type");
  9293. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9294. // DataStruct dStruct = GetPostStruct();
  9295. // dStruct.PageSize = 1000;
  9296. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  9297. // List<string> lw = new List<string>();
  9298. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  9299. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  9300. // dStruct.Order = "WaitDesignTime asc";
  9301. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9302. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9303. // writeGridDataTableJson(dStruct.TotalCount, dt);
  9304. //}
  9305. //获取完成单量排名
  9306. public void get_finish_order_count_ranking()
  9307. {
  9308. /* string date_type = GetPostString("date_type");
  9309. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9310. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9311. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9312. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  9313. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9314. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9315. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9316. writeGridDataTableJson(0, new DataTable());
  9317. }
  9318. public void get_finish_order_amount_ranking()
  9319. {
  9320. /*string date_type = GetPostString("date_type");
  9321. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9322. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9323. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9324. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  9325. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  9326. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9327. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  9328. writeGridDataTableJson(0, new DataTable());
  9329. }
  9330. public void get_finish_refund_count_ranking()
  9331. {
  9332. string date_type = GetPostString("date_type");
  9333. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9334. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  9335. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9336. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  9337. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9338. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9339. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9340. writeGridDataTableJson(dt.Rows.Count, dt);
  9341. }
  9342. public void get_finish_refund_amount_ranking()
  9343. {
  9344. string date_type = GetPostString("date_type");
  9345. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  9346. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  9347. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  9348. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  9349. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  9350. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  9351. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9352. writeGridDataTableJson(dt.Rows.Count, dt);
  9353. }
  9354. public void set_erp_finishorder_director()
  9355. {
  9356. if (UrlPostParmsCheck("ctid"))
  9357. {
  9358. string eid = GetPostString("ctid");
  9359. CeErpTradeCell entity = null;
  9360. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9361. if (entity != null)
  9362. {
  9363. entity.OrderState = 8;
  9364. entity.Update();
  9365. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  9366. returnSuccessMsg("操作成功!");
  9367. return;
  9368. }
  9369. returnErrorMsg("找不到记录");
  9370. }
  9371. }
  9372. public void get_erp_placeregistlist()
  9373. {
  9374. DataStruct dStruct = GetPostStruct();
  9375. List<string> lw = new List<string>();
  9376. string outsid = GetPostString("outsid");
  9377. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  9378. string memo = GetPostString("memo");
  9379. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  9380. string filename = GetPostString("filename");
  9381. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  9382. string islate = GetPostString("islate");
  9383. if (islate.Length > 0)
  9384. {
  9385. if (islate == "1")
  9386. lw.Add(string.Format("OutLate>0"));
  9387. else
  9388. lw.Add(string.Format("OutLate=0"));
  9389. }
  9390. string placedate1 = GetPostString("placedate1");
  9391. string placedate2 = GetPostString("placedate2");
  9392. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  9393. if (dw.Length > 0) lw.Add(dw);
  9394. string deliveryDate1 = GetPostString("deliverydate1");
  9395. string deliveryDate2 = GetPostString("deliverydate2");
  9396. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  9397. if (dw_deli.Length > 0) lw.Add(dw_deli);
  9398. dStruct.Order = "ID desc";
  9399. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9400. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  9401. writeGridDataTableJson(dStruct.TotalCount, dt);
  9402. }
  9403. public void ins_erp_placeregist()
  9404. {
  9405. if (UrlPostParmsCheck("id"))
  9406. {
  9407. string eid = GetPostString("id");
  9408. CeErpPlaceRegister entity = null;
  9409. if (eid == "0")//新增
  9410. {
  9411. entity = new CeErpPlaceRegister();
  9412. string xdTime = GetPostString("placeTime");
  9413. if (xdTime.Length > 0)
  9414. {
  9415. entity.PlactTime = Convert.ToDateTime(xdTime);
  9416. }
  9417. string fhTime = GetPostString("deliveryTime");
  9418. if (fhTime.Length > 0)
  9419. {
  9420. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9421. }
  9422. string preTime = GetPostString("preOutTime");
  9423. if (preTime.Length > 0)
  9424. {
  9425. entity.PreOutTime = Convert.ToDateTime(preTime);
  9426. }
  9427. entity.DeliveryCount = GetPostInt("deliveryCount");
  9428. entity.ReceiveCount = GetPostInt("receiveCount");
  9429. entity.OutSid = GetPostString("outSid");
  9430. entity.FileName = GetPostString("fileName");
  9431. entity.Memo = GetPostString("memo");
  9432. entity.AddUserId = CurrentUser.UserID;
  9433. entity.CreateTime = DateTime.Now;
  9434. entity.Img = GetPostString("img");
  9435. entity.Supplier = GetPostInt("supplier");
  9436. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9437. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9438. {
  9439. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9440. DateTime dt2 = (DateTime)entity.PreOutTime;
  9441. TimeSpan span = dt1.Subtract(dt2);
  9442. if (span.Days > 0)
  9443. {
  9444. entity.OutLate = span.Days;
  9445. }
  9446. }
  9447. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9448. entity.Create();
  9449. returnSuccessMsg("添加成功!");
  9450. return;
  9451. }
  9452. else //修改
  9453. {
  9454. entity = CeErpPlaceRegister.Get(eid);
  9455. if (entity != null)
  9456. {
  9457. string xdTime = GetPostString("placeTime");
  9458. if (xdTime.Length > 0)
  9459. {
  9460. entity.PlactTime = Convert.ToDateTime(xdTime);
  9461. }
  9462. string fhTime = GetPostString("deliveryTime");
  9463. if (fhTime.Length > 0)
  9464. {
  9465. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  9466. }
  9467. string preTime = GetPostString("preOutTime");
  9468. if (preTime.Length > 0)
  9469. {
  9470. entity.PreOutTime = Convert.ToDateTime(preTime);
  9471. }
  9472. entity.DeliveryCount = GetPostInt("deliveryCount");
  9473. entity.ReceiveCount = GetPostInt("receiveCount");
  9474. if (entity.DeliveryCount == entity.ReceiveCount)
  9475. {
  9476. entity.CurState = "已完成";
  9477. }
  9478. else
  9479. {
  9480. entity.CurState = "未完成";
  9481. }
  9482. entity.OutSid = GetPostString("outSid");
  9483. entity.FileName = GetPostString("fileName");
  9484. entity.Memo = GetPostString("memo");
  9485. entity.Img = GetPostString("img");
  9486. entity.Supplier = GetPostInt("supplier");
  9487. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  9488. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  9489. {
  9490. DateTime dt1 = (DateTime)entity.DeliveryTime;
  9491. DateTime dt2 = (DateTime)entity.PreOutTime;
  9492. TimeSpan span = dt1.Subtract(dt2);
  9493. if (span.Days > 0)
  9494. {
  9495. entity.OutLate = span.Days;
  9496. }
  9497. }
  9498. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  9499. entity.Update();
  9500. returnSuccessMsg("修改成功");
  9501. return;
  9502. }
  9503. returnErrorMsg("找不到对应的记录");
  9504. return;
  9505. }
  9506. }
  9507. returnErrorMsg("缺少必要参数");
  9508. }
  9509. public void del_erp_placeregist()
  9510. {
  9511. string eid = GetPostString("id");
  9512. CeErpPlaceRegister.Del(eid);
  9513. returnSuccessMsg("删除成功!");
  9514. return;
  9515. }
  9516. public void ins_erp_placeregistbyorder()
  9517. {
  9518. string ctid = GetPostString("ctid");
  9519. if (ctid.Length > 0)
  9520. {
  9521. StringBuilder sql = new StringBuilder();
  9522. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  9523. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9524. if (dt.Rows.Count > 0)
  9525. {
  9526. foreach (DataRow dr in dt.Rows)
  9527. {
  9528. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  9529. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  9530. entity.AddUserId = CurrentUser.UserID;
  9531. entity.tid = dr["tid"].ToString();
  9532. entity.Did = Convert.ToString(dr["ctid"]);
  9533. entity.splitTag = dr["SplitTag"].ToString();
  9534. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9535. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9536. if (pre_ctid.Length > 0)
  9537. {
  9538. sellmemo = sellmemo.Replace(pre_ctid, "");
  9539. }
  9540. sellmemo = sellmemo.Replace("[", "");
  9541. sellmemo = sellmemo.Replace("]", "");
  9542. entity.FileName = sellmemo;
  9543. string count = dr["ProductCount"].ToString();
  9544. int usecount = commonHelper.getIntCountFromString(count);
  9545. entity.DeliveryCount = usecount;
  9546. entity.CurState = "未完成";
  9547. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9548. {
  9549. entity.Supplier = 24;//dl手提袋定制
  9550. }
  9551. else
  9552. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9553. entity.CreateTime = DateTime.Now;
  9554. entity.Create();
  9555. }
  9556. returnSuccessMsg("操作成功");
  9557. return;
  9558. }
  9559. returnErrorMsg("没有找到对应订单");
  9560. return;
  9561. }
  9562. returnErrorMsg("缺少订单编号");
  9563. return;
  9564. }
  9565. public void get_erp_persuadelist()
  9566. {
  9567. DataStruct dStruct = GetPostStruct();
  9568. List<string> lw = new List<string>();
  9569. string ctid = GetPostString("ctid");
  9570. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9571. string shopname = GetPostString("shopname");
  9572. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9573. string buyernick = GetPostString("buyer_nick");
  9574. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9575. string customer = GetPostString("customer");
  9576. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9577. string returndate1 = GetPostString("returndate1");
  9578. string returndate2 = GetPostString("returndate2");
  9579. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9580. if (dw.Length > 0) lw.Add(dw);
  9581. string finishDate1 = GetPostString("finishdate1");
  9582. string finishDate2 = GetPostString("finishdate2");
  9583. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9584. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9585. string persuadetype = GetPostString("persuadetype");
  9586. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9587. string returnvstate = GetPostString("returnvstate");
  9588. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9589. dStruct.Order = "created desc";
  9590. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9591. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9592. writeGridDataTableJson(dStruct.TotalCount, dt);
  9593. }
  9594. public void upd_erp_returnpersuadeback()
  9595. {
  9596. if (UrlPostParmsCheck("ID"))
  9597. {
  9598. int eid = GetPostInt("ID");
  9599. CeErpPersuade entity = null;
  9600. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9601. if (entity != null)
  9602. {
  9603. entity.backreason = GetPostString("reason");
  9604. entity.pstate = 2;
  9605. entity.verifytime = DateTime.Now;
  9606. entity.verifyuserid = CurrentUser.UserID;
  9607. entity.Update();
  9608. returnSuccessMsg("退回成功!");
  9609. return;
  9610. }
  9611. returnErrorMsg("找不到订单记录");
  9612. }
  9613. }
  9614. public void upd_erp_returnpersuadeverify()
  9615. {
  9616. if (UrlPostParmsCheck("ID"))
  9617. {
  9618. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9619. {
  9620. returnErrorMsg("暂无权限审核");
  9621. return;
  9622. }
  9623. int eid = GetPostInt("ID");
  9624. CeErpPersuade entity = null;
  9625. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9626. if (entity != null)
  9627. {
  9628. entity.pstate = 1;
  9629. entity.verifytime = DateTime.Now;
  9630. entity.verifyuserid = CurrentUser.UserID;
  9631. entity.Update();
  9632. returnSuccessMsg("审核成功!");
  9633. return;
  9634. }
  9635. returnErrorMsg("找不到订单记录");
  9636. }
  9637. }
  9638. public void del_erp_persuade()
  9639. {
  9640. if (UrlPostParmsCheck("ID"))
  9641. {
  9642. int eid = GetPostInt("ID");
  9643. CeErpPersuade.Del(eid);
  9644. returnSuccessMsg("操作成功");
  9645. return;
  9646. }
  9647. }
  9648. public void get_erp_oldcustoupload()
  9649. {
  9650. DataStruct dStruct = GetPostStruct();
  9651. List<string> lw = new List<string>();
  9652. string buyernick = GetPostString("buyer_nick");
  9653. if (buyernick.Length > 0)
  9654. {
  9655. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9656. }
  9657. else
  9658. return;
  9659. dStruct.Order = "pay_time desc";
  9660. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9661. DataTable dt = null;
  9662. dt = WebCache.GetData("view_erptradecell", dStruct);
  9663. writeGridDataTableJson(dStruct.TotalCount, dt);
  9664. }
  9665. public void get_erp_checkorderlist()
  9666. {
  9667. DataStruct dStruct = GetPostStruct();
  9668. List<string> lw = new List<string>();
  9669. string tid = GetPostString("ctid");
  9670. if (tid.Length > 0)
  9671. {
  9672. string select_tid = getTidByCtid(tid);
  9673. lw.Add(string.Format("tid='{0}'", select_tid));
  9674. }
  9675. string shopname = GetPostString("shopname");
  9676. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9677. string buyernick = GetPostString("buyer_nick");
  9678. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9679. string customer = GetPostString("customer");
  9680. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9681. string design = GetPostString("design");
  9682. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9683. string orderState = GetPostString("orderState");
  9684. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9685. string address = GetPostString("address");
  9686. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9687. string sellermemo = GetPostString("seller_memo");
  9688. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9689. string supplier = GetPostString("supplier");
  9690. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9691. {
  9692. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9693. }
  9694. else
  9695. {
  9696. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9697. }
  9698. string date1 = GetPostString("date1");
  9699. string date2 = GetPostString("date2");
  9700. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9701. if (dw.Length > 0) lw.Add(dw);
  9702. string placedate1 = GetPostString("placedate1");
  9703. string placedate2 = GetPostString("placedate2");
  9704. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9705. if (fdw.Length > 0) lw.Add(fdw);
  9706. string price1 = GetPostString("price1");
  9707. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9708. string price2 = GetPostString("price2");
  9709. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9710. string checkst = GetPostString("checkstate");
  9711. if (checkst.Length > 0 && "10".Equals(checkst))
  9712. {
  9713. lw.Add(string.Format("CheckOut>0"));
  9714. }
  9715. else
  9716. {
  9717. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9718. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9719. }
  9720. if (CurrentUser.UserPost.Post.Code == "AfterSale")
  9721. {
  9722. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  9723. }
  9724. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9725. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9726. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9727. writeGridDataTableJson(dStruct.TotalCount, dt);
  9728. }
  9729. public void ins_erp_startCheck()
  9730. {
  9731. if (UrlPostParmsCheck("ctid"))
  9732. {
  9733. string eid = GetPostString("ctid");
  9734. CeErpTradeCell entity = null;
  9735. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9736. if (entity != null)
  9737. {
  9738. entity.MemoOpt = 4;
  9739. entity.UpdateTime = DateTime.Now;
  9740. entity.Update();
  9741. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9742. CeErpSukuraData.createInfo(entity.ctid, 6);
  9743. returnSuccessMsg("操作成功!");
  9744. return;
  9745. }
  9746. returnErrorMsg("找不到记录");
  9747. }
  9748. }
  9749. public void upd_erp_sendXlw()
  9750. {
  9751. if (UrlPostParmsCheck("ctid"))
  9752. {
  9753. string eid = GetPostString("ctid");
  9754. CeErpTradeCell entity = null;
  9755. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9756. if (entity != null)
  9757. {
  9758. if (entity.IsSendGift == 1)
  9759. {
  9760. returnErrorMsg("请勿重复标记");
  9761. return;
  9762. }
  9763. entity.IsSendGift = 1;
  9764. entity.Update();
  9765. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9766. returnSuccessMsg("操作成功!");
  9767. return;
  9768. }
  9769. returnErrorMsg("找不到记录");
  9770. }
  9771. }
  9772. public void cancel_sendXlw()
  9773. {
  9774. if (UrlPostParmsCheck("ctid"))
  9775. {
  9776. string eid = GetPostString("ctid");
  9777. CeErpTradeCell entity = null;
  9778. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9779. if (entity != null)
  9780. {
  9781. if (entity.IsSendGift == 0)
  9782. {
  9783. returnErrorMsg("未标记小礼物");
  9784. return;
  9785. }
  9786. entity.IsSendGift = 0;
  9787. entity.Update();
  9788. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9789. returnSuccessMsg("操作成功!");
  9790. return;
  9791. }
  9792. returnErrorMsg("找不到记录");
  9793. }
  9794. }
  9795. public void get_erp_designbill()
  9796. {
  9797. DataStruct dStruct = GetPostStruct();
  9798. List<string> lw = new List<string>();
  9799. int isMy = GetInt("my");
  9800. if (isMy == 1)
  9801. {
  9802. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9803. }
  9804. string tid = GetPostString("tid");
  9805. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9806. string userName = GetPostString("design");
  9807. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9808. string price1 = GetPostString("price1");
  9809. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9810. string price2 = GetPostString("price2");
  9811. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9812. string rePrice1 = GetPostString("rePrice1");
  9813. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9814. string rePrice2 = GetPostString("rePrice2");
  9815. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9816. string designerType = GetPostString("designerType");
  9817. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9818. string orderState = GetPostString("orderState");
  9819. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9820. string endTime1 = GetPostString("endTime1");
  9821. string endTime2 = GetPostString("endTime2");
  9822. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9823. if (dw.Length > 0) lw.Add(dw);
  9824. string isDk = GetPostString("isDk");
  9825. if (isDk == "1")
  9826. {
  9827. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9828. }
  9829. else if (isDk == "0")
  9830. {
  9831. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9832. }
  9833. dStruct.Order = "oid, create_time desc";
  9834. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9835. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9836. writeGridDataTableJson(dStruct.TotalCount, dt);
  9837. }
  9838. public void upd_erp_designerbill()
  9839. {
  9840. if (UrlPostParmsCheck("ID"))
  9841. {
  9842. string eid = GetPostString("ID");
  9843. CeErpDesignerBill entity = null;
  9844. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9845. if (entity != null)
  9846. {
  9847. if (GetPostDouble("designerpirce") > 0)
  9848. {
  9849. entity.realPrice = GetPostDouble("designerpirce");
  9850. entity.update_time = DateTime.Now;
  9851. entity.update_u_id = CurrentUser.UserID;
  9852. entity.update_u_name = CurrentUser.UserName;
  9853. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9854. entity.Update();
  9855. returnSuccessMsg("操作成功!");
  9856. return;
  9857. }
  9858. else
  9859. {
  9860. entity.price = GetPostDouble("price");
  9861. entity.update_time = DateTime.Now;
  9862. entity.update_u_id = CurrentUser.UserID;
  9863. entity.update_u_name = CurrentUser.UserName;
  9864. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9865. entity.Update();
  9866. returnSuccessMsg("操作成功!");
  9867. return;
  9868. }
  9869. }
  9870. returnErrorMsg("找不到记录");
  9871. }
  9872. }
  9873. public void audit_erp_designerbill()
  9874. {
  9875. if (UrlPostParmsCheck("ID"))
  9876. {
  9877. string eid = GetPostString("ID");
  9878. CeErpDesignerBill entity = null;
  9879. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9880. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9881. if (entity != null)
  9882. {
  9883. entity.realPrice = GetPostDouble("designerpirce");
  9884. entity.update_time = DateTime.Now;
  9885. entity.update_u_id = CurrentUser.UserID;
  9886. entity.update_u_name = CurrentUser.UserName;
  9887. entity.isAudit = 1;
  9888. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9889. entity.Update();
  9890. if (orderEntity != null)
  9891. {
  9892. orderEntity.IsReadTag = 3;
  9893. orderEntity.Update();
  9894. }
  9895. returnSuccessMsg("操作成功!");
  9896. return;
  9897. }
  9898. returnErrorMsg("找不到记录");
  9899. }
  9900. }
  9901. public void all_audit_erp_designerbill()
  9902. {
  9903. if (UrlPostParmsCheck("idList"))
  9904. {
  9905. string[] list = GetPostString("idList").Split(',');
  9906. CeErpDesignerBill entity = null;
  9907. for (int i = 0; i < list.Length; i++)
  9908. {
  9909. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9910. if (entity == null) return;
  9911. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9912. if (orderEntity == null) return;
  9913. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9914. entity.update_time = DateTime.Now;
  9915. entity.update_u_id = CurrentUser.UserID;
  9916. entity.update_u_name = CurrentUser.UserName;
  9917. entity.isAudit = 1;
  9918. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9919. entity.Update();
  9920. orderEntity.IsReadTag = 3;
  9921. orderEntity.Update();
  9922. }
  9923. returnSuccessMsg("操作成功!");
  9924. return;
  9925. }
  9926. }
  9927. public void get_erp_sameorders()
  9928. {
  9929. if (UrlPostParmsCheck("ctid"))
  9930. {
  9931. string eid = GetPostString("ctid");
  9932. CeErpTradeCell entity = null;
  9933. entity = CeErpTradeCell.GetByCtid(eid);
  9934. if (entity != null)
  9935. {
  9936. StringBuilder sql = new StringBuilder();
  9937. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9938. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9939. var res = new
  9940. {
  9941. data = dt.Rows.Count
  9942. };
  9943. string ro_jsond = JsonConvert.SerializeObject(res);
  9944. returnSuccess(ro_jsond);
  9945. return;
  9946. }
  9947. returnErrorMsg("未找到订单");
  9948. return;
  9949. }
  9950. returnErrorMsg("缺少必要的参数");
  9951. }
  9952. public void get_erp_islasthavesameorder()
  9953. {
  9954. if (UrlPostParmsCheck("ctid"))
  9955. {
  9956. string eid = GetPostString("ctid");
  9957. string[] ctidList = eid.Split(',');
  9958. StringBuilder sql = new StringBuilder();
  9959. string tisCtid = "";
  9960. foreach (string ctid in ctidList)
  9961. {
  9962. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9963. if (entity != null)
  9964. {
  9965. sql = new StringBuilder();
  9966. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9967. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9968. if (dth.Rows.Count > 0)
  9969. {
  9970. tisCtid += entity.ctid;
  9971. tisCtid += ",";
  9972. }
  9973. }
  9974. }
  9975. if (tisCtid.Length > 0)
  9976. {
  9977. var res = new
  9978. {
  9979. data = tisCtid
  9980. };
  9981. string ro_jsond = JsonConvert.SerializeObject(res);
  9982. returnSuccess(ro_jsond);
  9983. }
  9984. else
  9985. {
  9986. var res = new
  9987. {
  9988. data = ""
  9989. };
  9990. string ro_jsond = JsonConvert.SerializeObject(res);
  9991. returnSuccess(ro_jsond);
  9992. }
  9993. return;
  9994. }
  9995. returnErrorMsg("缺少必要的参数");
  9996. }
  9997. public void file_client_down_url()
  9998. {
  9999. if (!UrlPostParmsCheck("userId"))
  10000. {
  10001. returnErrorMsg("缺少必要的参数");
  10002. }
  10003. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  10004. }
  10005. public void checkout_form_data()
  10006. {
  10007. if (!UrlPostParmsCheck("tid"))
  10008. {
  10009. returnErrorMsg("缺少必要的参数");
  10010. }
  10011. string tid = GetPostString("tid");
  10012. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  10013. if (ceErpOrderFormData != null)
  10014. {
  10015. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  10016. returnSuccess(ro_jsond);
  10017. return;
  10018. }
  10019. returnErrorMsg("尚未有文件!");
  10020. }
  10021. public void back_supplier_audit()
  10022. {
  10023. int userId = CurrentUser.UserID;
  10024. StringBuilder sql = new StringBuilder();
  10025. 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);
  10026. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10027. if (dt.Rows.Count > 0)
  10028. {
  10029. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10030. }
  10031. else
  10032. {
  10033. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10034. }
  10035. }
  10036. public void back_supplier_query()
  10037. {
  10038. string eid = GetPostString("ctid");
  10039. if (eid != "")
  10040. {
  10041. StringBuilder sql = new StringBuilder();
  10042. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  10043. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10044. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10045. }
  10046. else
  10047. {
  10048. returnErrorMsg("找不到订单记录");
  10049. return;
  10050. }
  10051. }
  10052. public void verified_to_order()
  10053. {
  10054. int userId = CurrentUser.UserID;
  10055. StringBuilder sql = new StringBuilder();
  10056. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  10057. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10058. if (dt.Rows.Count > 0)
  10059. {
  10060. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10061. }
  10062. else
  10063. {
  10064. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10065. }
  10066. }
  10067. public void upd_supplier_audit()
  10068. {
  10069. if (UrlPostParmsCheck("ctid"))
  10070. {
  10071. string eid = GetPostString("ctid");
  10072. string reason = GetPostString("returnreason");
  10073. CeErpTradeCell entity = null;
  10074. CeWithdraw withdraw = null;
  10075. withdraw = CeWithdraw.GetByTid(eid);
  10076. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  10077. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  10078. {
  10079. if (withdraw != null)
  10080. {
  10081. if (!withdraw.userid.Equals(CurrentUser.UserID))
  10082. {
  10083. returnSuccessMsg("您没有权限操作!");
  10084. return;
  10085. }
  10086. else
  10087. {
  10088. if (reason.Equals("1"))
  10089. {
  10090. if (entity.OrderState == -1)
  10091. {
  10092. if (entity.FinishPlaceTime == null)
  10093. {
  10094. entity.OrderState = 2;
  10095. }
  10096. else
  10097. {
  10098. entity.OrderState = 6;
  10099. }
  10100. }
  10101. entity.Update();
  10102. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10103. if (withdraw != null)
  10104. {
  10105. withdraw.status = int.Parse(reason);
  10106. withdraw.Update();
  10107. }
  10108. returnSuccessMsg("操作成功!");
  10109. return;
  10110. }
  10111. else
  10112. {
  10113. withdraw.status = int.Parse(reason);
  10114. withdraw.acknowledgingtime = DateTime.Now;
  10115. withdraw.Update();
  10116. returnSuccessMsg("查看详细请点击线下订单查询");
  10117. return;
  10118. }
  10119. }
  10120. }
  10121. // 第一个字符是 'N'
  10122. }
  10123. if (eid[0] != 'N')
  10124. {
  10125. }
  10126. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  10127. {
  10128. entity.IsVerifyToSupplier = false;
  10129. entity.IsReturn = 1;
  10130. entity.ReturnTime = DateTime.Now;
  10131. entity.ReturnReason = reason;
  10132. if (entity.OrderState == 6)
  10133. {
  10134. entity.OrderState = 5;
  10135. }
  10136. entity.Update();
  10137. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  10138. if (withdraw != null)
  10139. {
  10140. withdraw.status = int.Parse(reason);
  10141. withdraw.Update();
  10142. }
  10143. returnSuccessMsg("操作成功!");
  10144. return;
  10145. }
  10146. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  10147. {
  10148. ;
  10149. if (withdraw != null)
  10150. {
  10151. withdraw.status = int.Parse(reason);
  10152. withdraw.acknowledgingtime = DateTime.Now;
  10153. withdraw.Update();
  10154. returnSuccessMsg("供应商取消撤回!");
  10155. return;
  10156. }
  10157. }
  10158. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  10159. {
  10160. if (entity.OrderState == -1)
  10161. {
  10162. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  10163. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10164. if (!string.IsNullOrEmpty(ceErpTrade.receiver_state) && ceErpTrade.receiver_state.Contains("台湾") && string.IsNullOrEmpty(ceErpTrade.receiver_zip))
  10165. {
  10166. returnErrorMsg("台湾客户需填写身份证!");
  10167. return;
  10168. }
  10169. if (commonHelper.isFarAddress(ceErpTrade.receiver_state) && ceErpTrade.delivery_paymant == 0 && entity.IsSF != 2)
  10170. {
  10171. returnErrorMsg("偏远地区需要填写物流费!");
  10172. return;
  10173. }
  10174. if (string.IsNullOrEmpty(ceErpTradeCellExtend.spu_id) && !entity.ctid.Contains("N_") && !entity.ctid.Contains("S_"))
  10175. {
  10176. returnErrorMsg("订单spu没有确认无法通过审核!");
  10177. return;
  10178. }
  10179. if (entity.FinishPlaceTime == null)
  10180. {
  10181. entity.OrderState = 2;
  10182. }
  10183. else
  10184. {
  10185. entity.OrderState = 3;
  10186. }
  10187. commonHelper.getCytPrice(entity);
  10188. if ((entity.OtherMemo.Contains("老客户") || entity.OtherMemo.Contains("老顾客")) && entity.OtherMemo.Contains("改稿"))
  10189. {
  10190. tmcHelper.dealOldCustomerEntityTag(ref entity, ceErpTrade);
  10191. }
  10192. if (entity.IsSample > 1 || entity.seller_memo.Contains("现货") || entity.seller_memo.Contains("礼物"))
  10193. {
  10194. entity.OrderState = 6;
  10195. }
  10196. }
  10197. entity.Update();
  10198. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  10199. if (withdraw != null)
  10200. {
  10201. withdraw.status = int.Parse(reason);
  10202. withdraw.Update();
  10203. }
  10204. returnSuccessMsg("操作成功!");
  10205. return;
  10206. }
  10207. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  10208. {
  10209. if (withdraw == null)
  10210. {
  10211. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  10212. return;
  10213. }
  10214. }
  10215. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  10216. {
  10217. if (withdraw != null)
  10218. {
  10219. withdraw.status = int.Parse(reason);
  10220. withdraw.acknowledgingtime = DateTime.Now;
  10221. withdraw.Update();
  10222. returnSuccessMsg("查看详细请点击线下订单查询");
  10223. return;
  10224. }
  10225. }
  10226. return;
  10227. }
  10228. }
  10229. //校验报价
  10230. public void refund_order_tip()
  10231. {
  10232. int userid = CurrentUser.UserID;
  10233. int sectionId = CurrentUser.UserPost.OrgID;
  10234. StringBuilder sql = new StringBuilder();
  10235. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  10236. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10237. List<string> ids = new List<string>();
  10238. if (dth.Rows.Count > 0)
  10239. {
  10240. foreach (DataRow dr in dth.Rows)
  10241. {
  10242. ids.Add(dr["ID"].ToString());
  10243. }
  10244. try
  10245. {
  10246. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  10247. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  10248. }
  10249. catch (Exception ex)
  10250. {
  10251. }
  10252. }
  10253. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10254. }
  10255. public void refund_order_Design()
  10256. {
  10257. int userid = CurrentUser.UserID;
  10258. int sectionId = CurrentUser.UserPost.OrgID;
  10259. StringBuilder sql = new StringBuilder();
  10260. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  10261. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10262. List<string> ids = new List<string>();
  10263. if (dth.Rows.Count > 0)
  10264. {
  10265. foreach (DataRow dr in dth.Rows)
  10266. {
  10267. ids.Add(dr["ID"].ToString());
  10268. }
  10269. try
  10270. {
  10271. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  10272. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10273. }
  10274. catch (Exception ex)
  10275. {
  10276. }
  10277. }
  10278. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  10279. }
  10280. public void change_order_info()
  10281. {
  10282. int userid = CurrentUser.UserID;
  10283. StringBuilder sql = new StringBuilder();
  10284. 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);
  10285. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10286. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  10287. }
  10288. public void change_win_mome()
  10289. {
  10290. if (UrlPostParmsCheck("id,ctid"))
  10291. {
  10292. string id = GetPostString("id");
  10293. string ctid = GetPostString("ctid");
  10294. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  10295. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  10296. if (ce == null || ceErpMessageTip == null)
  10297. {
  10298. returnSuccessMsg("未找到对应的订单!");
  10299. return;
  10300. }
  10301. if (ce.OrderState >= 5)
  10302. {
  10303. ceErpMessageTip.isVisit = true;
  10304. ceErpMessageTip.Update();
  10305. returnSuccessMsg("已上传文件无法修改!");
  10306. return;
  10307. }
  10308. int type = GetPostInt("type");
  10309. string content = GetPostString("content");
  10310. if (type == 0)
  10311. {
  10312. content = content.Replace("(", "(");
  10313. content = content.Replace(")", ")");
  10314. string check = MidStrEx(content, "(", ")").Trim();
  10315. if (string.IsNullOrEmpty(check))
  10316. {
  10317. returnSuccessMsg("文件名格式不正确");
  10318. return;
  10319. }
  10320. }
  10321. ce.seller_memo = content;
  10322. ce.Update();
  10323. ceErpMessageTip.isVisit = true;
  10324. ceErpMessageTip.Update();
  10325. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  10326. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  10327. ApiVo apiVo = new ApiVo();
  10328. apiVo.orderNumber = ce.ctid;
  10329. apiVo.actionName = "demandDesign";
  10330. apiVo.orderRemarks = content;
  10331. apiVo.demandExamine = type + 1;
  10332. designHelper.API_WorkCore(apiVo);//demandDesign
  10333. returnSuccessMsg("修改成功!");
  10334. }
  10335. }
  10336. public static string MidStrEx(string sourse, string startstr, string endstr)
  10337. {
  10338. string result = string.Empty;
  10339. int startindex, endindex;
  10340. try
  10341. {
  10342. startindex = sourse.IndexOf(startstr);
  10343. if (startindex == -1)
  10344. return result;
  10345. string tmpstr = sourse.Substring(startindex + startstr.Length);
  10346. endindex = tmpstr.IndexOf(endstr);
  10347. if (endindex == -1)
  10348. return result;
  10349. result = tmpstr.Remove(endindex);
  10350. }
  10351. catch (Exception ex)
  10352. {
  10353. Console.WriteLine("MidStrEx Err:" + ex.Message);
  10354. }
  10355. return result;
  10356. }
  10357. public void refund_order_list()
  10358. {
  10359. int userid = CurrentUser.UserID;
  10360. int sectionId = CurrentUser.UserPost.OrgID;
  10361. StringBuilder sql = new StringBuilder();
  10362. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  10363. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10364. DataStruct dStruct = GetPostStruct();
  10365. DataTable dt = null;
  10366. List<string> ids = new List<string>();
  10367. List<string> tids = new List<string>();
  10368. if (dth.Rows.Count > 0)
  10369. {
  10370. foreach (DataRow dr in dth.Rows)
  10371. {
  10372. tids.Add("'" + dr["tid"].ToString() + "'");
  10373. ids.Add(dr["id"].ToString());
  10374. }
  10375. try
  10376. {
  10377. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  10378. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10379. List<string> lw = new List<string>();
  10380. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  10381. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10382. dt = WebCache.GetData("view_orderlist", dStruct);
  10383. }
  10384. catch (Exception ex)
  10385. {
  10386. }
  10387. }
  10388. writeGridDataTableJson(dStruct.TotalCount, dt);
  10389. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  10390. }
  10391. //新增
  10392. public void order_batch_downloads()
  10393. {
  10394. string ceid = GetPostString("tid");
  10395. String[] tid = ceid.Split(',');
  10396. order_batch_caiyingtong(tid);
  10397. /* (string success, string errors) = UploadFiles(tid);
  10398. returnSuccessMsg(success + errors);*/
  10399. return;
  10400. }
  10401. //报价接口
  10402. public void Get_To_Quote()
  10403. {
  10404. string ceid = GetPostString("ctid");
  10405. if (ceid != null)
  10406. {
  10407. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  10408. if (entity != null)
  10409. {
  10410. if (entity.seller_memo.IndexOf("种子纸") > -1)
  10411. {
  10412. return;
  10413. }
  10414. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10415. double price = 0;
  10416. if (cp == null)
  10417. {
  10418. JObject jsonObject12 = new JObject
  10419. {
  10420. { "UserId", "77886" },
  10421. { "Pwd", "lt666888" },
  10422. { "Filename", entity.seller_memo }
  10423. };
  10424. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  10425. JObject jsonObjects1 = JObject.Parse(response1);
  10426. string ms1g = (string)jsonObjects1["msg"];
  10427. if (ms1g == "报价成功")
  10428. {
  10429. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  10430. string data = (string)jsonObject1["price"];
  10431. 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 + "');";
  10432. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10433. returnSuccessMsg("获取报价成功:" + data);
  10434. price = Convert.ToDouble(data);
  10435. }
  10436. else
  10437. {
  10438. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  10439. return;
  10440. }
  10441. }
  10442. String[] beizhu = entity.seller_memo.Split('-');
  10443. String chanp = "";
  10444. if (beizhu.Length > 0)
  10445. {
  10446. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  10447. }
  10448. else
  10449. {
  10450. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10451. }
  10452. JObject jsonObject = new JObject
  10453. {
  10454. { "UserId", "77886" },
  10455. { "Pwd", "lt666888" },
  10456. { "Filename", chanp }
  10457. };
  10458. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10459. JObject jsonObjects = JObject.Parse(response);
  10460. string msg = (string)jsonObjects["msg"];
  10461. if (msg == "报价成功")
  10462. {
  10463. JObject jsonObject1 = (JObject)jsonObjects["data"];
  10464. string data = (string)jsonObject1["price"];
  10465. 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 + "');";
  10466. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  10467. returnSuccessMsg("获取报价成功:" + data);
  10468. price = Convert.ToDouble(data);
  10469. }
  10470. else
  10471. {
  10472. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  10473. return;
  10474. }
  10475. if (price > 0)
  10476. {
  10477. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  10478. if (ceErpTradeCellExtend == null)
  10479. {
  10480. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10481. ceErpTradeCellExtend.ctid = entity.ctid;
  10482. ceErpTradeCellExtend.payment_cyt = price;
  10483. ceErpTradeCellExtend.Create();
  10484. }
  10485. else
  10486. {
  10487. ceErpTradeCellExtend.payment_cyt = price;
  10488. ceErpTradeCellExtend.Update();
  10489. }
  10490. }
  10491. return;
  10492. }
  10493. }
  10494. else
  10495. {
  10496. returnErrorMsg("请至少选择一条数据");
  10497. return;
  10498. }
  10499. }
  10500. //新增
  10501. public void order_To_Supplier()
  10502. {
  10503. string ceid = GetPostString("tid");
  10504. String[] tid = ceid.Split(',');
  10505. if (tid.Length > 0)
  10506. {
  10507. try
  10508. {
  10509. for (int i = 0; i < tid.Length; i++)
  10510. {
  10511. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  10512. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  10513. entity.SupplierId = suid;
  10514. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  10515. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  10516. entity.Update();
  10517. }
  10518. }
  10519. catch (Exception ex)
  10520. {
  10521. returnErrorMsg("自动匹配供应商失败");
  10522. return;
  10523. }
  10524. }
  10525. else
  10526. {
  10527. returnErrorMsg("请至少选择一条数据");
  10528. return;
  10529. }
  10530. returnSuccessMsg("自动匹配供应商成功");
  10531. return;
  10532. }
  10533. public (string, string) UploadFiles(string[] urls)
  10534. {
  10535. string success = "";
  10536. string errors = "";
  10537. int userid = CurrentUser.UserID;
  10538. foreach (string url in urls)
  10539. {
  10540. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  10541. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  10542. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  10543. {
  10544. JObject jsonObject = new JObject
  10545. {
  10546. { "Userid", "77886" },
  10547. { "pwd", "cyt86435015" },
  10548. { "content", base64FileContent },
  10549. { "ext", Path.GetExtension(fileName) }
  10550. };
  10551. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  10552. JObject jsonObjects = JObject.Parse(response);
  10553. string msg = (string)jsonObjects["msg"];
  10554. if (msg.Equals("上传成功"))
  10555. {
  10556. success += url + " 上传成功";
  10557. }
  10558. else
  10559. {
  10560. errors += url + " 上传失败";
  10561. }
  10562. }
  10563. else
  10564. {
  10565. errors += url + " 格式出现问题";
  10566. }
  10567. }
  10568. if (urls.Length == 0)
  10569. {
  10570. return (success, errors);
  10571. }
  10572. return (success, errors);
  10573. }
  10574. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10575. {
  10576. return true; //总是接受
  10577. }
  10578. public static string HttpPost(string url, string param = null)
  10579. {
  10580. HttpWebRequest request;
  10581. //如果是发送HTTPS请求
  10582. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10583. {
  10584. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10585. request = WebRequest.Create(url) as HttpWebRequest;
  10586. request.ProtocolVersion = HttpVersion.Version10;
  10587. }
  10588. else
  10589. {
  10590. request = WebRequest.Create(url) as HttpWebRequest;
  10591. }
  10592. request.Method = "POST";
  10593. request.ContentType = "application/json";
  10594. request.Accept = "*/*";
  10595. request.Timeout = 120000;
  10596. request.AllowAutoRedirect = false;
  10597. StreamWriter requestStream = null;
  10598. WebResponse response = null;
  10599. string responseStr = null;
  10600. try
  10601. {
  10602. requestStream = new StreamWriter(request.GetRequestStream());
  10603. requestStream.Write(param);
  10604. requestStream.Close();
  10605. response = request.GetResponse();
  10606. if (response != null)
  10607. {
  10608. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10609. responseStr = reader.ReadToEnd();
  10610. reader.Close();
  10611. }
  10612. }
  10613. catch (Exception ex)
  10614. {
  10615. return ex.Message;
  10616. }
  10617. finally
  10618. {
  10619. request = null;
  10620. requestStream = null;
  10621. response = null;
  10622. }
  10623. return responseStr;
  10624. }
  10625. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10626. {
  10627. string base64FileContent;
  10628. string fileName;
  10629. using (WebClient webClient = new WebClient())
  10630. {
  10631. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10632. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10633. {
  10634. using (Stream stream = response.GetResponseStream())
  10635. {
  10636. using (MemoryStream memoryStream = new MemoryStream())
  10637. {
  10638. stream.CopyTo(memoryStream);
  10639. byte[] fileBytes = memoryStream.ToArray();
  10640. base64FileContent = Convert.ToBase64String(fileBytes);
  10641. fileName = response.Headers["Content-Disposition"];
  10642. if (!string.IsNullOrEmpty(fileName))
  10643. {
  10644. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10645. if (index >= 0)
  10646. {
  10647. fileName = fileName.Substring(index + 9).Trim('\"');
  10648. }
  10649. }
  10650. else
  10651. {
  10652. fileName = Path.GetFileName(downloadUrl);
  10653. }
  10654. }
  10655. }
  10656. }
  10657. }
  10658. return (fileName, base64FileContent);
  10659. }
  10660. //新增
  10661. public void order_batch_caiyingtong(string[] downloadUrls)
  10662. {
  10663. try
  10664. {
  10665. //遍历文件
  10666. DataStruct dStruct = GetPostStruct();
  10667. DataTable dt = null;
  10668. int userid = CurrentUser.UserID;
  10669. List<string> ids = new List<string>();//失败组
  10670. List<string> tids = new List<string>();
  10671. using (WebClient webClient = new WebClient())
  10672. {
  10673. foreach (var url in downloadUrls)
  10674. {
  10675. try
  10676. {
  10677. tids.Add("'" + url + "'");
  10678. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10679. if (entity != null)
  10680. {
  10681. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10682. if (cp == null)
  10683. {
  10684. JObject jsonObject = new JObject
  10685. {
  10686. { "Userid", "77886" },
  10687. { "pwd", "lt666888" },
  10688. { "Filename",entity.seller_memo }
  10689. };
  10690. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10691. JObject jsonObjects = JObject.Parse(response);
  10692. string msg = (string)jsonObjects["msg"];
  10693. if (msg == "报价成功")
  10694. {
  10695. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10696. DownloadAndConvertToBase64(url1);
  10697. }
  10698. else
  10699. {
  10700. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10701. }
  10702. }
  10703. else
  10704. {
  10705. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10706. JObject jsonObject = new JObject
  10707. {
  10708. { "Userid", "77886" },
  10709. { "pwd", "lt666888" },
  10710. { "Filename",chanp }
  10711. };
  10712. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10713. JObject jsonObjects = JObject.Parse(response);
  10714. string msg = (string)jsonObjects["msg"];
  10715. if (msg == "报价成功")
  10716. {
  10717. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10718. DownloadAndConvertToBase64(url1);
  10719. }
  10720. else
  10721. {
  10722. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10723. }
  10724. }
  10725. }
  10726. // 上传文件到FTP
  10727. }
  10728. catch (Exception ex)
  10729. {
  10730. Console.WriteLine($"An error occurred: {ex.Message}");
  10731. }
  10732. }
  10733. List<string> lw = new List<string>();
  10734. lw.Add(string.Format("( OrderState < 6 )"));
  10735. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10736. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10737. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10738. if (dt.Rows.Count > 0)
  10739. {
  10740. foreach (DataRow dr in dt.Rows)
  10741. {
  10742. ids.Add(dr["ctid"].ToString());
  10743. }
  10744. }
  10745. String ErrorMsgs = "";
  10746. foreach (String id in ids)
  10747. {
  10748. ErrorMsgs += id + ",";
  10749. }
  10750. if (ErrorMsgs.Length > 1)
  10751. {
  10752. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10753. }
  10754. if (ErrorMsgs.Length < 1)
  10755. {
  10756. ErrorMsgs = "上传成功";
  10757. returnSuccessMsg(ErrorMsgs);
  10758. }
  10759. else
  10760. {
  10761. returnErrorMsg("以下订单" + ErrorMsgs);
  10762. }
  10763. }
  10764. // 删除文件夹及其内容
  10765. /* Directory.Delete(localDirectory, true);*/
  10766. }
  10767. catch { }
  10768. }
  10769. public void get_center_data()
  10770. {
  10771. int userId = CurrentUser.UserID;
  10772. string postCode = CurrentUser.UserPost.Post.Code;
  10773. List<string> lw = new List<string>();
  10774. List<string> ww = new List<string>();
  10775. DateTime currentTime = DateTime.Now;
  10776. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10777. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10778. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10779. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10780. string sql = " SELECT ";
  10781. string startTime = "2023-10-01 11:22:31";
  10782. //设计
  10783. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10784. {
  10785. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10786. 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));
  10787. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10788. 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));
  10789. }
  10790. //客服
  10791. else if (postCode == "CustomerService" || postCode == "Director")
  10792. {
  10793. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10794. 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));
  10795. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10796. 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));
  10797. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10798. 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));
  10799. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10800. 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));
  10801. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10802. 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));
  10803. }
  10804. //售后
  10805. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10806. {
  10807. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10808. 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));
  10809. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10810. 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));
  10811. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10812. 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));
  10813. }
  10814. //下单部
  10815. else if (postCode == "Place" || postCode == "PlaceMr")
  10816. {
  10817. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10818. 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));
  10819. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10820. 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));
  10821. }
  10822. //车间
  10823. else if (postCode == "Supplier")
  10824. {
  10825. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10826. 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));
  10827. }
  10828. DataTable dt = new DataTable();
  10829. if (lw.Count > 0)
  10830. {
  10831. sql += string.Join(" , ", lw);
  10832. sql += " FROM ";
  10833. sql += string.Join(" , ", ww);
  10834. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10835. }
  10836. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10837. }
  10838. public void get_center_data_list()
  10839. {
  10840. int userId = CurrentUser.UserID;
  10841. string postCode = CurrentUser.UserPost.Post.Code;
  10842. string shopIds = CurrentUser.User.pemShop;
  10843. DataStruct dStruct = GetPostStruct();
  10844. List<string> lw = new List<string>();
  10845. DateTime currentTime = DateTime.Now;
  10846. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10847. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10848. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10849. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10850. string startTime = "2023-10-01 11:22:31";
  10851. int order_type = GetPostInt("order_type");
  10852. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10853. {
  10854. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10855. if (order_type == 0)
  10856. {
  10857. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10858. }
  10859. else if (order_type == 3)
  10860. {
  10861. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10862. }
  10863. else
  10864. {
  10865. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10866. }
  10867. }
  10868. //客服
  10869. if (postCode == "CustomerService" || postCode == "Director")
  10870. {
  10871. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10872. if (order_type == 0)
  10873. {
  10874. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10875. }
  10876. else if (order_type == 1)
  10877. {
  10878. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10879. }
  10880. else if (order_type == 2)
  10881. {
  10882. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10883. }
  10884. else if (order_type == 3)
  10885. {
  10886. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10887. }
  10888. else if (order_type == 4)
  10889. {
  10890. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10891. }
  10892. else
  10893. {
  10894. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10895. }
  10896. }
  10897. //售后
  10898. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10899. {
  10900. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10901. if (shopIds != "")
  10902. {
  10903. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10904. }
  10905. if (order_type == 2)
  10906. {
  10907. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10908. }
  10909. else if (order_type == 4)
  10910. {
  10911. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10912. }
  10913. else if (order_type == 5)
  10914. {
  10915. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10916. }
  10917. else
  10918. {
  10919. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10920. }
  10921. }
  10922. //下单部
  10923. if (postCode == "Place" || postCode == "PlaceMr")
  10924. {
  10925. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10926. if (shopIds != "")
  10927. {
  10928. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10929. }
  10930. else if (order_type == 1)
  10931. {
  10932. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10933. }
  10934. else if (order_type == 2)
  10935. {
  10936. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10937. }
  10938. else
  10939. {
  10940. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10941. }
  10942. }
  10943. //车间
  10944. if (postCode == "Supplier")
  10945. {
  10946. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10947. if (order_type == 5)
  10948. {
  10949. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10950. }
  10951. else
  10952. {
  10953. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10954. }
  10955. }
  10956. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10957. dStruct.Fileds = "tid,ctid";
  10958. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10959. writeGridDataTableJson(dStruct.TotalCount, dt);
  10960. }
  10961. public void aftersale_audit_master()
  10962. {
  10963. if (UrlPostParmsCheck("ctid"))
  10964. {
  10965. string ctid = GetPostString("ctid");
  10966. if (ctid.Length > 0)
  10967. {
  10968. bool result = aftersale_data_change(ctid);
  10969. if (result)
  10970. {
  10971. returnSuccessMsg("修改成功!");
  10972. return;
  10973. }
  10974. }
  10975. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10976. }
  10977. }
  10978. public void aftersale_batch_audit_master()
  10979. {
  10980. if (UrlPostParmsCheck("ctids"))
  10981. {
  10982. string ctids = GetPostString("ctids");
  10983. if (ctids.Length > 0)
  10984. {
  10985. List<string> list = new List<string>();
  10986. string[] ctid_list = ctids.Split(',');
  10987. foreach (var item in ctid_list)
  10988. {
  10989. bool result = aftersale_data_change(item);
  10990. if (!result)
  10991. {
  10992. list.Add(item);
  10993. }
  10994. }
  10995. if (list.Count > 0)
  10996. {
  10997. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10998. return;
  10999. }
  11000. returnSuccessMsg("修改成功!");
  11001. return;
  11002. }
  11003. returnErrorMsg("找不到指定售后单对应的原始订单!");
  11004. }
  11005. }
  11006. public bool aftersale_data_change(string ctid)
  11007. {
  11008. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11009. if (ceErpTradeCell != null)
  11010. {
  11011. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  11012. ceErpTradeCell.AfterSaleSupplierState = 0;
  11013. StringBuilder sql = new StringBuilder();
  11014. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  11015. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11016. CeErpTradeResponsible.DelByTid(ctid, 0);
  11017. 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 == "不理赔")
  11018. {
  11019. CeErpTradeResponsible.DelByTid(ctid, 1);
  11020. ceErpTradeCell.AfterSaleSupplierState = 1;
  11021. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11022. ceErpTradeCell.AfterSaleState = 4;
  11023. }
  11024. else
  11025. {
  11026. ceErpTradeCell.AfterSaleState = 3;
  11027. }
  11028. bool needCyt = false;
  11029. if (dt != null)
  11030. {
  11031. if (dt.Rows.Count == 1)
  11032. {
  11033. bool isEnd = false;
  11034. foreach (DataRow dr in dt.Rows)
  11035. {
  11036. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11037. {
  11038. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11039. isEnd = true;
  11040. }
  11041. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  11042. {
  11043. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11044. isEnd = true;
  11045. }
  11046. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11047. {
  11048. needCyt = true;
  11049. }
  11050. }
  11051. if (isEnd)
  11052. {
  11053. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11054. ceErpTradeCell.AfterSaleState = 4;
  11055. ceErpTradeCell.AfterSaleSupplierState = 1;
  11056. }
  11057. }
  11058. else
  11059. {
  11060. bool isAll = true;
  11061. foreach (DataRow dr in dt.Rows)
  11062. {
  11063. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  11064. {
  11065. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11066. continue;
  11067. }
  11068. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  11069. {
  11070. string path = "";
  11071. int OrgID = 0;
  11072. if (!Convert.IsDBNull(dr["OrgPath"]))
  11073. {
  11074. path = dr["OrgPath"].ToString();
  11075. }
  11076. if (!Convert.IsDBNull(dr["OrgID"]))
  11077. {
  11078. OrgID = Convert.ToInt32(dr["OrgID"]);
  11079. }
  11080. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  11081. {
  11082. CeErpTradeResponsible.DelById(dr["ID"], 1);
  11083. continue;
  11084. }
  11085. }
  11086. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && (Convert.ToInt32(dr["UserId"]) == 64 || Convert.ToInt32(dr["UserId"]) == 80))
  11087. {
  11088. needCyt = true;
  11089. }
  11090. isAll = false;
  11091. }
  11092. if (isAll)
  11093. {
  11094. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  11095. ceErpTradeCell.AfterSaleState = 4;
  11096. ceErpTradeCell.AfterSaleSupplierState = 1;
  11097. }
  11098. }
  11099. }
  11100. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  11101. {
  11102. commonHelper.sendCytAfterSale(ceErpTradeCell);
  11103. }
  11104. if (ceErpTradeCell.AfterSaleState == 4)
  11105. {
  11106. ApiVo apiVo = new ApiVo();
  11107. apiVo.orderNumber = ceErpTradeCell.ctid;
  11108. apiVo.actionName = "afterOver";
  11109. designHelper.API_WorkCore(apiVo); //afterOver
  11110. }
  11111. ceErpTradeCell.Update();
  11112. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  11113. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  11114. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  11115. return true;
  11116. }
  11117. return false;
  11118. }
  11119. public void get_erp_wechatorder()
  11120. {
  11121. DataStruct dStruct = GetPostStruct();
  11122. List<string> lw = new List<string>();
  11123. string tid = GetPostString("tid");
  11124. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11125. string shopname = GetPostString("shopname");
  11126. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11127. string buyernick = GetPostString("buyer_nick");
  11128. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11129. string customer = GetPostString("customer");
  11130. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11131. string returndate1 = GetPostString("returndate1");
  11132. string returndate2 = GetPostString("returndate2");
  11133. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11134. if (dw.Length > 0) lw.Add(dw);
  11135. string finishDate1 = GetPostString("finishdate1");
  11136. string finishDate2 = GetPostString("finishdate2");
  11137. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11138. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11139. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11140. dStruct.Order = "created desc";
  11141. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11142. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  11143. writeGridDataTableJson(dStruct.TotalCount, dt);
  11144. }
  11145. public void get_erp_wechatlist_sumprice()
  11146. {
  11147. DataStruct dStruct = GetPostStruct();
  11148. List<string> lw = new List<string>();
  11149. string tid = GetPostString("tid");
  11150. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  11151. string shopname = GetPostString("shopname");
  11152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11153. string buyernick = GetPostString("buyer_nick");
  11154. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11155. string customer = GetPostString("customer");
  11156. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  11157. string returndate1 = GetPostString("returndate1");
  11158. string returndate2 = GetPostString("returndate2");
  11159. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  11160. if (dw.Length > 0) lw.Add(dw);
  11161. string finishDate1 = GetPostString("finishdate1");
  11162. string finishDate2 = GetPostString("finishdate2");
  11163. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  11164. if (dw_finish.Length > 0) lw.Add(dw_finish);
  11165. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  11166. string mainWhere = string.Join(" and ", lw.ToArray());
  11167. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  11168. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  11169. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  11170. decimal total = 0;
  11171. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  11172. {
  11173. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  11174. }
  11175. var res = new
  11176. {
  11177. data = total
  11178. };
  11179. string ro_jsond = JsonConvert.SerializeObject(res);
  11180. returnSuccess(ro_jsond);
  11181. return;
  11182. }
  11183. public void get_erp_qr_waitdeliverylist()
  11184. {
  11185. DataStruct dStruct = GetPostStruct();
  11186. List<string> lw = new List<string>();
  11187. string tid = GetPostString("ctid");
  11188. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  11189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11190. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  11191. var res_objz = new
  11192. {
  11193. restype = 1,
  11194. data = dt
  11195. };
  11196. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  11197. returnSuccess(ro_jsonz);
  11198. }
  11199. public void get_erp_yield_list()
  11200. {
  11201. DataStruct dStruct = GetPostStruct();
  11202. List<string> lw = new List<string>();
  11203. string tid = GetPostString("ctid");
  11204. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  11205. string shopname = GetPostString("shopname");
  11206. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  11207. string buyernick = GetPostString("buyer_nick");
  11208. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  11209. //if (tid.Length == 0 && buyernick.Length == 0)
  11210. //{
  11211. // lw.Add(string.Format("IsRefund<={0}", 1));
  11212. //}
  11213. string customer = GetPostString("customer");
  11214. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11215. string design = GetPostString("design");
  11216. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11217. string orderState = GetPostString("orderState");
  11218. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  11219. string address = GetPostString("address");
  11220. 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));
  11221. string sellermemo = GetPostString("seller_memo");
  11222. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11223. string supplier = GetPostString("supplier");
  11224. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11225. string OrderArea = GetPostString("order_area");
  11226. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  11227. string placedate1 = GetPostString("placedate1");
  11228. string placedate2 = GetPostString("placedate2");
  11229. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  11230. if (fdw.Length > 0) lw.Add(fdw);
  11231. string price1 = GetPostString("price1");
  11232. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  11233. string price2 = GetPostString("price2");
  11234. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  11235. string unusualCon = GetPostString("unusualcon");
  11236. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  11237. string posTag = CurrentUser.UserPost.Post.Code;
  11238. if (posTag == "Supplier")
  11239. {
  11240. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  11241. }
  11242. lw.Add(string.Format("OrderState = 6 "));
  11243. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  11244. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  11245. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11246. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  11247. writeGridDataTableJson(dStruct.TotalCount, dt);
  11248. }
  11249. public void change_erp_sup_state()
  11250. {
  11251. if (UrlPostParmsCheck("ctid"))
  11252. {
  11253. string ctid = GetPostString("ctid");
  11254. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11255. if (ceErpTradeCell != null)
  11256. {
  11257. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11258. if (ceErpTradeCellExtend == null)
  11259. {
  11260. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11261. ceErpTradeCellExtend.ctid = ctid;
  11262. ceErpTradeCellExtend.SupState = 1;
  11263. ceErpTradeCellExtend.Create();
  11264. }
  11265. else
  11266. {
  11267. ceErpTradeCellExtend.SupState = 1;
  11268. ceErpTradeCellExtend.Update();
  11269. }
  11270. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  11271. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  11272. return;
  11273. }
  11274. returnErrorMsg("找不到订单");
  11275. }
  11276. }
  11277. public void supplier_all_downs()
  11278. {
  11279. if (UrlPostParmsCheck("tids"))
  11280. {
  11281. string tids = GetPostString("tids");
  11282. if (tids != null && tids.Length > 0)
  11283. {
  11284. StringBuilder sql = new StringBuilder();
  11285. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  11286. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11287. sql = new StringBuilder();
  11288. 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, "下载设计文件");
  11289. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11290. string[] list = tids.Split(',');
  11291. foreach (string ctid in list)
  11292. {
  11293. CeErpSukuraData.createInfo(ctid, 3);
  11294. }
  11295. designHelper.api_approveDesign(tids); //approveDesign
  11296. returnSuccessMsg("下载成功!");
  11297. return;
  11298. }
  11299. returnErrorMsg("下载订单更新失败");
  11300. }
  11301. }
  11302. public void uploaderFileSuccess()
  11303. {
  11304. if (UrlPostParmsCheck("fileName"))
  11305. {
  11306. string fileName = GetPostString("fileName");
  11307. ApiVo apiVo = new ApiVo();
  11308. apiVo.orderNumber = fileName;
  11309. apiVo.actionName = "finishDesign";
  11310. designHelper.API_WorkCore(apiVo);//finishDesign
  11311. returnSuccessMsg("");
  11312. }
  11313. }
  11314. public void get_sample2_order()
  11315. {
  11316. if (UrlPostParmsCheck("ctid"))
  11317. {
  11318. string ctid = GetPostString("ctid");
  11319. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11320. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11321. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  11322. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  11323. double total = 0.0;
  11324. double order_price = 0.0;
  11325. if (dt_bu.Rows.Count > 0)
  11326. {
  11327. foreach (DataRow dr in dt_bu.Rows)
  11328. {
  11329. total += Convert.ToDouble(dr["payment"]);
  11330. }
  11331. }
  11332. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  11333. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  11334. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  11335. string tid = ctid.Replace("S_", "");
  11336. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  11337. double paymant = 0.0;
  11338. if (entity != null)
  11339. {
  11340. paymant = entity.payment;
  11341. }
  11342. string return_reason = "";
  11343. if (dt_after != null && dt_after.Rows.Count > 0)
  11344. {
  11345. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  11346. }
  11347. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  11348. }
  11349. }
  11350. public void get_erp_design_status()
  11351. {
  11352. string designName = GetPostString("designName");
  11353. DataStruct dStruct = GetPostStruct();
  11354. if (designName.Length > 0)
  11355. {
  11356. 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";
  11357. sql_user += " and Name like '%" + designName + "%'";
  11358. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  11359. List<string> ids_list = new List<string>();
  11360. if (user_table.Rows.Count > 0)
  11361. {
  11362. foreach (DataRow item in user_table.Rows)
  11363. {
  11364. ids_list.Add(item["id"].ToString());
  11365. string ids_s = item["TeamIds"].ToString();
  11366. if (ids_s.Length > 0)
  11367. {
  11368. ids_list.AddRange(ids_s.Split(','));
  11369. }
  11370. }
  11371. }
  11372. HashSet<string> set = new HashSet<string>(ids_list);
  11373. ids_list = set.ToList();
  11374. if (ids_list.Count > 0)
  11375. {
  11376. 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));
  11377. dStruct.MainWhere = sql;
  11378. DataTable dt = null;
  11379. dt = WebCache.GetData("view_ErpUser", dStruct);
  11380. writeGridDataTableJson(dStruct.TotalCount, dt);
  11381. }
  11382. }
  11383. }
  11384. public void change_erp_order_price()
  11385. {
  11386. string ctid = GetPostString("ctid");
  11387. double price = GetPostDouble("price");
  11388. if (ctid.Length > 0)
  11389. {
  11390. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11391. if (ceErpTradeCellExtend == null)
  11392. {
  11393. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11394. ceErpTradeCellExtend.ctid = ctid;
  11395. ceErpTradeCellExtend.payment_cyt = price;
  11396. ceErpTradeCellExtend.Create();
  11397. }
  11398. else
  11399. {
  11400. ceErpTradeCellExtend.payment_cyt = price;
  11401. ceErpTradeCellExtend.Update();
  11402. }
  11403. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  11404. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  11405. {
  11406. ceErpDataSendOrderInfo.isSync = false;
  11407. ceErpDataSendOrderInfo.Update();
  11408. }
  11409. if (ceErpDataSendOrderInfo == null)
  11410. {
  11411. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  11412. ceErpDataSendOrderInfo.isSync = false;
  11413. ceErpDataSendOrderInfo.ctid = ctid;
  11414. ceErpDataSendOrderInfo.Create();
  11415. }
  11416. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  11417. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  11418. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11419. if (dth != null && dth.Rows.Count > 0 && ceErpTradeCellExtend.payment_cyt > 0)
  11420. {
  11421. dataSendOrderBean dataSendOrderBean = null;
  11422. foreach (DataRow item in dth.Rows)
  11423. {
  11424. try
  11425. {
  11426. dataSendOrderBean = new dataSendOrderBean();
  11427. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  11428. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  11429. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  11430. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  11431. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  11432. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  11433. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  11434. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  11435. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  11436. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  11437. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  11438. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  11439. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  11440. if (result != null)
  11441. {
  11442. if ("0".Equals(result.errcode))
  11443. {
  11444. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  11445. }
  11446. else
  11447. {
  11448. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  11449. }
  11450. }
  11451. }
  11452. catch (Exception ex)
  11453. {
  11454. }
  11455. }
  11456. }
  11457. returnSuccessMsg("修改成功!");
  11458. return;
  11459. }
  11460. returnErrorMsg("找不到订单");
  11461. }
  11462. public void find_he_together()
  11463. {
  11464. string ctid = GetPostString("ctid");
  11465. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11466. List<string> list = new List<string>();
  11467. if (ceErpTradeCell != null)
  11468. {
  11469. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  11470. {
  11471. 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);
  11472. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11473. if (table != null && table.Rows.Count > 0)
  11474. {
  11475. foreach (TableRow row in table.Rows)
  11476. {
  11477. }
  11478. }
  11479. }
  11480. }
  11481. returnSuccess(JsonConvert.SerializeObject(new { list }));
  11482. }
  11483. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  11484. {
  11485. //chy----19
  11486. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  11487. //GD-CYT-----64
  11488. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  11489. //ZHX----3
  11490. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  11491. //JK----97
  11492. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  11493. //ZT----70
  11494. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  11495. //GD-CYTUV---126
  11496. {126, new Dictionary<string, string> {{"uv", "uv"}}},
  11497. //LHCY-----98
  11498. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  11499. //XD-----90
  11500. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  11501. //CYCY-----14
  11502. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}},
  11503. //THLZY----122
  11504. {122, new Dictionary<string, string> {{ "烫画", "烫画" }, { "冷转印", "冷转印" }}}
  11505. };
  11506. //其他改名
  11507. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  11508. {
  11509. {15,"滴塑" }, {119,"数码" }, {121,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  11510. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  11511. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  11512. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  11513. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  11514. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  11515. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  11516. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  11517. };
  11518. //不统计
  11519. List<int> no_suppliers = new List<int>()
  11520. {
  11521. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  11522. };
  11523. //配件单
  11524. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  11525. {
  11526. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  11527. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  11528. {"别针",new List<string>(){ "卡片", "吊牌" } },
  11529. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  11530. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  11531. {"旗杆",new List<string>(){ "班旗" } },
  11532. {"牙签",new List<string>(){ "不干胶" } }
  11533. };
  11534. public void get_place_order_data()
  11535. {
  11536. string date1 = GetPostString("date1");
  11537. string date2 = GetPostString("date2");
  11538. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  11539. DateTime start = DateTime.Parse(starttime);
  11540. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  11541. DateTime end = DateTime.Parse(endtime);
  11542. if (date1 != null && date1.Length > 0)
  11543. {
  11544. DateTime dateTime = DateTime.Parse(date1);
  11545. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11546. start = DateTime.Parse(starttime);
  11547. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  11548. end = DateTime.Parse(endtime);
  11549. }
  11550. if (date2 != null && date2.Length > 0)
  11551. {
  11552. DateTime dateTime = DateTime.Parse(date2);
  11553. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  11554. end = DateTime.Parse(endtime);
  11555. }
  11556. 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);
  11557. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11558. //不干胶-----1,卡片-----29
  11559. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  11560. foreach (DataRow row in data.Rows)
  11561. {
  11562. int productId = Convert.ToInt32(row["ProductId"]);
  11563. int supplierId = Convert.ToInt32(row["SupplierId"]);
  11564. if (no_suppliers.Contains(supplierId))
  11565. {
  11566. continue;
  11567. }
  11568. string seller_memo = row["seller_memo"].ToString();
  11569. bool ispj = false;//是否配件单
  11570. bool isfirst = true;//第一个配
  11571. maps.Keys.ForEach(key =>
  11572. {
  11573. //备注包含配件
  11574. if (seller_memo.Contains(key) && isfirst)
  11575. {
  11576. List<string> list = maps[key];
  11577. ispj = true;
  11578. isfirst = false;
  11579. for (int i = 0; i < list.Count; i++)
  11580. {
  11581. if (seller_memo.Contains(list[i]))
  11582. {
  11583. ispj = false;
  11584. break;
  11585. }
  11586. }
  11587. }
  11588. });
  11589. if (ispj)
  11590. {
  11591. continue;
  11592. }
  11593. seller_memo = seller_memo.Replace("UV", "uv");
  11594. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11595. //吊牌归到卡片
  11596. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11597. seller_memo = seller_memo.Replace("卡套", "卡片");
  11598. seller_memo = seller_memo.Replace("封套", "卡片");
  11599. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11600. seller_memo = seller_memo.Replace("腰封", "卡片");
  11601. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11602. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11603. seller_memo = seller_memo.Replace("横幅", "条幅");
  11604. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11605. string map_key = "";
  11606. string type = "";
  11607. if (supplierMap.ContainsKey(supplierId))
  11608. {
  11609. foreach (var kvp in supplierMap[supplierId])
  11610. {
  11611. if (seller_memo.Contains(kvp.Key))
  11612. {
  11613. map_key = kvp.Value;
  11614. type = kvp.Value;
  11615. break;
  11616. }
  11617. }
  11618. }
  11619. if (map_key == "")
  11620. {
  11621. type = "其他";
  11622. map_key = "其他";
  11623. }
  11624. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11625. {
  11626. map_key = suppliers[supplierId];
  11627. }
  11628. if (supplierId == 70)
  11629. {
  11630. supplierId = 70;
  11631. }
  11632. map_key += "_" + row["SupplierName"].ToString();
  11633. Dictionary<string, int> map = null;
  11634. if (other_map.ContainsKey(map_key))
  11635. {
  11636. other_map.TryGetValue(map_key, out map);
  11637. }
  11638. else
  11639. {
  11640. map = new Dictionary<string, int>();
  11641. map.Add("dayDev", 0);//当天出货
  11642. map.Add("dayTotal", 0);//下单总数
  11643. map.Add("payTotal", 0);//500以上
  11644. map.Add("today", 0);//当天出货数量
  11645. map.Add("unusua", 0);//异常数
  11646. other_map.Add(map_key, map);
  11647. other_map.TryGetValue(map_key, out map);
  11648. }
  11649. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11650. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11651. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11652. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11653. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11654. {
  11655. map["dayTotal"]++;
  11656. if (supplierId == 97)
  11657. {
  11658. supplierId = 97;
  11659. }
  11660. }
  11661. if (Convert.ToDecimal(row["payment"]) >= 500)
  11662. {
  11663. map["payTotal"]++;
  11664. }
  11665. bool istoday = false;
  11666. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11667. {
  11668. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11669. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11670. {
  11671. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11672. {
  11673. map["today"]++;
  11674. }
  11675. }
  11676. else
  11677. {
  11678. if (supplierId == 80)
  11679. {
  11680. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11681. {
  11682. map["today"]++;
  11683. }
  11684. }
  11685. else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11686. {
  11687. map["today"]++;
  11688. istoday = true;
  11689. }
  11690. }
  11691. }
  11692. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11693. {
  11694. map["unusua"]++;
  11695. }
  11696. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11697. //GD-CYT-----64
  11698. DateTime two = palceTimeStart.AddHours(14);
  11699. DateTime three = palceTimeStart.AddHours(15);
  11700. DateTime four = palceTimeStart.AddHours(16);
  11701. DateTime six = palceTimeStart.AddHours(18);
  11702. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11703. {
  11704. //下午四点前 500-1000
  11705. string count = row["ProductCount"].ToString();
  11706. if (count != null && count.Length > 0)
  11707. {
  11708. int productCount = commonHelper.getPlaceProductCount(count);
  11709. if (productCount >= 500 && productCount <= 1000)
  11710. {
  11711. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11712. {
  11713. map["dayDev"]++;
  11714. }
  11715. }
  11716. }
  11717. }
  11718. //UV
  11719. else if ("uv".Equals(type))
  11720. {
  11721. //ZT----70
  11722. //ZHX----3
  11723. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11724. {
  11725. map["dayDev"]++;
  11726. }
  11727. //JK----97
  11728. //HZX----105
  11729. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11730. {
  11731. map["dayDev"]++;
  11732. }
  11733. if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
  11734. {
  11735. map["dayDev"]++;
  11736. }
  11737. }
  11738. //帆布---52|条幅---27
  11739. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11740. {
  11741. //LHCY-----98
  11742. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11743. {
  11744. map["dayDev"]++;
  11745. }
  11746. }
  11747. //条幅
  11748. else if ("条幅".Equals(type))
  11749. {
  11750. //XD-----90
  11751. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11752. {
  11753. map["dayDev"]++;
  11754. }
  11755. }
  11756. //桌布
  11757. else if ("桌布".Equals(type))
  11758. {
  11759. //XD-----90
  11760. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11761. {
  11762. map["dayDev"]++;
  11763. }
  11764. }
  11765. //DL---10
  11766. //AYTW---119
  11767. //FS-CYT-DY ----80
  11768. //JK----97
  11769. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11770. {
  11771. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11772. {
  11773. map["dayDev"]++;
  11774. if (supplierId == 80 && istoday)
  11775. {
  11776. Debug.WriteLine(seller_memo);
  11777. }
  11778. }
  11779. }
  11780. // QC---121
  11781. else if (supplierId == 121)
  11782. {
  11783. if (DateTime.Compare(FinishPlaceTime, six) < 0)
  11784. {
  11785. map["dayDev"]++;
  11786. }
  11787. }
  11788. }
  11789. DataTable dt = new DataTable();
  11790. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11791. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11792. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11793. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11794. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11795. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11796. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11797. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11798. other_map.Keys.ForEach(key =>
  11799. {
  11800. DataRow dr = dt.NewRow();
  11801. Dictionary<string, int> map = other_map[key];
  11802. string[] key_list = key.Split('_');
  11803. dr[0] = key_list[0];
  11804. dr[1] = key_list[1];
  11805. if (key_list.Length > 2)
  11806. {
  11807. dr[1] += "(" + key_list[2] + ")";
  11808. }
  11809. dr[2] = map["dayTotal"];
  11810. dr[3] = map["payTotal"];
  11811. dr[4] = map["today"];
  11812. dr[5] = map["unusua"];
  11813. dr[6] = map["dayDev"];
  11814. double rate = 0.00;
  11815. if (map["dayDev"] > 0)
  11816. {
  11817. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11818. }
  11819. dr[7] = rate.ToString();
  11820. dt.Rows.Add(dr);
  11821. });
  11822. DataView dv = new DataView(dt);
  11823. dv.Sort = "SupplierName";
  11824. //dv.Sort = "AllOrder desc";
  11825. DataTable dtNew = dv.ToTable();
  11826. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11827. }
  11828. public void check_order_desing_info()
  11829. {
  11830. string ctid = GetPostString("ctid");
  11831. if (!string.IsNullOrEmpty(ctid))
  11832. {
  11833. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11834. if (ceErpTradeCell != null)
  11835. {
  11836. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11837. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11838. return;
  11839. }
  11840. returnErrorMsg("找不到订单");
  11841. return;
  11842. }
  11843. returnErrorMsg("找不到订单");
  11844. }
  11845. public void get_timeout_detail()
  11846. {
  11847. string poscode = CurrentUser.UserPost.Post.Code;
  11848. DataStruct dStruct = GetPostStruct();
  11849. List<string> lw = new List<string>();
  11850. string id = GetPostString("id");
  11851. string pay_date1 = GetPostString("pay_date1");
  11852. string pay_date2 = GetPostString("pay_date2");
  11853. int type = GetPostInt("type");
  11854. if (type == 0)
  11855. {
  11856. if (pay_date1.Length > 0)
  11857. {
  11858. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11859. }
  11860. if (pay_date2.Length > 0)
  11861. {
  11862. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11863. }
  11864. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11865. }
  11866. if (type == 1)
  11867. {
  11868. if (pay_date1.Length > 0)
  11869. {
  11870. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11871. }
  11872. if (pay_date2.Length > 0)
  11873. {
  11874. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11875. }
  11876. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11877. }
  11878. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11879. DataTable dt = null;
  11880. dt = WebCache.GetData("view_orderlist", dStruct);
  11881. writeGridDataTableJson(dStruct.TotalCount, dt);
  11882. }
  11883. public void saveUrgentChargePrice()
  11884. {
  11885. string ctid = GetPostString("ctid");
  11886. if (!string.IsNullOrEmpty(ctid))
  11887. {
  11888. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11889. if (ceErpTradeCell != null)
  11890. {
  11891. double prices = commonHelper.calculationPrice(ceErpTradeCell);
  11892. if (prices <= 100)
  11893. {
  11894. returnErrorMsg("此订单金额不足100元,无法加急。");
  11895. return;
  11896. }
  11897. double price = GetPostDouble("price");
  11898. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11899. if (ceErpTradeCellExtend == null)
  11900. {
  11901. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11902. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11903. }
  11904. ceErpTradeCellExtend.urgentCharge = price;
  11905. if (ceErpTradeCellExtend.ID > 0)
  11906. {
  11907. ceErpTradeCellExtend.Update();
  11908. }
  11909. else
  11910. {
  11911. ceErpTradeCellExtend.Save();
  11912. }
  11913. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "手动订单加急", 0, 1);
  11914. returnSuccessMsg("修改成功!");
  11915. return;
  11916. }
  11917. returnErrorMsg("找不到订单");
  11918. return;
  11919. }
  11920. returnErrorMsg("找不到订单");
  11921. }
  11922. public void finish_erp_order()
  11923. {
  11924. string ctid = GetPostString("ctid");
  11925. if (!string.IsNullOrEmpty(ctid))
  11926. {
  11927. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11928. {
  11929. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11930. if (ceErpTradeCell != null)
  11931. {
  11932. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11933. ceErpTradeCell.Update();
  11934. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11935. returnSuccessMsg("修改成功!");
  11936. return;
  11937. }
  11938. }
  11939. }
  11940. returnErrorMsg("找不到订单");
  11941. }
  11942. public void get_trade_order_list()
  11943. {
  11944. string tid = GetPostString("tid");
  11945. if (!string.IsNullOrEmpty(tid))
  11946. {
  11947. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11948. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11949. writeGridDataTableJson(data.Rows.Count, data);
  11950. return;
  11951. }
  11952. returnErrorMsg("找不到订单");
  11953. }
  11954. public void save_cell_spu()
  11955. {
  11956. string ctid = GetPostString("ctid");
  11957. string spu_id = GetPostString("spu_id");
  11958. if (!string.IsNullOrEmpty(ctid))
  11959. {
  11960. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11961. if (ceErpTradeCellExtend == null)
  11962. {
  11963. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11964. ceErpTradeCellExtend.ctid = ctid;
  11965. }
  11966. ceErpTradeCellExtend.spu_id = spu_id;
  11967. if (!string.IsNullOrEmpty(spu_id))
  11968. {
  11969. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11970. ceErpTradeCellExtend = commonHelper.sendSpuData(ceErpTradeCell, ceErpTradeCellExtend);
  11971. }
  11972. if (ceErpTradeCellExtend.ID == 0)
  11973. {
  11974. ceErpTradeCellExtend.Create();
  11975. }
  11976. else
  11977. {
  11978. ceErpTradeCellExtend.Update();
  11979. }
  11980. returnSuccessMsg("修改成功!");
  11981. return;
  11982. }
  11983. returnErrorMsg("找不到订单");
  11984. }
  11985. public void change_express_info()
  11986. {
  11987. string ctid = GetPostString("ctid");
  11988. string transNo = GetPostString("transNo");
  11989. string transCom = GetPostString("transCom");
  11990. if (!string.IsNullOrEmpty(ctid))
  11991. {
  11992. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11993. if (ceErpTradeCellExtend == null)
  11994. {
  11995. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11996. ceErpTradeCellExtend.ctid = ctid;
  11997. }
  11998. ceErpTradeCellExtend.modExpressNo = transNo;
  11999. ceErpTradeCellExtend.modExpressCom = transCom;
  12000. ceErpTradeCellExtend.readMod = 2;
  12001. if (ceErpTradeCellExtend.ID == 0)
  12002. {
  12003. ceErpTradeCellExtend.Create();
  12004. }
  12005. else
  12006. {
  12007. ceErpTradeCellExtend.Update();
  12008. }
  12009. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  12010. returnSuccessMsg("修改成功!");
  12011. return;
  12012. }
  12013. returnErrorMsg("找不到订单");
  12014. }
  12015. public void get_change_express_list()
  12016. {
  12017. DataStruct dStruct = GetPostStruct();
  12018. List<string> lw = new List<string>();
  12019. int st = 2;
  12020. string tid = GetPostString("ctid");
  12021. if (tid.Length > 0)
  12022. {
  12023. string select_tid = getTidByCtid(tid);
  12024. lw.Add(string.Format("tid='{0}'", select_tid));
  12025. }
  12026. string shopname = GetPostString("shopname");
  12027. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12028. string buyernick = GetPostString("buyer_nick");
  12029. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12030. string sellermemo = GetPostString("seller_memo");
  12031. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12032. string supplier = GetPostString("supplier");
  12033. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12034. string customer = GetPostString("customer");
  12035. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12036. string design = GetPostString("design");
  12037. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12038. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12039. string poscode = CurrentUser.UserPost.Post.Code;
  12040. if (poscode != "SysAdmin")
  12041. {
  12042. string shopid = CurrentUser.User.pemShop;
  12043. lw.Add(string.Format("shopId in ({0})", shopid));
  12044. }
  12045. lw.Add("readMod = 2");
  12046. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12047. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  12048. writeGridDataTableJson(dStruct.TotalCount, dt);
  12049. }
  12050. public void deal_express_complete()
  12051. {
  12052. string ctid = GetPostString("ctid");
  12053. if (!string.IsNullOrEmpty(ctid))
  12054. {
  12055. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12056. if (ceErpTradeCellExtend == null)
  12057. {
  12058. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12059. ceErpTradeCellExtend.ctid = ctid;
  12060. }
  12061. ceErpTradeCellExtend.readMod = 1;
  12062. if (ceErpTradeCellExtend.ID == 0)
  12063. {
  12064. ceErpTradeCellExtend.Create();
  12065. }
  12066. else
  12067. {
  12068. ceErpTradeCellExtend.Update();
  12069. }
  12070. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  12071. returnSuccessMsg("修改成功!");
  12072. return;
  12073. }
  12074. returnErrorMsg("找不到订单");
  12075. }
  12076. public void aftersale_return_visit()
  12077. {
  12078. string ctid = GetPostString("ctid");
  12079. if (!string.IsNullOrEmpty(ctid))
  12080. {
  12081. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  12082. if (ceErpTradeCellExtend == null)
  12083. {
  12084. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  12085. ceErpTradeCellExtend.ctid = ctid;
  12086. }
  12087. ceErpTradeCellExtend.returnVisit = 1;
  12088. if (ceErpTradeCellExtend.ID == 0)
  12089. {
  12090. ceErpTradeCellExtend.Create();
  12091. }
  12092. else
  12093. {
  12094. ceErpTradeCellExtend.Update();
  12095. }
  12096. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12097. if (ceErpTradeAfterSaleExtend != null)
  12098. {
  12099. ceErpTradeAfterSaleExtend.TextResult = "";
  12100. ceErpTradeAfterSaleExtend.Update();
  12101. }
  12102. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  12103. returnSuccessMsg("修改成功!");
  12104. return;
  12105. }
  12106. returnErrorMsg("找不到订单");
  12107. }
  12108. public void orderPlaceInfo()
  12109. {
  12110. string ctids = GetPostString("ctids");
  12111. string[] list = ctids.Split(',');
  12112. foreach (string ctid in list)
  12113. {
  12114. CeErpSukuraData.createInfo(ctid, 3);
  12115. }
  12116. StringBuilder sql = new StringBuilder();
  12117. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  12118. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  12119. designHelper.api_approveDesign(ctids); //approveDesign
  12120. returnSuccessMsg("");
  12121. }
  12122. public void get_issue_list()
  12123. {
  12124. DataStruct dStruct = GetPostStruct();
  12125. List<string> lw = new List<string>();
  12126. int st = 2;
  12127. string tid = GetPostString("ctid");
  12128. if (tid.Length > 0)
  12129. {
  12130. string select_tid = getTidByCtid(tid);
  12131. lw.Add(string.Format("tid='{0}'", select_tid));
  12132. }
  12133. string shopname = GetPostString("shopname");
  12134. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  12135. string buyernick = GetPostString("buyer_nick");
  12136. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  12137. string sellermemo = GetPostString("seller_memo");
  12138. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  12139. string supplier = GetPostString("supplier");
  12140. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  12141. string customer = GetPostString("customer");
  12142. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  12143. string design = GetPostString("design");
  12144. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  12145. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  12146. string poscode = CurrentUser.UserPost.Post.Code;
  12147. if (poscode != "SysAdmin")
  12148. {
  12149. string shopid = CurrentUser.User.pemShop;
  12150. lw.Add(string.Format("shopId in ({0})", shopid));
  12151. }
  12152. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode) || "CustomerMr".Equals(poscode))
  12153. {
  12154. lw.Add("IssueState = 1");
  12155. }
  12156. else
  12157. {
  12158. string iisstate = GetPostString("iisstate");
  12159. if ("1".Equals(iisstate))
  12160. {
  12161. lw.Add("IssueState =1");
  12162. }
  12163. else if ("2".Equals(iisstate))
  12164. {
  12165. lw.Add("IssueState = 2");
  12166. }
  12167. else
  12168. {
  12169. lw.Add("IssueState > 0");
  12170. }
  12171. }
  12172. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12173. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  12174. writeGridDataTableJson(dStruct.TotalCount, dt);
  12175. }
  12176. public void saveIssueContent()
  12177. {
  12178. string ctid = GetPostString("ctid");
  12179. if (!string.IsNullOrEmpty(ctid))
  12180. {
  12181. string content = GetPostString("content");
  12182. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12183. if (ceErpTradeAfterSaleExtend == null)
  12184. {
  12185. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  12186. ceErpTradeAfterSaleExtend.tid = ctid;
  12187. }
  12188. ceErpTradeAfterSaleExtend.IssueContent = content;
  12189. ceErpTradeAfterSaleExtend.IssueState = 1;
  12190. if (ceErpTradeAfterSaleExtend.ID > 0)
  12191. {
  12192. ceErpTradeAfterSaleExtend.Update();
  12193. }
  12194. else
  12195. {
  12196. ceErpTradeAfterSaleExtend.Create();
  12197. }
  12198. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  12199. returnSuccessMsg("添加成功!");
  12200. return;
  12201. }
  12202. returnErrorMsg("找不到订单");
  12203. }
  12204. public void dealIssueContent()
  12205. {
  12206. string ctid = GetPostString("ctid");
  12207. if (!string.IsNullOrEmpty(ctid))
  12208. {
  12209. string content = GetPostString("content");
  12210. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  12211. if (ceErpTradeAfterSaleExtend != null)
  12212. {
  12213. ceErpTradeAfterSaleExtend.IssueState = 2;
  12214. ceErpTradeAfterSaleExtend.Update();
  12215. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  12216. returnSuccessMsg("修改完成!");
  12217. return;
  12218. }
  12219. }
  12220. returnErrorMsg("找不到订单");
  12221. }
  12222. public void set_tid_attachments()
  12223. {
  12224. string tid = GetPostString("tid");
  12225. string atta = GetPostString("atta");
  12226. if (!string.IsNullOrEmpty(tid))
  12227. {
  12228. if (string.IsNullOrEmpty(atta))
  12229. {
  12230. returnErrorMsg("文件地址为空");
  12231. return;
  12232. }
  12233. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12234. if (ceErpTradeCell != null)
  12235. {
  12236. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12237. if (ceErpTrade == null)
  12238. {
  12239. returnErrorMsg("找不到订单");
  12240. return;
  12241. }
  12242. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  12243. bool isSend = false;
  12244. if (dt != null && dt.Rows.Count > 0)
  12245. {
  12246. foreach (DataRow row in dt.Rows)
  12247. {
  12248. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  12249. {
  12250. isSend = true;
  12251. }
  12252. }
  12253. if (isSend)
  12254. {
  12255. returnErrorMsg("已发货无法修改");
  12256. return;
  12257. }
  12258. ceErpTrade.Attachments = atta;
  12259. ceErpTrade.Update();
  12260. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址:" + atta, 6);
  12261. returnSuccessMsg("上传成功!");
  12262. return;
  12263. }
  12264. }
  12265. }
  12266. returnErrorMsg("找不到订单");
  12267. }
  12268. public void get_tid_attachments()
  12269. {
  12270. string tid = GetPostString("tid");
  12271. if (!string.IsNullOrEmpty(tid))
  12272. {
  12273. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  12274. if (ceErpTradeCell != null)
  12275. {
  12276. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  12277. if (ceErpTrade == null)
  12278. {
  12279. returnErrorMsg("找不到订单");
  12280. return;
  12281. }
  12282. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  12283. return;
  12284. }
  12285. }
  12286. returnErrorMsg("找不到订单");
  12287. }
  12288. public void check_erp_sameorders()
  12289. {
  12290. if (UrlPostParmsCheck("ctid"))
  12291. {
  12292. string eid = GetPostString("ctid");
  12293. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12294. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12295. if (entity != null && ceErpTrade != null)
  12296. {
  12297. if (entity.OrderState > 6)
  12298. {
  12299. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12300. return;
  12301. }
  12302. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12303. List<string> ids = new List<string>();
  12304. if (dt != null && dt.Rows.Count > 1)
  12305. {
  12306. bool needhe = true;
  12307. foreach (DataRow dr in dt.Rows)
  12308. {
  12309. ids.Add("'" + dr["ctid"] + "'");
  12310. /* //备注有合包
  12311. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  12312. {
  12313. needhe = true;
  12314. }
  12315. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  12316. {
  12317. needhe = true;
  12318. }
  12319. //顺丰快递
  12320. if (Convert.ToInt32(dr["IsSF"]) > 0)
  12321. {
  12322. needhe = true;
  12323. }*/
  12324. }
  12325. if (!needhe)
  12326. {
  12327. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12328. return;
  12329. }
  12330. StringBuilder sql = new StringBuilder();
  12331. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12332. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  12333. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  12334. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12335. foreach (DataRow dr in dt.Rows)
  12336. {
  12337. dr["dstate"] = 0;
  12338. dr["dnumber"] = 0;
  12339. foreach (DataRow row in dt1.Rows)
  12340. {
  12341. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  12342. {
  12343. dr["dstate"] = 2;
  12344. dr["default"] = 1;
  12345. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  12346. }
  12347. }
  12348. if (eid.Equals(dr["ctid"].ToString()))
  12349. {
  12350. dr["dstate"] = 1;
  12351. dr["default"] = 1;
  12352. }
  12353. }
  12354. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12355. return;
  12356. }
  12357. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12358. return;
  12359. }
  12360. returnErrorMsg("未找到订单");
  12361. return;
  12362. }
  12363. returnErrorMsg("缺少必要的参数");
  12364. }
  12365. public void get_mark_number()
  12366. {
  12367. string eid = GetPostString("ctid");
  12368. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  12369. if (entity != null)
  12370. {
  12371. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  12372. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  12373. int current = 1;
  12374. if (ceErpDeliverMark == null)
  12375. {
  12376. DataTable dt = commonHelper.getSameOrderList(entity, ceErpTrade);
  12377. List<string> ids = new List<string>();
  12378. if (dt != null && dt.Rows.Count > 1)
  12379. {
  12380. foreach (DataRow dr in dt.Rows)
  12381. {
  12382. ids.Add("'" + dr["ctid"] + "'");
  12383. }
  12384. //查询已有的编号
  12385. StringBuilder sql = new StringBuilder();
  12386. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  12387. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12388. if (dt1 == null || dt1.Rows.Count == 0)
  12389. {
  12390. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  12391. List<int> list_number = new List<int>();
  12392. foreach (DataRow row in numbers.Rows)
  12393. {
  12394. list_number.Add(Convert.ToInt32(row["markNumber"]));
  12395. }
  12396. //查询空余编号
  12397. for (int i = 0; i < list_number.Count + 2; i++)
  12398. {
  12399. if (!list_number.Contains(current))
  12400. {
  12401. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  12402. //防止查询过程中有新数据生成
  12403. if (ceErpDeliverMark1 == null)
  12404. {
  12405. break;
  12406. }
  12407. }
  12408. current++;
  12409. }
  12410. }
  12411. else
  12412. {
  12413. foreach (DataRow row in dt1.Rows)
  12414. {
  12415. current = Convert.ToInt32(row["markNumber"]);
  12416. }
  12417. }
  12418. ceErpDeliverMark = new CeErpDeliverMark();
  12419. ceErpDeliverMark.ctid = eid;
  12420. ceErpDeliverMark.createtime = DateTime.Now;
  12421. if (ceErpTrade != null)
  12422. {
  12423. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  12424. }
  12425. ceErpDeliverMark.markNumber = current;
  12426. ceErpDeliverMark.Create();
  12427. }
  12428. }
  12429. else
  12430. {
  12431. current = ceErpDeliverMark.markNumber;
  12432. }
  12433. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  12434. return;
  12435. }
  12436. }
  12437. public void aftersaleCytSend()
  12438. {
  12439. string ctid = GetPostString("ctid");
  12440. if (!string.IsNullOrEmpty(ctid))
  12441. {
  12442. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12443. if (ceErpTradeCell != null)
  12444. {
  12445. commonHelper.sendCytAfterSale(ceErpTradeCell);
  12446. }
  12447. returnSuccessMsg("推送成功");
  12448. return;
  12449. }
  12450. returnErrorMsg("缺少必要的参数");
  12451. }
  12452. public void packOrderInfo()
  12453. {
  12454. string ctids = GetPostString("ctids");
  12455. if (!string.IsNullOrEmpty(ctids))
  12456. {
  12457. string[] ctid_list = ctids.Split(',');
  12458. if (ctid_list.Length > 20)
  12459. {
  12460. returnErrorMsg("单次下载次数不能超过20个");
  12461. return;
  12462. }
  12463. string textCtids = "'" + ctids.Replace(",", "','") + "'";
  12464. StringBuilder sql = new StringBuilder();
  12465. sql.AppendFormat("select ctid,OrderState,SupplierId from CE_ErpTradeCell where ctid in ({0})", textCtids);
  12466. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12467. int supplierId = 0;
  12468. StringBuilder insterSql = new StringBuilder();
  12469. for (int i = 0; i < dt.Rows.Count; i++)
  12470. {
  12471. DataRow row = dt.Rows[i];
  12472. if (i == 0)
  12473. {
  12474. supplierId = Convert.ToInt32(row["SupplierId"]);
  12475. }
  12476. if (supplierId > 0 && supplierId != Convert.ToInt32(row["SupplierId"]))
  12477. {
  12478. returnErrorMsg("同车间的订单才能一起打包");
  12479. return;
  12480. }
  12481. int orderState = Convert.ToInt32(row["OrderState"]);
  12482. if (orderState != 5)
  12483. {
  12484. returnErrorMsg(row["ctid"].ToString() + "订单状态不对无法打包。");
  12485. return;
  12486. }
  12487. insterSql.AppendLine("INSERT INTO [CE_ErpPackDataItem] ([ctid], [packId]) VALUES ( '" + row["ctid"].ToString() + "', {0});");
  12488. }
  12489. CeErpPackData ceErpPackData = new CeErpPackData();
  12490. ceErpPackData.fileName = supplierId + "LT_" + DateTime.Now.ToString("yyyyMMddhhMmss") + CurrentUser.UserID + ".zip";
  12491. ceErpPackData.supplierId = supplierId;
  12492. ceErpPackData.createtime = DateTime.Now;
  12493. ceErpPackData.createBy = CurrentUser.UserID;
  12494. ceErpPackData.createName = CurrentUser.UserName;
  12495. ceErpPackData.Create();
  12496. if (ceErpPackData.ID > 0)
  12497. {
  12498. string inSql = string.Format(insterSql.ToString(), ceErpPackData.ID);
  12499. DbHelper.DbConn.ExecuteNonQuery(inSql);
  12500. }
  12501. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=6,IsVerifyToSupplier=0 where ctid in ({0}) and OrderState=5 and IsVerifyToSupplier=1", textCtids));
  12502. returnSuccessMsg("打包成功");
  12503. return;
  12504. }
  12505. returnErrorMsg("缺少必要的参数");
  12506. }
  12507. public void rePackOrderInfo()
  12508. {
  12509. string id = GetPostString("id");
  12510. if (!string.IsNullOrEmpty(id))
  12511. {
  12512. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12513. if (ceErpPackData == null)
  12514. {
  12515. returnSuccessMsg("查无数据");
  12516. return;
  12517. }
  12518. ceErpPackData.upStatus = 0;
  12519. ceErpPackData.message = "";
  12520. ceErpPackData.Update();
  12521. returnSuccessMsg("打包成功");
  12522. return;
  12523. }
  12524. returnErrorMsg("缺少必要的参数");
  12525. }
  12526. public void backPackOrderInfo()
  12527. {
  12528. string id = GetPostString("id");
  12529. if (!string.IsNullOrEmpty(id))
  12530. {
  12531. CeErpPackData ceErpPackData = CeErpPackData.Get(id);
  12532. if (ceErpPackData == null)
  12533. {
  12534. returnSuccessMsg("查无数据");
  12535. return;
  12536. }
  12537. ceErpPackData.upStatus = 4;
  12538. ceErpPackData.Update();
  12539. List<string> list = new List<string>();
  12540. StringBuilder sql = new StringBuilder();
  12541. sql.AppendFormat("select * from CE_ErpPackDataItem where packId = {0}", ceErpPackData.ID);
  12542. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12543. for (int i = 0; i < dt.Rows.Count; i++)
  12544. {
  12545. DataRow row = dt.Rows[i];
  12546. list.Add("'" + row["ctid"].ToString() + "'");
  12547. }
  12548. string textCtids = string.Join(",", list);
  12549. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpTradeCell set OrderState=5,IsVerifyToSupplier=0,IsReturn=1,ReturnTime=GETDATE(),ReturnReason='无法打包' where ctid in ({0}) and OrderState=6", textCtids));
  12550. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", textCtids, (int)OrderState.下单完成, 0, "无法打包退回"));
  12551. returnSuccessMsg("退回成功");
  12552. return;
  12553. }
  12554. returnErrorMsg("缺少必要的参数");
  12555. }
  12556. public void addPackDownNum()
  12557. {
  12558. string id = GetPostString("id");
  12559. if (!string.IsNullOrEmpty(id))
  12560. {
  12561. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpPackData set downNum+=1 where id= {0}", id));
  12562. returnSuccessMsg("下载成功");
  12563. return;
  12564. }
  12565. returnErrorMsg("缺少必要的参数");
  12566. }
  12567. public void get_pack_list()
  12568. {
  12569. DataStruct dStruct = GetPostStruct();
  12570. List<string> lw = new List<string>();
  12571. string supplier = GetPostString("supplier");
  12572. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  12573. string posTag = CurrentUser.UserPost.Post.Code;
  12574. if (posTag == "Supplier")
  12575. {
  12576. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  12577. }
  12578. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12579. dStruct.Order = "createtime desc";
  12580. DataTable dt = WebCache.GetData("view_packCenter", dStruct);
  12581. writeGridDataTableJson(dStruct.TotalCount, dt);
  12582. }
  12583. public void get_pack_order_list()
  12584. {
  12585. string packId = GetPostString("packId");
  12586. if (string.IsNullOrEmpty(packId))
  12587. {
  12588. returnErrorMsg("缺少必要的参数");
  12589. return;
  12590. }
  12591. StringBuilder sql = new StringBuilder();
  12592. sql.AppendFormat("select c.ctid,c.seller_memo,i.message from CE_ErpPackDataItem i left join CE_ErpTradeCell c on i.ctid=c.ctid where i.packId = {0}", packId);
  12593. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  12594. if (dt == null || dt.Rows.Count == 0)
  12595. {
  12596. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  12597. return;
  12598. }
  12599. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12600. return;
  12601. }
  12602. public void get_supplier_product_time_list()
  12603. {
  12604. DataStruct dStruct = GetPostStruct();
  12605. List<string> lw = new List<string>();
  12606. string supplier = GetPostString("supplier");
  12607. if (supplier.Length > 0) lw.Add(string.Format("supplierName = '{0}'", supplier));
  12608. string posTag = CurrentUser.UserPost.Post.Code;
  12609. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  12610. DataTable dt = WebCache.GetData("CE_ErpSupplierProductTime", dStruct);
  12611. writeGridDataTableJson(dStruct.TotalCount, dt);
  12612. }
  12613. public void saveSupplierProductTime()
  12614. {
  12615. string productId = GetPostString("productId");
  12616. if (string.IsNullOrEmpty(productId))
  12617. {
  12618. returnErrorMsg("缺少必要的参数");
  12619. return;
  12620. }
  12621. string productName = GetPostString("productName");
  12622. int supplierId = GetPostInt("supplierId");
  12623. if (supplierId == 0)
  12624. {
  12625. returnErrorMsg("缺少必要的参数");
  12626. return;
  12627. }
  12628. int quantity = GetPostInt("quantity");
  12629. int sendDay = GetPostInt("sendTime");
  12630. string supplierName = GetPostString("supplierName");
  12631. string craft = GetPostString("craft");
  12632. string deadLine = GetPostString("deadLine");
  12633. string dayDeadLine = GetPostString("dayDeadLine");
  12634. try
  12635. {
  12636. int eid = GetPostInt("eid");
  12637. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12638. if (ceErpSupplierProductTime == null)
  12639. {
  12640. ceErpSupplierProductTime = new CeErpSupplierProductTime();
  12641. }
  12642. ceErpSupplierProductTime.productId = productId;
  12643. ceErpSupplierProductTime.productName = productName;
  12644. ceErpSupplierProductTime.supplierId = supplierId;
  12645. ceErpSupplierProductTime.supplierName = supplierName;
  12646. ceErpSupplierProductTime.craft = craft;
  12647. ceErpSupplierProductTime.sendDay = sendDay;
  12648. ceErpSupplierProductTime.quantity = quantity;
  12649. if (!string.IsNullOrEmpty(deadLine))
  12650. {
  12651. ceErpSupplierProductTime.deadLine = TimeSpan.Parse(deadLine).ToString();
  12652. }
  12653. if (!string.IsNullOrEmpty(dayDeadLine))
  12654. {
  12655. ceErpSupplierProductTime.dayDeadLine = TimeSpan.Parse(dayDeadLine).ToString();
  12656. }
  12657. if (ceErpSupplierProductTime.ID == 0)
  12658. {
  12659. ceErpSupplierProductTime.Save();
  12660. }
  12661. else
  12662. {
  12663. ceErpSupplierProductTime.Update();
  12664. }
  12665. }
  12666. catch (Exception e)
  12667. {
  12668. }
  12669. returnSuccessMsg("保存成功");
  12670. return;
  12671. }
  12672. public void delSupplierProductTime()
  12673. {
  12674. int eid = GetPostInt("eid");
  12675. if (eid > 0)
  12676. {
  12677. CeErpSupplierProductTime ceErpSupplierProductTime = CeErpSupplierProductTime.Get(eid);
  12678. if (ceErpSupplierProductTime == null)
  12679. {
  12680. returnErrorMsg("查无数据");
  12681. return;
  12682. }
  12683. ceErpSupplierProductTime.Delete();
  12684. returnSuccessMsg("保存成功");
  12685. return;
  12686. }
  12687. returnErrorMsg("缺少必要的参数");
  12688. }
  12689. public void getExpressInfo()
  12690. {
  12691. string ctid = GetPostString("ctid");
  12692. if (!string.IsNullOrEmpty(ctid))
  12693. {
  12694. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  12695. if (ceErpTradeCell != null)
  12696. {
  12697. string outSid = ceErpTradeCell.OutSid;
  12698. if (outSid.Length > 0)
  12699. {
  12700. string sql = string.Format("SELECT out_sid FROM [dbo].[CE_ErpExpressInfo] WHERE (out_sid in ({0}) or tid = '{1}') and ISNULL(DATALENGTH(postData), 0)>0;", "'" + outSid.Replace(",", "','") + "'", ceErpTradeCell.tid);
  12701. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12702. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  12703. return;
  12704. }
  12705. }
  12706. returnErrorMsg("查无记录");
  12707. return;
  12708. }
  12709. returnErrorMsg("缺少必要的参数");
  12710. }
  12711. public void getExpressPostData()
  12712. {
  12713. string express = GetPostString("express");
  12714. if (!string.IsNullOrEmpty(express))
  12715. {
  12716. CeErpExpressInfo ceErpExpressInfo = CeErpExpressInfo.GetByExpress(express);
  12717. if (ceErpExpressInfo != null)
  12718. {
  12719. ReturnSuccess("{" + string.Format("\"data\":{0}", ceErpExpressInfo.postData) + "}");
  12720. return;
  12721. }
  12722. }
  12723. returnErrorMsg("缺少必要的参数");
  12724. }
  12725. public void checkSupplierOrder()
  12726. {
  12727. string ctids = GetPostString("ctids");
  12728. if (ctids != null)
  12729. {
  12730. List<string> list = new List<string>();
  12731. string sql = string.Format("SELECT ctid,seller_memo,OrderState,IsVerifyToSupplier FROM [dbo].[CE_ErpTradeCell] WHERE ctid in ({0});", "'" + ctids.Replace(",", "','") + "'");
  12732. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12733. for (int i = 0; i < dt.Rows.Count; i++)
  12734. {
  12735. DataRow row = dt.Rows[i];
  12736. if (Convert.ToInt16(row["OrderState"]) == 6 && Convert.ToInt16(row["IsVerifyToSupplier"]) == 1)
  12737. {
  12738. continue;
  12739. }
  12740. list.Add(row["seller_memo"].ToString());
  12741. }
  12742. if (list.Count > 0)
  12743. {
  12744. DbHelper.DbConn.ExecuteNonQuery(string.Format("insert into CE_ErpTradeLog(tid,orderstate,userid,operatetime,con) select ctid,{1},{2},getdate(),'{3}' from ce_erptradecell where ctid in ({0}) ;", "'" + ctids.Replace(",", "','") + "'", (int)OrderState.下单完成, CurrentUser.UserID, "点击下载按钮"));
  12745. ReturnSuccess("{" + string.Format("\"data\":{0}", JsonConvert.SerializeObject(list)) + "}");
  12746. return;
  12747. }
  12748. }
  12749. ReturnSuccess("{" + string.Format("\"data\":{0}", "[]") + "}");
  12750. return;
  12751. }
  12752. public void addPersonId()
  12753. {
  12754. string tid = GetPostString("tid");
  12755. string personId = GetPostString("personId");
  12756. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12757. if (ceErpTrade != null)
  12758. {
  12759. ceErpTrade.receiver_zip = personId;
  12760. ceErpTrade.Update();
  12761. LogHelper.addLog(tid, CurrentUser.UserID, "身份证号:" + personId, 6);
  12762. returnSuccessMsg("保存成功");
  12763. return;
  12764. }
  12765. returnErrorMsg("缺少必要的参数");
  12766. }
  12767. public void addDeliveryPaymant()
  12768. {
  12769. string tid = GetPostString("tid");
  12770. string paymant = GetPostString("paymant");
  12771. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12772. if (ceErpTrade != null)
  12773. {
  12774. if (!string.IsNullOrEmpty(paymant))
  12775. {
  12776. ceErpTrade.delivery_paymant = Convert.ToDouble(paymant);
  12777. }
  12778. ceErpTrade.Update();
  12779. LogHelper.addLog(tid, CurrentUser.UserID, "偏远物流费:" + paymant, 6);
  12780. returnSuccessMsg("保存成功");
  12781. return;
  12782. }
  12783. returnErrorMsg("缺少必要的参数");
  12784. }
  12785. public void saveCellFile()
  12786. {
  12787. string tid = GetPostString("tid");
  12788. string ctid = GetPostString("ctid");
  12789. string urls = GetPostString("urls");
  12790. string type = GetPostString("type");
  12791. string del = GetPostString("del");
  12792. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12793. {
  12794. if ("1".Equals(del))
  12795. {
  12796. CeErpTradeCellFile.delByCtid(tid, ctid, tradeCellFile.ToString());
  12797. }
  12798. string[] list = urls.Split(',');
  12799. if (!string.IsNullOrEmpty(urls) && list.Length > 0)
  12800. {
  12801. foreach (string item in list)
  12802. {
  12803. CeErpTradeCellFile ceErpTradeCellFile = new CeErpTradeCellFile(tid, ctid, item, tradeCellFile.ToString());
  12804. ceErpTradeCellFile.Create();
  12805. LogHelper.addLog(ctid, CurrentUser.UserID, "上传客户文件:" + item, 6);
  12806. }
  12807. }
  12808. returnSuccessMsg("保存成功");
  12809. return;
  12810. }
  12811. returnErrorMsg("缺少必要的参数");
  12812. }
  12813. public void getCellFile()
  12814. {
  12815. string tid = GetPostString("tid");
  12816. string ctid = GetPostString("ctid");
  12817. string type = GetPostString("type");
  12818. if (Enum.TryParse(type, out TradeCellFile tradeCellFile))
  12819. {
  12820. string sql = string.Format("SELECT * FROM [dbo].[CE_ErpTradeCellFile] WHERE isDel=0 and tid='{0}' and ctid='{1}' and type='{2}';", tid, ctid, tradeCellFile);
  12821. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12822. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  12823. return;
  12824. }
  12825. returnErrorMsg("缺少必要的参数");
  12826. }
  12827. public void delCellFile()
  12828. {
  12829. string id = GetPostString("id");
  12830. if (string.IsNullOrEmpty(id))
  12831. {
  12832. returnErrorMsg("缺少必要的参数");
  12833. return;
  12834. }
  12835. CeErpTradeCellFile ceErpTradeCellFile = CeErpTradeCellFile.Get(id);
  12836. CeErpTradeCellFile.delByID(id);
  12837. LogHelper.addLog(ceErpTradeCellFile.ctid, CurrentUser.UserID, "删除客户文件", 6);
  12838. returnSuccessMsg("保存成功");
  12839. }
  12840. public void getInvoiceOrder()
  12841. {
  12842. string tid = GetPostString("tid");
  12843. CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
  12844. List<string> tids = new List<string>();
  12845. if (!string.IsNullOrEmpty(ceErpTrade.buyer_nick) && !string.IsNullOrEmpty(ceErpTrade.buyer_id))
  12846. {
  12847. string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WHERE buyer_id = '{0}' AND seller_nick = '{1}' order by pay_time desc;", ceErpTrade.buyer_id, ceErpTrade.seller_nick);
  12848. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  12849. foreach (DataRow dr in dt.Rows)
  12850. {
  12851. tids.Add("'" + dr["tid"].ToString() + "'");
  12852. }
  12853. }
  12854. else
  12855. {
  12856. tids.Add("'" + ceErpTrade.tid + "'");
  12857. }
  12858. DataTable cell_dt = new DataTable();
  12859. if (tids.Count > 0)
  12860. {
  12861. cell_dt = DbHelper.DbConn.ExecuteDataset(string.Format("SELECT * FROM [dbo].[CE_ErpTradeCell] WHERE tid in ({0});", string.Join(",", tids))).Tables[0];
  12862. }
  12863. ReturnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(cell_dt));
  12864. return;
  12865. }
  12866. }
  12867. }