sync.order.cs 562 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI.WebControls;
  37. using Utils;
  38. using Utils.Serialization;
  39. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  40. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  41. using static SiteCore.taoObj.work_core_vo;
  42. using static System.Net.Mime.MediaTypeNames;
  43. namespace SiteCore.Handler
  44. {
  45. public partial class sync
  46. {
  47. public void get_erp_orderlist()
  48. {
  49. string poscode = CurrentUser.UserPost.Post.Code;
  50. DataStruct dStruct = GetPostStruct();
  51. //apiHelper.Api_SyncOrderByTime("598825");
  52. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  53. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  54. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  55. //banniuApiHelper.sendLogisticsInfo(null);
  56. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  57. //commonHelper.checkOrderListDesignInfo("4042031616863358615");
  58. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2449287014185573080");
  59. //int sid = commonHelper.autoDistributeToSupplier(entity);
  60. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  61. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1738821978000,\"deliveryType\":\"OFFLINE\",\"discountFee\":-34.0,\"flag\":\"NONE\",\"lines\":[{\"mark2\":[],\"num\":9,\"outerId\":\"\",\"payment\":350.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i4/2213077796486/O1CN01Tg7cpd1xmdrqFR8F9_!!2-item_pic.png\",\"platServiceFee\":0.0,\"price\":35.0,\"refOlId\":\"2458934582736842566\",\"refSkuId\":\"0\",\"refSpuId\":\"817084548604\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":38.8889,\"singleFee\":38.89,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"雅柔纸卡片定制logo广告宣传纹理卡纸印刷保养展示饰品卡小卡特种纸名片打印制作包装售后硬卡设计产品养护卡\",\"totalFee\":350.0,\"totalPrice\":315.0,\"totalSellPrice\":350.0},{\"isFreeGift\":true,\"mark2\":[\"GIFT\"],\"num\":1,\"outerId\":\"\",\"payment\":0.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2213077796486/O1CN01Su0uey1xmdtXkF7zu_!!4611686018427381382-0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":1.0,\"refOlId\":\"2458934582737842566\",\"refSkuId\":\"0\",\"refSpuId\":\"856312416459\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":0.0,\"singleFee\":0.0,\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【联系客服领礼金】【售后保障服务】\",\"totalFee\":0.0,\"totalPrice\":1.0,\"totalSellPrice\":0.0}],\"logisticsOrderNo\":\"\",\"mark2\":[\"GIFT\"],\"modifyTime\":1738821982000,\"openBuyerId\":\"AAEpRHraABkUZRPgSx2LbmHS\",\"openBuyerNick\":\"如**\",\"openSellerNick\":\"领淘文具旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1738821813000,\"payTime\":1738821976000,\"payment\":350.0,\"platServiceFee\":0.0,\"posCode\":\"lingtao\",\"posId\":600090,\"postFee\":0.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"石家庄市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"裕华区\",\"receiverId\":\"a908c5702ff4d1d42009017efc49d0dc$\",\"receiverState\":\"河北省\",\"receiverTown\":\"建通街道\",\"refOid\":\"2458934582735842566\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"90x130mm-200张-卡片-300克铜版纸-双面印刷不覆膜裁切-如何怎样你奈-丹儿-170,90x90mm-200张-卡片-80克硫酸纸-不覆膜单色裁切-如何怎样你奈-丹儿-180\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":350.0,\"totalPrice\":316.0,\"totalSellPrice\":350.0,\"type\":\"SALE\"}}");
  62. //refundTmcHelper.Api_TmcRefundMsg("{\"content\":{\"afterStatus\":\"SUCCESS\",\"createTime\":1735287446000,\"desc\":\"\",\"interceptInvestor\":\"NONE\",\"interceptStatus\":\"NONE\",\"interceptType\":\"NONE\",\"lines\":[{\"num\":2,\"outerId\":\"\",\"price\":50.0,\"refAid\":\"313001208133750610\",\"refAlId\":\"313001208133750610\",\"refBoughtSkuId\":\"\",\"refOid\":\"4181722704291751006\",\"refOlId\":\"4181722704291751006\",\"refSkuId\":\"0\",\"refSpuId\":\"865893808768\",\"refundFee\":98.86,\"refundStatus\":\"SUCCESS\",\"title\":\"新年会抽奖券定制2025蛇年公司活动正副可撕代金券打印纪念票根奖品兑换尾牙晚宴邀请卡号码牌创意入场券设计\",\"totalFee\":98.86,\"type\":1}],\"logisticsCompany\":\"\",\"logisticsOrderNo\":\"\",\"mark2\":[],\"openBuyerNick\":\"0**\",\"openSellerNick\":\"万慕办公旗舰店\",\"posCode\":\"wanmu\",\"posId\":598798,\"reason\":\"订单信息拍错(规格/尺码/颜色等)\",\"receiverCity\":\"\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"\",\"receiverId\":\"\",\"receiverState\":\"\",\"receiverTown\":\"\",\"receiverZip\":\"\",\"refAid\":\"313001208133750610\",\"refOid\":\"4181722704291751006\",\"refPlatform\":\"TB\",\"refType\":\"TMALL\",\"refundCreateTime\":1735287358000,\"refundFee\":\"98.86\",\"refundPhase\":\"ON_SALE\",\"refundTime\":1735289443000,\"refundUpdateTime\":1735289443000,\"refundVersion\":1735287358100,\"senderAddress\":\"\",\"senderCity\":\"\",\"senderCountry\":\"中国\",\"senderDistrict\":\"\",\"senderMobile\":\"\",\"senderName\":\"\",\"senderPhone\":\"\",\"senderState\":\"\",\"senderTown\":\"\",\"senderZip\":\"\",\"status\":\"SUCCESS\",\"statusCode\":\"SUCCESS\",\"statusName\":\"退款成功\",\"totalFee\":\"98.86\",\"type\":\"REFUND\",\"updateTime\":1735289479000}}");
  63. List<string> lw = new List<string>();
  64. string tid = GetPostString("ctid");
  65. string date1 = GetPostString("date1");
  66. //12-1 修改
  67. string urgent = GetPostString("urgent");
  68. string back = GetPostString("back");
  69. string offlineSearch = GetPostString("offlineSearch");
  70. int paramsCount = 0;
  71. if (!string.IsNullOrWhiteSpace(urgent))
  72. {
  73. if (urgent.Equals("true"))
  74. {
  75. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  76. }
  77. }
  78. if (!string.IsNullOrWhiteSpace(back))
  79. {
  80. if (back.Equals("true"))
  81. {
  82. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  83. }
  84. }
  85. if (!string.IsNullOrWhiteSpace(offlineSearch))
  86. {
  87. if (offlineSearch.Equals("true"))
  88. {
  89. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  90. }
  91. }
  92. //end
  93. string date2 = GetPostString("date2");
  94. string buyernick = GetPostString("buyer_nick");
  95. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  96. {
  97. if (tid.Length <= 0 && buyernick.Length <= 0)
  98. {
  99. return;
  100. }
  101. }
  102. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  103. {
  104. if (tid.Length > 0)
  105. {
  106. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or OrderSn='{0}')", tid));
  107. }
  108. if (buyernick.Length > 0)
  109. {
  110. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  111. }
  112. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  113. if (dw.Length > 0)
  114. {
  115. lw.Add(dw);
  116. }
  117. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  118. {
  119. string usershop = CurrentUser.User.pemShop;
  120. lw.Add(string.Format("ShopId in ({0})", usershop));
  121. }
  122. }
  123. else
  124. {
  125. if (ex_psize == 0)
  126. {
  127. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  128. }
  129. if (PKey != "admin")
  130. {
  131. string usershop = CurrentUser.User.pemShop;
  132. lw.Add(string.Format("ShopId in ({0})", usershop));
  133. paramsCount++;
  134. }
  135. }
  136. string uploaddate1 = GetPostString("uploaddate1");
  137. string uploaddate2 = GetPostString("uploaddate2");
  138. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  139. if (update.Length > 0) lw.Add(update);
  140. string shopname = GetPostString("shopname");
  141. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  142. string addwechat = GetPostString("addwechat");
  143. if (addwechat.Length > 0)
  144. {
  145. int addWt = Convert.ToInt32(addwechat);
  146. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  147. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  148. }
  149. string customer = GetPostString("customer");
  150. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  151. string design = GetPostString("design");
  152. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  153. string orderState = GetPostString("orderState");
  154. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  155. string address = GetPostString("address");
  156. 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));
  157. string sellermemo = GetPostString("seller_memo");
  158. if (sellermemo.Length > 0)
  159. {
  160. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  161. }
  162. string backReason = GetPostString("backReason");
  163. if (backReason.Length > 0)
  164. {
  165. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  166. }
  167. string apdate1 = GetPostString("apdate1");
  168. string apdate2 = GetPostString("apdate2");
  169. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  170. if (dwap.Length > 0) lw.Add(dwap);
  171. string price1 = GetPostString("price1");
  172. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  173. string price2 = GetPostString("price2");
  174. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  175. string isoldcustomer = GetPostString("isoldcus");
  176. string finishdate1 = GetPostString("finishdate1");
  177. string finishdate2 = GetPostString("finishdate2");
  178. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  179. bool isFinish = false;
  180. if (finishdate.Length > 0)
  181. {
  182. lw.Add(finishdate);
  183. isFinish = true;
  184. paramsCount++;
  185. }
  186. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  187. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  188. if (ex_psize > 0)
  189. {
  190. int UserID = CurrentUser.UserID;
  191. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  192. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  193. {
  194. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  195. }
  196. dStruct.Order = "pay_time desc";
  197. }
  198. string isNew = GetPostString("isNew");
  199. if (isNew == "true")
  200. {
  201. lw.Add(string.Format("IsNew = {0}", 1));
  202. }
  203. string overtime = GetPostString("overtime");
  204. if (overtime == "1")
  205. {
  206. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  207. }
  208. String usePost = CurrentUser.UserPost.Post.Code;
  209. if (usePost.Equals("Operation") == true)
  210. {
  211. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  212. }
  213. else
  214. {
  215. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  216. }
  217. //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";
  218. if (dStruct.PageSize == 100000)
  219. {
  220. dStruct.Order = "";
  221. }
  222. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  223. DataTable dt = null;
  224. string tablename = "view_orderlist";
  225. if (isFinish)
  226. {
  227. tablename = "view_orderlist_end";
  228. }
  229. dt = WebCache.GetData(tablename, dStruct);
  230. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  231. if (dt != null && dt.Rows.Count > 0)
  232. {
  233. foreach (DataRow dr in dt.Rows)
  234. {
  235. try
  236. {
  237. if (dr["refund_fees"] != null)
  238. {
  239. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  240. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  241. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  242. if (payment == refund_fees)
  243. {
  244. dr["refund_fees"] = Math.Round(refund_fees, 2);
  245. continue; // 跳过当前迭代
  246. }
  247. else if (refund_fees == total_fee)
  248. {
  249. dr["refund_fees"] = payment;
  250. continue; // 跳过当前迭代
  251. }
  252. else
  253. {
  254. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  255. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  256. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  257. }
  258. }
  259. // 对象操作
  260. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  261. ceErpTradeCell.ctid = dr["ctid"].ToString();
  262. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  263. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  264. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  265. if (dStruct.PageSize != 100000)
  266. {
  267. if (dr["DispatchSort"].ToString() == "2")
  268. {
  269. dr["gongchuang"] = 200;
  270. }
  271. else
  272. {
  273. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  274. dr["gongchuang"] = response.code;
  275. }
  276. }
  277. }
  278. catch (NullReferenceException ex)
  279. {
  280. // 处理空引用异常
  281. dr["refund_fees"] = "0.00";
  282. }
  283. }
  284. }
  285. writeGridDataTableJson(dStruct.TotalCount, dt);
  286. }
  287. public void get_erp_orderlist_sumprice()
  288. {
  289. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  290. return;
  291. List<string> lw = new List<string>();
  292. string tid = GetPostString("ctid");
  293. string date1 = GetPostString("date1");
  294. string date2 = GetPostString("date2");
  295. if (tid.Length > 0 || date1.Length > 0)
  296. {
  297. lw.Add(string.Format("ctid like '%{0}%'", tid));
  298. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  299. if (dw.Length > 0) lw.Add(dw);
  300. }
  301. else
  302. {
  303. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  304. }
  305. string shopname = GetPostString("shopname");
  306. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  307. string buyernick = GetPostString("buyer_nick");
  308. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  309. string customer = GetPostString("customer");
  310. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  311. string design = GetPostString("design");
  312. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  313. string orderState = GetPostString("orderState");
  314. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  315. string address = GetPostString("address");
  316. 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));
  317. string sellermemo = GetPostString("seller_memo");
  318. if (sellermemo.Length > 0)
  319. {
  320. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  321. }
  322. string apdate1 = GetPostString("apdate1");
  323. string apdate2 = GetPostString("apdate2");
  324. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  325. if (dwap.Length > 0) lw.Add(dwap);
  326. string price1 = GetPostString("price1");
  327. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  328. string price2 = GetPostString("price2");
  329. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  330. string isoldcustomer = GetPostString("isoldcus");
  331. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  332. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  333. if (PKey != "admin")
  334. {
  335. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  336. lw.Add(string.Format("shopId in ({0})", usershop));
  337. }
  338. //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";
  339. string mainWhere = string.Join(" and ", lw.ToArray());
  340. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  341. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  342. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  343. decimal total = 0;
  344. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  345. {
  346. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  347. }
  348. var res = new
  349. {
  350. data = total
  351. };
  352. string ro_jsond = JsonConvert.SerializeObject(res);
  353. returnSuccess(ro_jsond);
  354. return;
  355. }
  356. public void get_erp_CustomerServiceGather()
  357. {
  358. string userWhere = "", orderWhere = "";
  359. List<string> lw = new List<string>();
  360. string customer = GetPostString("customer");
  361. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  362. string shopname = GetPostString("shopname");
  363. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  364. string date1 = GetPostString("date1");
  365. string date2 = GetPostString("date2");
  366. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  367. if (dw.Length > 0) lw.Add(dw);
  368. orderWhere = string.Join(" and ", lw.ToArray());
  369. 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 " +
  370. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  371. "left join " +
  372. "( " +
  373. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  374. ") as b on a.ID = b.CustomerUserId " +
  375. "left join " +
  376. "( " +
  377. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  378. ") as d on a.ID = d.CustomerUserId " +
  379. "left join " +
  380. "( " +
  381. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  382. ") as e on a.ID = e.CustomerUserId " +
  383. "left join " +
  384. "( " +
  385. " select CustomerUserId, RefundCount, RefundSum from " +
  386. " ( " +
  387. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  388. " from CE_ErpTradeRefund a " +
  389. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  390. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  391. " group by CustomerUserId " +
  392. " ) as a " +
  393. ") as f on a.ID = f.CustomerUserId " +
  394. "where a.PostCode = 'CustomerService'",
  395. userWhere, orderWhere);
  396. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  397. writeGridDataTableJson(dt.Rows.Count, dt);
  398. //writeGridDataTableJson(dt.Rows.Count, dt);
  399. }
  400. //设计汇总
  401. public void get_erp_DesignerGather()
  402. {
  403. string userWhere = "", orderWhere = "";
  404. List<string> lw = new List<string>();
  405. string Designer = GetPostString("designer");
  406. int org = GetPostInt("org");
  407. if (Designer.Length > 0)
  408. {
  409. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  410. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  411. }
  412. else if (org > 0)
  413. {
  414. userWhere = string.Format(" where OrgID ={0}", org);
  415. }
  416. string shopname = GetPostString("shopname");
  417. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  418. string state = GetPostString("state");
  419. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  420. string OrderArea = GetPostString("order_area");
  421. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  422. string date1 = GetPostString("date1");
  423. string date2 = GetPostString("date2");
  424. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  425. if (dw.Length > 0) lw.Add(dw);
  426. string UpDate1 = GetPostString("UpDate1");
  427. string UpDate2 = GetPostString("UpDate2");
  428. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  429. if (dw.Length > 0) lw.Add(dw);
  430. orderWhere = string.Join(" and ", lw.ToArray());
  431. 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 (" +
  432. "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 " +
  433. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  434. "left join " +
  435. "( " +
  436. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  437. ") as b on a.ID = b.DesignUserId " +
  438. "left join " +
  439. "( " +
  440. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  441. ") as d on a.ID = d.DesignUserId " +
  442. "left join " +
  443. "( " +
  444. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  445. ") as e on a.ID = e.DesignUserId " +
  446. "left join " +
  447. "( " +
  448. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  449. ") as g on a.ID = g.DesignUserId " +
  450. "left join " +
  451. "( " +
  452. " select CustomerUserId, RefundCount, RefundSum from " +
  453. " ( " +
  454. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  455. " from CE_ErpTradeRefund a " +
  456. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  457. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  458. " group by CustomerUserId " +
  459. " ) as a " +
  460. ") as f on a.ID = f.CustomerUserId " +
  461. "where a.PostCode = 'Designer') as z",
  462. userWhere, orderWhere);
  463. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  464. writeGridDataTableJson(dt.Rows.Count, dt);
  465. }
  466. //删除tradecell的订单
  467. public void del_erp_cellorder()
  468. {
  469. if (UrlPostParmsCheck("ctid"))
  470. {
  471. string eid = GetPostString("ctid");
  472. CeErpTradeCell.DelByCtid(eid);
  473. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  474. returnSuccessMsg("删除成功");
  475. }
  476. }
  477. public void clear_erp_refundstate()
  478. {
  479. if (UrlPostParmsCheck("ids"))
  480. {
  481. string eids = GetPostString("ids");
  482. string[] ctidList = eids.Split(',');
  483. foreach (string ctid in ctidList)
  484. {
  485. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  486. if (entity != null)
  487. {
  488. entity.IsRefund = 0;
  489. entity.Update();
  490. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  491. }
  492. else
  493. continue;
  494. }
  495. returnSuccessMsg("操作成功");
  496. return;
  497. }
  498. returnErrorMsg("缺少必要参数");
  499. }
  500. public void set_erp_urgency()
  501. {
  502. if (UrlPostParmsCheck("ctid"))
  503. {
  504. string eid = GetPostString("ctid");
  505. CeErpTradeCell entity = null;
  506. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  507. if (entity != null)
  508. {
  509. string utime = GetPostString("urgencytime");
  510. if (utime.Length > 0)
  511. {
  512. entity.UrgencyTime = Convert.ToDateTime(utime);
  513. }
  514. else
  515. {
  516. returnErrorMsg("请选择加急时间");
  517. return;
  518. }
  519. if (entity.OrderState <= 4)
  520. {
  521. //entity.seller_memo = entity.seller_memo + "-加急";
  522. string smemo = entity.seller_memo;
  523. int kindex = smemo.IndexOf(")");
  524. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  525. if (lastoneStr != "-")
  526. {
  527. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  528. }
  529. string prememo = smemo.Substring(0, kindex + 2);
  530. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  531. int lastkindex = lastmemo.IndexOf("(");
  532. DateTime urgtime = Convert.ToDateTime(utime);
  533. string newlastmemo = "";
  534. if (lastkindex == 0)
  535. {
  536. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  537. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  538. }
  539. else
  540. {
  541. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  542. }
  543. entity.seller_memo = prememo + newlastmemo;
  544. }
  545. entity.IsUrgency = true;
  546. entity.Update();
  547. ApiVo apiVo = new ApiVo();
  548. apiVo.orderNumber = entity.ctid;
  549. apiVo.actionName = "changeDesign";
  550. apiVo.orderRemarks = entity.seller_memo;
  551. apiVo.remarkSign = 3;
  552. designHelper.API_WorkCore(apiVo); //changeDesign
  553. CeErpSukuraData.createInfo(entity.ctid, 7);
  554. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  555. returnSuccessMsg("设置成功!");
  556. return;
  557. }
  558. returnErrorMsg("找不到记录");
  559. }
  560. }
  561. public void set_erp_reset()
  562. {
  563. if (UrlPostParmsCheck("ctid"))
  564. {
  565. string eid = GetPostString("ctid");
  566. CeErpTradeCell entity = null;
  567. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  568. if (entity != null)
  569. {
  570. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  571. {
  572. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  573. {
  574. returnErrorMsg("财务要求已下单已发货无法重置");
  575. return;
  576. }
  577. }
  578. entity.IsUrgency = false;
  579. entity.seller_memo = "";
  580. entity.OtherMemo = "";
  581. entity.OrderState = 0;
  582. entity.IsReturn = 0;
  583. //entity.IsRefund = 0;
  584. entity.MemoOpt = 0;
  585. entity.AfterSaleState = 0;
  586. entity.AfterSaleResponsible = "";
  587. entity.AfterSaleUserId = 0;
  588. entity.IsNeedBill = 0;
  589. entity.CustomerUserId = 0;
  590. entity.DesignUserId = 0;
  591. entity.SupplierId = 0;
  592. entity.PlaceUserId = 0;
  593. entity.ptid = "";
  594. entity.IsSample = 0;
  595. entity.IsXianHuo = 0;
  596. entity.isDianziOrder = 0;
  597. entity.FinishPlaceTime = null;
  598. entity.Update();
  599. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  600. if (trade != null)
  601. {
  602. trade.seller_memo = "";
  603. trade.Update();
  604. }
  605. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  606. returnSuccessMsg("重置成功!");
  607. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  608. if (desginBill != null)
  609. {
  610. desginBill.isDel = 1;
  611. desginBill.Update();
  612. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  613. }
  614. ApiVo apiVo = new ApiVo();
  615. apiVo.orderNumber = entity.ctid;
  616. apiVo.actionName = "resetDesign";
  617. designHelper.API_WorkCore(apiVo);//resetDesign
  618. return;
  619. }
  620. returnErrorMsg("找不到记录");
  621. }
  622. }
  623. public void save_erp_sellermemo()
  624. {
  625. if (UrlPostParmsCheck("ctid"))
  626. {
  627. string ctid = GetPostString("ctid");
  628. CeErpTradeCell entity = null;
  629. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  630. if (entity != null)
  631. {
  632. string memo = GetPostString("seller_memo");
  633. memo = memo.Replace(" ", "");
  634. if (memo.Contains("补差"))
  635. {
  636. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  637. return;
  638. }
  639. if (entity.seller_memo != memo)
  640. {
  641. if (entity.IsSample == 2)
  642. {
  643. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  644. return;
  645. }
  646. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  647. {
  648. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  649. {
  650. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  651. return;
  652. }
  653. }
  654. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  655. }
  656. commonHelper.getCytPrice(entity);
  657. int memoopt = GetPostInt("MemoOpt");
  658. Boolean ismemoopt = false;
  659. if (memoopt > 0)
  660. {
  661. string stropt = "";
  662. if (memoopt == 1)
  663. {
  664. stropt = "“改稿”";
  665. ismemoopt = true;
  666. }
  667. else if (memoopt == 2)
  668. {
  669. stropt = "“定稿”";
  670. }
  671. else if (memoopt == 3)
  672. {
  673. stropt = "“查货”";
  674. CeErpSukuraData.createInfo(entity.ctid, 6);
  675. }
  676. entity.MemoOpt = Convert.ToInt32(memoopt);
  677. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  678. }
  679. if (entity.OrderState < 5)
  680. {
  681. memo = memo.Replace("(", "(");
  682. memo = memo.Replace(")", ")");
  683. }
  684. entity.seller_memo = memo;
  685. entity.Update();
  686. ApiVo apiVo = new ApiVo();
  687. apiVo.orderNumber = entity.ctid;
  688. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  689. apiVo.orderRemarks = memo;
  690. apiVo.remarkSign = memoopt;
  691. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  692. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  693. returnSuccessMsg("保存成功!");
  694. return;
  695. }
  696. returnErrorMsg("找不到记录");
  697. }
  698. }
  699. public void ins_erp_checkorder()
  700. {
  701. if (UrlPostParmsCheck("ctid"))
  702. {
  703. string ctid = GetPostString("ctid");
  704. CeErpTradeCell entity = null;
  705. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  706. if (entity != null)
  707. {
  708. if (entity.OrderState < 6)
  709. {
  710. returnErrorMsg("下单完成后才可查货");
  711. return;
  712. }
  713. /*if (entity.OrderState > 6)
  714. {
  715. returnErrorMsg("订单已发货");
  716. return;
  717. }*/
  718. if (entity.FinishPlaceTime != null)
  719. {
  720. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  721. {
  722. returnErrorMsg("下单时间不足,无法查货");
  723. return;
  724. }
  725. }
  726. entity.MemoOpt = 3;
  727. entity.CheckOrderTime = DateTime.Now;
  728. entity.Update();
  729. CeErpSukuraData.createInfo(entity.ctid, 6);
  730. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  731. returnSuccessMsg("操作成功!");
  732. return;
  733. }
  734. returnErrorMsg("找不到记录");
  735. }
  736. }
  737. public void save_erp_othermemo()
  738. {
  739. if (UrlPostParmsCheck("ctid"))
  740. {
  741. string ctid = GetPostString("ctid");
  742. CeErpTradeCell entity = null;
  743. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  744. if (entity != null)
  745. {
  746. entity.OtherMemo = GetPostString("otherMemo");
  747. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  748. {
  749. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  750. StringBuilder sql = new StringBuilder();
  751. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  752. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  753. if (dt != null && dt.Rows.Count > 0)
  754. {
  755. foreach (DataRow dr in dt.Rows)
  756. {
  757. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  758. {
  759. //品类一直
  760. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  761. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  762. if (ceErpSampleCustomer == null)
  763. {
  764. ceErpSampleCustomer = new CeErpSampleCustomer();
  765. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  766. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  767. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  768. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  769. ceErpSampleCustomer.shopId = entity.ShopId;
  770. }
  771. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  772. ceErpSampleCustomer.lastTid = entity.tid;
  773. if (ceErpSampleCustomer.ID > 0)
  774. {
  775. ceErpSampleCustomer.Update();
  776. }
  777. else
  778. {
  779. ceErpSampleCustomer.Create();
  780. }
  781. }
  782. }
  783. }
  784. }
  785. //if (entity.IsOldCustomer == 1)
  786. //{
  787. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  788. //{
  789. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  790. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  791. //}
  792. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  793. //{
  794. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  795. // {
  796. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  797. // {
  798. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  799. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  800. // }
  801. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  802. // {
  803. // entity.OrderState = 2;
  804. // entity.DesignUserId = 0;
  805. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  806. // }
  807. // else
  808. // {
  809. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  810. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  811. // }
  812. // }
  813. //}
  814. //}
  815. entity.Update();
  816. returnSuccessMsg("保存成功!");
  817. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  818. return;
  819. }
  820. returnErrorMsg("找不到记录");
  821. }
  822. }
  823. public void save_erp_customermemo()
  824. {
  825. if (UrlPostParmsCheck("ctid"))
  826. {
  827. string ctid = GetPostString("ctid");
  828. CeErpTradeCell entity = null;
  829. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  830. if (entity != null)
  831. {
  832. entity.CustomerMemo = GetPostString("CustomerMemo");
  833. entity.Update();
  834. ApiVo apiVo = new ApiVo();
  835. apiVo.orderNumber = entity.ctid;
  836. apiVo.actionName = "followRemarks";
  837. apiVo.orderRemarks = entity.CustomerMemo;
  838. designHelper.API_WorkCore(apiVo);//followRemarks
  839. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  840. returnSuccessMsg("保存成功!");
  841. return;
  842. }
  843. returnErrorMsg("找不到记录");
  844. }
  845. }
  846. public void upd_erp_addmemotag()
  847. {
  848. if (UrlPostParmsCheck("ctid"))
  849. {
  850. ;
  851. string eid = GetPostString("ctid");
  852. string sfTagstr = GetPostString("memotag");
  853. CeErpTradeCell entity = null;
  854. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  855. if (entity != null)
  856. {
  857. if (entity.OrderState == 0)
  858. {
  859. returnErrorMsg("请先领单");
  860. return;
  861. }
  862. //撤销顺丰
  863. if (sfTagstr == "撤销顺丰")
  864. {
  865. entity.IsSF = 0;
  866. string reMsg = "";
  867. string oldmemo = entity.seller_memo;
  868. if (entity.OrderState < 5)
  869. {
  870. oldmemo = oldmemo.Replace("顺丰到付", "");
  871. oldmemo = oldmemo.Replace("顺丰寄付", "");
  872. entity.seller_memo = oldmemo;
  873. }
  874. else
  875. {
  876. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  877. {
  878. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  879. }
  880. }
  881. entity.Update();
  882. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  883. api.orderNumber = entity.ctid;
  884. api.actionName = "followRemarks";
  885. api.orderRemarks = entity.seller_memo;
  886. api.isSf = entity.IsSF.ToString();
  887. designHelper.API_WorkCore(api);//followRemarks
  888. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  889. returnSuccessMsg("撤销成功!" + reMsg);
  890. return;
  891. }
  892. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  893. {
  894. //string oldmemo = entity.seller_memo;
  895. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  896. string sfStr = GetPostString("memotag");
  897. string smemo = entity.seller_memo;
  898. int kindex = smemo.IndexOf(")");
  899. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  900. if (lastoneStr != "-")
  901. {
  902. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  903. }
  904. string prememo = smemo.Substring(0, kindex + 2);
  905. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  906. int lastkindex = lastmemo.IndexOf("(");
  907. string newlastmemo = "";
  908. if (lastkindex == 0)
  909. {
  910. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  911. newlastmemo = "(" + sfStr + "." + useLastmemo;
  912. }
  913. else
  914. {
  915. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  916. }
  917. entity.seller_memo = prememo + newlastmemo;
  918. }
  919. string sfTagMSg = "";
  920. if (sfTagstr == "顺丰寄付")
  921. {
  922. entity.IsSF = 1;
  923. sfTagMSg = "顺丰寄付";
  924. }
  925. else if (sfTagstr == "顺丰到付")
  926. {
  927. entity.IsSF = 2;
  928. sfTagMSg = "顺丰到付";
  929. }
  930. entity.Update();
  931. ApiVo apiVo = new ApiVo();
  932. apiVo.orderNumber = entity.ctid;
  933. apiVo.actionName = "orderRemarks";
  934. apiVo.orderRemarks = entity.seller_memo;
  935. apiVo.isSf = entity.IsSF.ToString();
  936. designHelper.API_WorkCore(apiVo);//orderRemarks
  937. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  938. returnSuccessMsg("标记成功!");
  939. return;
  940. }
  941. returnErrorMsg("找不到记录");
  942. }
  943. }
  944. public void upd_erp_ordertag()
  945. {
  946. if (UrlPostParmsCheck("ctid"))
  947. {
  948. string eid = GetPostString("ctid");
  949. CeErpTradeCell entity = null;
  950. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  951. if (entity != null)
  952. {
  953. int tag = GetPostInt("wechattag");
  954. //if(tag==4 && entity.IsSample == 2)
  955. //{
  956. // returnErrorMsg("补差价单不能标记微信单");
  957. // return;
  958. //}
  959. entity.wechatTag = tag;
  960. entity.Update();
  961. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  962. if (tag == 1)
  963. {
  964. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  965. if (cash == null)
  966. {
  967. CeErpTrade main = CeErpTrade.Get(entity.tid);
  968. cash = new CeErpReturnCash();
  969. cash.tid = entity.tid;
  970. cash.seller_nick = main.seller_nick;
  971. cash.payment = trade.payment;
  972. cash.buyer_nick = main.buyer_nick;
  973. cash.cashstate = 0;
  974. cash.rtype = "微信返现";
  975. cash.returnprice = 0;
  976. cash.created = DateTime.Now;
  977. cash.con = "订单标记微信单";
  978. cash.img = "";
  979. cash.applyuserid = CurrentUser.UserID;
  980. cash.Create();
  981. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  982. }
  983. else
  984. {
  985. cash.cashstate = 0;
  986. cash.Update();
  987. }
  988. CeErpSukuraData.createInfo(entity.ctid, 9);
  989. }
  990. else if (tag == 2)
  991. {
  992. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  993. if (cash == null)
  994. {
  995. CeErpTrade main = CeErpTrade.Get(entity.tid);
  996. cash = new CeErpReturnCash();
  997. cash.tid = entity.tid;
  998. cash.seller_nick = main.seller_nick;
  999. cash.payment = trade.payment;
  1000. cash.buyer_nick = main.buyer_nick;
  1001. cash.cashstate = 0;
  1002. cash.rtype = "推购返现";
  1003. cash.returnprice = 5;
  1004. cash.created = DateTime.Now;
  1005. cash.con = "订单标记推购单";
  1006. cash.img = "";
  1007. cash.applyuserid = CurrentUser.UserID;
  1008. cash.Create();
  1009. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1010. }
  1011. else
  1012. {
  1013. cash.cashstate = 0;
  1014. cash.Update();
  1015. }
  1016. CeErpSukuraData.createInfo(entity.ctid, 9);
  1017. }
  1018. else if (tag == 3)
  1019. {
  1020. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1021. if (pers == null)
  1022. {
  1023. pers = new CeErpPersuade();
  1024. pers.ctid = entity.ctid;
  1025. pers.pstate = 0;
  1026. pers.created = DateTime.Now;
  1027. pers.applyuserid = CurrentUser.UserID;
  1028. pers.Create();
  1029. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1030. }
  1031. else
  1032. {
  1033. pers.pstate = 0;
  1034. pers.Update();
  1035. }
  1036. }
  1037. else if (tag == 4 || tag == 5)
  1038. {
  1039. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1040. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1041. if (pers == null)
  1042. {
  1043. pers = new CeErpStayGoods();
  1044. pers.t_id = entity.tid;
  1045. pers.status = "待审核";
  1046. pers.audit_type = 0;
  1047. if (tag == 4)
  1048. {
  1049. pers.stay_type = "微信推购";
  1050. }
  1051. else
  1052. {
  1053. pers.stay_type = "旺旺推购";
  1054. }
  1055. if (entity.IsXianHuo == 0)
  1056. {
  1057. pers.product_id = entity.ProductId;
  1058. }
  1059. pers.wangwang = main.buyer_nick;
  1060. pers.shop_name = main.seller_nick;
  1061. pers.creata_time = DateTime.Now;
  1062. pers.create_u_id = CurrentUser.UserID;
  1063. pers.create_u_name = CurrentUser.UserName;
  1064. pers.Create();
  1065. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1066. }
  1067. else
  1068. {
  1069. pers.audit_type = 0;
  1070. pers.Update();
  1071. }
  1072. CeErpSukuraData.createInfo(entity.ctid, 10);
  1073. }
  1074. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1075. returnSuccessMsg("标记成功!");
  1076. return;
  1077. }
  1078. returnErrorMsg("找不到记录");
  1079. }
  1080. }
  1081. public void upd_erp_ordertag_cancel()
  1082. {
  1083. if (UrlPostParmsCheck("ctid"))
  1084. {
  1085. string eid = GetPostString("ctid");
  1086. CeErpTradeCell entity = null;
  1087. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1088. if (entity != null)
  1089. {
  1090. entity.wechatTag = 0;
  1091. entity.Update();
  1092. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1093. if (pers != null)
  1094. {
  1095. pers.status = "取消推购";
  1096. pers.audit_type = 3;
  1097. pers.Update();
  1098. }
  1099. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1100. returnSuccessMsg("标记成功!");
  1101. return;
  1102. }
  1103. returnErrorMsg("找不到记录");
  1104. }
  1105. }
  1106. public void upd_erp_addweichattag()
  1107. {
  1108. if (UrlPostParmsCheck("ctid"))
  1109. {
  1110. ;
  1111. string eid = GetPostString("ctid");
  1112. CeErpTradeCell entity = null;
  1113. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1114. if (entity != null)
  1115. {
  1116. if (entity.IsAddWechat > 0)
  1117. {
  1118. returnErrorMsg("此单已经标记过了");
  1119. return;
  1120. }
  1121. 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);
  1122. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1123. if (dt.Rows.Count > 0)
  1124. {
  1125. entity.IsAddWechat = 2;
  1126. }
  1127. else
  1128. {
  1129. entity.IsAddWechat = 1;
  1130. }
  1131. entity.Update();
  1132. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1133. returnSuccessMsg("标记成功!");
  1134. return;
  1135. }
  1136. returnErrorMsg("找不到记录");
  1137. }
  1138. }
  1139. public void upd_erp_getmyorder()
  1140. {
  1141. if (UrlPostParmsCheck("ctid"))
  1142. {
  1143. ;
  1144. string eid = GetPostString("ctid");
  1145. CeErpTradeCell entity = null;
  1146. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1147. if (entity != null)
  1148. {
  1149. if (entity.ctid.IndexOf("C") != -1)
  1150. {
  1151. StringBuilder sql = new StringBuilder();
  1152. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1153. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1154. if (dt.Rows.Count > 0)
  1155. {
  1156. decimal total = 0;
  1157. foreach (DataRow dr in dt.Rows)
  1158. {
  1159. total += Convert.ToDecimal(dr["payment"]);
  1160. }
  1161. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1162. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1163. {
  1164. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1165. return;
  1166. }
  1167. }
  1168. }
  1169. entity.CustomerUserId = CurrentUser.UserID;
  1170. if (entity.OrderState < 2)
  1171. {
  1172. entity.OrderState = 2;
  1173. if (entity.ShopId != 0)
  1174. {
  1175. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1176. }
  1177. }
  1178. entity.Update();
  1179. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1180. returnSuccessMsg("领单成功!");
  1181. return;
  1182. }
  1183. returnErrorMsg("找不到记录");
  1184. }
  1185. }
  1186. public void getmyorder_from_init()
  1187. {
  1188. if (UrlPostParmsCheck("ctid"))
  1189. {
  1190. string eid = GetPostString("ctid");
  1191. CeErpTradeCell entity = null;
  1192. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1193. if (entity != null)
  1194. {
  1195. string sellerMemo = GetPostString("sellerMemo");
  1196. if (sellerMemo.Length > 0)
  1197. {
  1198. entity.seller_memo = sellerMemo;
  1199. }
  1200. string oterhMemo = GetPostString("otherMemo");
  1201. if (oterhMemo.Length > 0)
  1202. {
  1203. entity.OtherMemo = oterhMemo;
  1204. }
  1205. int urg = GetPostInt("urgency");
  1206. entity.IsUrgency = (urg == 1 ? true : false);
  1207. int wechat = GetPostInt("wechat");
  1208. int command = GetPostInt("command");
  1209. if (wechat == 1)
  1210. {
  1211. entity.wechatTag = 1;
  1212. }
  1213. if (command == 1)
  1214. {
  1215. entity.wechatTag = 2;
  1216. }
  1217. string pPro = GetPostString("pprofession");
  1218. if (pPro.Length > 0)
  1219. {
  1220. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1221. string spro = GetPostString("profession");
  1222. if (spro.Length > 0)
  1223. {
  1224. entity.ProfessionId = Convert.ToInt32(spro);
  1225. }
  1226. }
  1227. string proId = GetPostString("productId");
  1228. if (proId.Length > 0)
  1229. {
  1230. entity.ProductId = Convert.ToInt32(proId);
  1231. }
  1232. entity.Material = GetPostString("material");
  1233. entity.Craft = GetPostString("craft");
  1234. entity.CustomerUserId = CurrentUser.UserID;
  1235. if (entity.OrderState < 2)
  1236. {
  1237. entity.OrderState = 2;
  1238. if (entity.ShopId != 0)
  1239. {
  1240. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1241. }
  1242. }
  1243. entity.Update();
  1244. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1245. returnSuccessMsg("领单成功!");
  1246. return;
  1247. }
  1248. returnErrorMsg("找不到记录");
  1249. }
  1250. }
  1251. public void upd_erp_setrelationorder()
  1252. {
  1253. if (UrlPostParmsCheck("ctid"))
  1254. {
  1255. ;
  1256. string eid = GetPostString("ctid");
  1257. string ftid = GetPostString("ftid");
  1258. CeErpTradeCell entity = null;
  1259. CeErpTradeCell fentity = null;
  1260. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1261. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1262. if (fentity == null)
  1263. {
  1264. returnErrorMsg("找不到关联的主订单");
  1265. return;
  1266. }
  1267. if (entity != null)
  1268. {
  1269. if (entity.OrderState >= 5)
  1270. {
  1271. returnErrorMsg("本单已经设计完成无法关联");
  1272. return;
  1273. }
  1274. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1275. {
  1276. returnErrorMsg("线下单续审核后才能关联!");
  1277. return;
  1278. }
  1279. entity.ptid = ftid;
  1280. entity.OrderState = fentity.OrderState;
  1281. //entity.status = fentity.status;
  1282. entity.CustomerUserId = fentity.CustomerUserId;
  1283. entity.DesignUserId = fentity.DesignUserId;
  1284. entity.seller_memo = "补差价单:" + ftid;
  1285. entity.IsSample = 2;
  1286. entity.Update();
  1287. ApiVo apiVo = new ApiVo();
  1288. apiVo.orderNumber = ftid;
  1289. apiVo.payment = entity.payment;
  1290. apiVo.actionName = "repairDesign";
  1291. designHelper.API_WorkCore(apiVo);//repairDesign
  1292. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1293. returnSuccessMsg("关联成功!");
  1294. return;
  1295. }
  1296. else
  1297. returnErrorMsg("找不到记录");
  1298. }
  1299. }
  1300. public void download_erp_neworder()
  1301. {
  1302. string seller = GetPostString("seller_nick");
  1303. string tid = GetPostString("tid");
  1304. if (seller.Length <= 0 || tid.Length <= 0)
  1305. {
  1306. returnErrorMsg("数据错误");
  1307. }
  1308. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1309. //{
  1310. // returnErrorMsg("找不到店铺Sessionkey");
  1311. //}
  1312. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1313. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1314. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1315. if (res.IndexOf("refOid") == -1)
  1316. {
  1317. returnErrorMsg("下载订单数据失败");
  1318. return;
  1319. }
  1320. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1321. returnSuccessMsg("下载完成");
  1322. //tmcHelper.createNewOrder(res);
  1323. //CeErpTrade entr = null;
  1324. //entr = CeErpTrade.Get(tid);
  1325. //if (entr != null)
  1326. //{
  1327. // returnSuccess("下载成功");
  1328. // //下载成功之后,Cell表生成对应的订单;
  1329. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1330. //}
  1331. //else
  1332. //{
  1333. // returnErrorMsg("下载失败或者创建订单失败");
  1334. //}
  1335. }
  1336. public void set_erp_atersale()
  1337. {
  1338. if (UrlPostParmsCheck("ctid"))
  1339. {
  1340. string eid = GetPostString("ctid");
  1341. string reason = GetPostString("AfterSaleReason");
  1342. CeErpTradeCell entity = null;
  1343. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1344. if (entity != null)
  1345. {
  1346. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1347. {
  1348. returnErrorMsg("此订单已经在售后");
  1349. return;
  1350. }
  1351. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1352. //entity.AfterSaleReason = reason;
  1353. entity.AfterSaleTime = DateTime.Now;
  1354. entity.Update();
  1355. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1356. returnSuccessMsg("转售后成功!");
  1357. return;
  1358. }
  1359. returnErrorMsg("找不到记录");
  1360. }
  1361. }
  1362. public void set_erp_withdraw()
  1363. {
  1364. if (UrlPostParmsCheck("ctid"))
  1365. {
  1366. try
  1367. {
  1368. string eid = GetPostString("ctid");//商品id
  1369. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1370. CeWithdraw ceWithdrawSelect = null;
  1371. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1372. if (ceWithdrawSelect != null)
  1373. {
  1374. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1375. {
  1376. ceWithdrawSelect.status = -1;
  1377. ceWithdrawSelect.Update();
  1378. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1379. returnSuccessMsg("重新发起审核成功");
  1380. return;
  1381. }
  1382. else
  1383. {
  1384. returnSuccessMsg("请勿重复申请!");
  1385. return;
  1386. }
  1387. }
  1388. else
  1389. {
  1390. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1391. if (string.IsNullOrEmpty(CustomerUserId))
  1392. {
  1393. CustomerUserId = "-1";
  1394. }
  1395. int Userid = CurrentUser.UserID;//用户id
  1396. CeWithdraw ceWithdraw = new CeWithdraw();
  1397. ceWithdraw.tid = eid;
  1398. ceWithdraw.userid = Userid;
  1399. ceWithdraw.providerid = CustomerUserId;
  1400. ceWithdraw.status = 3;
  1401. ceWithdraw.creationtime = DateTime.Now;
  1402. ceWithdraw.Create();
  1403. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1404. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1405. return;
  1406. }
  1407. }
  1408. catch
  1409. {
  1410. returnErrorMsg("申请撤回订单失败");
  1411. return;
  1412. }
  1413. }
  1414. }
  1415. public void ins_erp_billinfo()
  1416. {
  1417. if (UrlPostParmsCheck("ctid"))
  1418. {
  1419. string eid = GetPostString("ctid");
  1420. CeErpTradeCell entity = null;
  1421. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1422. if (entity != null)
  1423. {
  1424. CeErpBill bill = CeErpBill.GetByTid(eid);
  1425. bool isHave = false;
  1426. if (bill != null)
  1427. {
  1428. isHave = true;
  1429. if (bill.state != 4)
  1430. {
  1431. returnErrorMsg("此单已经申请过发票了");
  1432. return;
  1433. }
  1434. }
  1435. if (entity.IsNeedBill == 0)
  1436. {
  1437. entity.IsNeedBill = 1;
  1438. }
  1439. entity.Update();
  1440. string errjson = "";
  1441. try
  1442. {
  1443. CeErpBill bill_entity = new CeErpBill();
  1444. bill_entity.tid = entity.tid;
  1445. bill_entity.title = GetPostString("title");
  1446. string taxstr = GetPostString("tax");
  1447. taxstr = taxstr.Replace(" ", "");
  1448. bill_entity.tax = taxstr;
  1449. bill_entity.bank = GetPostString("bank");
  1450. string bankacstr = GetPostString("bankac");
  1451. bankacstr = bankacstr.Replace(" ", "");
  1452. bill_entity.bankac = bankacstr;
  1453. bill_entity.address = GetPostString("address");
  1454. bill_entity.phone = GetPostString("phone");
  1455. bill_entity.price = GetPostString("price");
  1456. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1457. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1458. {
  1459. billCount += 1;
  1460. }
  1461. string prebill = "ltb";
  1462. for (int idx = 1; idx <= billCount; idx++)
  1463. {
  1464. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1465. string billoid = prebill + idx + dtstr;
  1466. bill_entity.billOrderId += billoid;
  1467. if (idx < billCount)
  1468. {
  1469. bill_entity.billOrderId += ",";
  1470. }
  1471. }
  1472. bill_entity.productId = GetPostInt("ProductName");
  1473. bill_entity.num = GetPostInt("num");
  1474. bill_entity.unit = GetPostString("unit");
  1475. bill_entity.type = GetPostString("type");
  1476. bill_entity.sendType = GetPostString("SendType");
  1477. bill_entity.email = GetPostString("email");
  1478. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1479. bill_entity.shopName = GetPostString("ShopName");
  1480. bill_entity.applymemo = GetPostString("applyMemo");
  1481. bill_entity.createTime = DateTime.Now;
  1482. bill_entity.state = 0;
  1483. bill_entity.userId = CurrentUser.UserID;
  1484. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1485. bill_entity.Create();
  1486. }
  1487. catch (Exception ex)
  1488. {
  1489. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1490. returnErrorMsg("创建发票出错!");
  1491. return;
  1492. }
  1493. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1494. returnSuccessMsg("发票申请成功!");
  1495. return;
  1496. }
  1497. returnErrorMsg("找不到记录");
  1498. }
  1499. }
  1500. public void ins_erp_neworder()
  1501. {
  1502. if (UrlPostParmsCheck("receiver_name"))
  1503. {
  1504. CeErpTrade entity = new CeErpTrade();
  1505. string plat_form = GetPostString("platform");
  1506. string preStr = "N_";
  1507. if (plat_form == "拼多多")
  1508. {
  1509. preStr = "P_";
  1510. }
  1511. else if (plat_form == "阿里巴巴")
  1512. {
  1513. preStr = "A_";
  1514. }
  1515. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1516. entity.seller_nick = GetPostString("seller_nick");
  1517. entity.buyer_nick = GetPostString("buyer_nick");
  1518. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1519. entity.total_fee = entity.payment;
  1520. entity.pay_time = DateTime.Now;
  1521. entity.status = "NOT_SHIPPED";
  1522. entity.receiver_name = GetPostString("receiver_name");
  1523. entity.receiver_mobile = GetPostString("receiver_mobile");
  1524. entity.receiver_state = GetPostString("receiver_state");
  1525. entity.receiver_city = GetPostString("receiver_city");
  1526. entity.receiver_district = GetPostString("receiver_district");
  1527. entity.receiver_address = GetPostString("receiver_address");
  1528. if (entity.receiver_state == "" || entity.receiver_city == "")
  1529. {
  1530. returnErrorMsg("收件地址不能为空");
  1531. return;
  1532. }
  1533. int shopId = 0;
  1534. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1535. if (nShop != null)
  1536. {
  1537. shopId = nShop.ID;
  1538. }
  1539. if (shopId != 34 && entity.payment == 0)
  1540. {
  1541. returnErrorMsg("公司自用的单金额才能为0");
  1542. return;
  1543. }
  1544. entity.Create();
  1545. CeErpTradeCell entitycell = new CeErpTradeCell();
  1546. entitycell.ctid = entity.tid;
  1547. entitycell.tid = entity.tid;
  1548. entitycell.ShopId = shopId;
  1549. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1550. entitycell.OrderState = 0;
  1551. entitycell.pay_time = entity.pay_time;
  1552. entitycell.IsOffLineOrder = 1;
  1553. entitycell.Create();
  1554. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1555. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1556. return;
  1557. }
  1558. }
  1559. public void ins_erp_neworder2()
  1560. {
  1561. if (UrlPostParmsCheck("receiver_name"))
  1562. {
  1563. //string plat_form = GetPostString("platform");
  1564. string preStr = "X_";
  1565. string memo = GetPostString("memo");
  1566. string productId = GetPostString("productId");
  1567. string primg = GetPostString("proofimg");
  1568. string sellerNick = GetPostString("seller_nick");
  1569. string addFrom = GetPostString("addfrom");
  1570. if (addFrom == "1")
  1571. {
  1572. preStr = "N_";
  1573. }
  1574. int shopId = 0;
  1575. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1576. if (nShop != null)
  1577. {
  1578. shopId = nShop.ID;
  1579. }
  1580. else
  1581. {
  1582. returnErrorMsg("找不到对应店铺");
  1583. return;
  1584. }
  1585. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1586. {
  1587. returnErrorMsg("必须上传付款凭证");
  1588. return;
  1589. }
  1590. CeErpTrade entity = new CeErpTrade();
  1591. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1592. entity.seller_nick = sellerNick;
  1593. entity.buyer_nick = GetPostString("buyer_nick");
  1594. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1595. entity.total_fee = entity.payment;
  1596. entity.pay_time = DateTime.Now;
  1597. entity.status = "NOT_SHIPPED";
  1598. entity.receiver_name = GetPostString("receiver_name");
  1599. entity.receiver_mobile = GetPostString("receiver_mobile");
  1600. entity.receiver_state = GetPostString("receiver_state");
  1601. entity.receiver_city = GetPostString("receiver_city");
  1602. entity.receiver_district = GetPostString("receiver_district");
  1603. entity.receiver_address = GetPostString("receiver_address");
  1604. entity.seller_memo = memo;
  1605. entity.orderFrom = 20;
  1606. entity.orderType = 15;
  1607. if (entity.receiver_state == "" || entity.receiver_city == "")
  1608. {
  1609. returnErrorMsg("收件地址不能为空");
  1610. return;
  1611. }
  1612. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1613. {
  1614. returnErrorMsg("公司自用的单金额才能为0");
  1615. return;
  1616. }
  1617. entity.Create();
  1618. string toWhere = GetPostString("towhere");
  1619. CeErpTradeCell entitycell = new CeErpTradeCell();
  1620. entitycell.ctid = entity.tid;
  1621. //唯一标识
  1622. entitycell.OrderSn = entity.tid;
  1623. //string orderSn = dataHelper.getSaleOrderSn();
  1624. //if (orderSn != "")
  1625. // {
  1626. // entitycell.OrderSn = orderSn;
  1627. // }
  1628. entitycell.tid = entity.tid;
  1629. //if (preStr == "X_")
  1630. //{
  1631. entitycell.IsOffLineOrder = 1;
  1632. //}
  1633. entitycell.CustomerUserId = CurrentUser.UserID;
  1634. entitycell.PayProofImg = primg;
  1635. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1636. entitycell.ProductId = Convert.ToInt32(productId);
  1637. entitycell.ShopId = shopId;
  1638. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1639. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1640. {
  1641. entitycell.IsXianHuo = 1;
  1642. }
  1643. entitycell.pay_time = entity.pay_time;
  1644. if (toWhere == "1")
  1645. {
  1646. entitycell.OrderState = 2;
  1647. }
  1648. else
  1649. {
  1650. entitycell.OrderState = 6;
  1651. entitycell.FinishPlaceTime = entitycell.pay_time;
  1652. }
  1653. if (shopId == 94)
  1654. {
  1655. entitycell.OrderState = 4;
  1656. entitycell.WaitDesignTime = entitycell.pay_time;
  1657. entitycell.StartDesignTime = entitycell.pay_time;
  1658. entitycell.DesignUserId = 218;
  1659. }
  1660. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1661. {
  1662. entitycell.OrderState = -1;//修改12-5
  1663. CeWithdraw ceWithdraw = new CeWithdraw();
  1664. ceWithdraw.tid = entity.tid;
  1665. ceWithdraw.providerid = "-1";
  1666. ceWithdraw.status = -1;
  1667. ceWithdraw.creationtime = DateTime.Now;
  1668. ceWithdraw.userid = 1337;
  1669. ceWithdraw.Create();
  1670. }
  1671. entitycell.Create();
  1672. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1673. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1674. {
  1675. addPlaceRegist(entitycell, CurrentUser.UserID);
  1676. }
  1677. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1678. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1679. return;
  1680. }
  1681. }
  1682. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1683. {
  1684. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1685. entity.PlactTime = tradecell.pay_time;
  1686. entity.AddUserId = userid;
  1687. entity.FileName = tradecell.seller_memo;
  1688. entity.Supplier = 24;
  1689. entity.CreateTime = DateTime.Now;
  1690. entity.Did = tradecell.ctid;
  1691. entity.tid = tradecell.tid;
  1692. entity.splitTag = tradecell.SplitTag;
  1693. entity.CurState = "未完成";
  1694. entity.Create();
  1695. }
  1696. public void get_erp_offlinelist()
  1697. {
  1698. DataStruct dStruct = GetPostStruct();
  1699. List<string> lw = new List<string>();
  1700. string tid = GetPostString("ctid");
  1701. string date1 = GetPostString("date1");
  1702. string date2 = GetPostString("date2");
  1703. if (tid.Length > 0 || date1.Length > 0)
  1704. {
  1705. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1706. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1707. if (dw.Length > 0) lw.Add(dw);
  1708. }
  1709. else
  1710. {
  1711. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1712. }
  1713. string shopname = GetPostString("shopname");
  1714. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1715. string buyernick = GetPostString("buyer_nick");
  1716. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1717. string customer = GetPostString("customer");
  1718. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1719. string design = GetPostString("design");
  1720. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1721. string orderState = GetPostString("orderState");
  1722. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1723. string address = GetPostString("address");
  1724. 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));
  1725. string sellermemo = GetPostString("seller_memo");
  1726. if (sellermemo.Length > 0)
  1727. {
  1728. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1729. }
  1730. string price1 = GetPostString("price1");
  1731. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1732. string price2 = GetPostString("price2");
  1733. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1734. //if (PKey != "admin")
  1735. //{
  1736. // string usershop = CurrentUser.User.pemShop;
  1737. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1738. //}
  1739. //if (ex_psize > 0)
  1740. //{
  1741. dStruct.Order = "pay_time desc";
  1742. //}
  1743. //else
  1744. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1745. lw.Add(string.Format("IsOffLineOrder=1"));
  1746. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1747. DataTable dt = null;
  1748. dt = WebCache.GetData("view_erptradecell", dStruct);
  1749. writeGridDataTableJson(dStruct.TotalCount, dt);
  1750. }
  1751. public void get_erp_returncashrecord()
  1752. {
  1753. DataStruct dStruct = GetPostStruct();
  1754. List<string> lw = new List<string>();
  1755. string tid = GetPostString("ctid");
  1756. if (tid.Length > 0)
  1757. {
  1758. lw.Add(string.Format("tid like '%{0}%'", tid));
  1759. dStruct.Order = "id desc";
  1760. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1761. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1762. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1763. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1764. return;
  1765. }
  1766. returnErrorMsg("id数据错误!");
  1767. }
  1768. public void ins_erp_returncashrecord()
  1769. {
  1770. if (UrlPostParmsCheck("tid"))
  1771. {
  1772. string tid = GetPostString("tid");
  1773. string retype = GetPostString("type");
  1774. StringBuilder sql = new StringBuilder();
  1775. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1776. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1777. if (dt.Rows.Count > 0)
  1778. {
  1779. returnErrorMsg("相同返现类型记录已存在");
  1780. return;
  1781. }
  1782. CeErpReturnCash entity = new CeErpReturnCash();
  1783. entity.tid = tid;
  1784. entity.seller_nick = GetPostString("seller_nick");
  1785. string pment = GetPostString("payment");
  1786. if (pment.Length > 0)
  1787. {
  1788. entity.payment = Convert.ToDouble(pment);
  1789. }
  1790. entity.buyer_nick = GetPostString("buyer_nick");
  1791. entity.cashstate = 0;
  1792. entity.rtype = retype;
  1793. string rPrice = GetPostString("returnprice");
  1794. if (rPrice.Length > 0)
  1795. {
  1796. entity.returnprice = Convert.ToDouble(rPrice);
  1797. }
  1798. entity.created = DateTime.Now;
  1799. entity.con = GetPostString("con");
  1800. entity.img = GetPostString("img");
  1801. entity.applyuserid = CurrentUser.UserID;
  1802. entity.Create();
  1803. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1804. returnSuccessMsg("操作成功!");
  1805. return;
  1806. }
  1807. }
  1808. public void set_erp_predelivery()
  1809. {
  1810. if (UrlPostParmsCheck("ctid"))
  1811. {
  1812. string eid = GetPostString("ctid");
  1813. CeErpTradeCell entity = null;
  1814. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1815. if (entity != null)
  1816. {
  1817. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1818. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1819. //{
  1820. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1821. // return;
  1822. //}
  1823. entity.IsPreDelivery = 1;
  1824. entity.Update();
  1825. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1826. returnSuccessMsg("预发货成功!");
  1827. return;
  1828. //string shop = GetPostString("seller_nick");
  1829. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1830. //string comName = GetPostString("comName");
  1831. //string comCode = GetPostString("comCode");
  1832. //string outSid = GetPostString("outSid");//运单号
  1833. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1834. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1835. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1836. //string apires = "";
  1837. //if (deliveryType == "虚拟发货")
  1838. //{
  1839. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1840. //}
  1841. //else
  1842. //{
  1843. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1844. //}
  1845. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1846. ////{
  1847. //if (apires.IndexOf("发货成功") != -1)
  1848. //{
  1849. // if (deliveryType != "虚拟发货")
  1850. // {
  1851. // //还要插入快递信息到 快递信息表
  1852. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1853. // exinfo.tid = eid;
  1854. // exinfo.out_sid = outSid;
  1855. // exinfo.company_code = comCode;
  1856. // exinfo.company_name = comName;
  1857. // exinfo.delivery_memo = deliveryMemo;
  1858. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1859. // exinfo.deliveryType = deliveryType;
  1860. // exinfo.Create();
  1861. // }
  1862. // returnSuccessMsg("发货成功!");
  1863. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1864. //}
  1865. //else
  1866. //{
  1867. // returnErrorMsg("淘宝发货失败!!");
  1868. //}
  1869. //return;
  1870. }
  1871. returnErrorMsg("找不到订单记录");
  1872. }
  1873. }
  1874. public void get_erp_unusuallist()
  1875. {
  1876. DataStruct dStruct = GetPostStruct();
  1877. List<string> lw = new List<string>();
  1878. string tid = GetPostString("ctid");
  1879. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1880. string shopname = GetPostString("shopname");
  1881. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1882. string buyernick = GetPostString("buyer_nick");
  1883. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1884. string ResponsibleMan = GetPostString("responsible");
  1885. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1886. string date1 = GetPostString("date1");
  1887. string date2 = GetPostString("date2");
  1888. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1889. if (dw.Length > 0) lw.Add(dw);
  1890. string price1 = GetPostString("price1");
  1891. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1892. string price2 = GetPostString("price2");
  1893. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1894. string orderState = GetPostString("orderState");
  1895. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1896. string sellermemo = GetPostString("seller_memo");
  1897. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1898. lw.Add(string.Format("UnusualTag > 0"));
  1899. lw.Add(string.Format("IsRefund<={0}", 1));
  1900. dStruct.Order = "pay_time desc";
  1901. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1902. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1903. writeGridDataTableJson(dStruct.TotalCount, dt);
  1904. }
  1905. public void set_erp_unusualtonomal()
  1906. {
  1907. if (UrlPostParmsCheck("ctid"))
  1908. {
  1909. string eid = GetPostString("ctid");
  1910. CeErpTradeCell entity = null;
  1911. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1912. if (entity != null)
  1913. {
  1914. entity.UnusualTag = -1;
  1915. entity.Update();
  1916. returnSuccessMsg("忽略成功!");
  1917. return;
  1918. }
  1919. returnErrorMsg("找不到记录");
  1920. }
  1921. }
  1922. public void ins_erp_unusualreason()
  1923. {
  1924. if (UrlPostParmsCheck("ctid"))
  1925. {
  1926. string eid = GetPostString("ctid");
  1927. CeErpTradeCell entity = null;
  1928. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1929. if (entity != null)
  1930. {
  1931. entity.MemoOpt = 4;
  1932. entity.UnusualCon = GetPostString("con");
  1933. entity.Update();
  1934. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1935. if (trade != null)
  1936. {
  1937. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1938. }
  1939. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1940. returnSuccessMsg("操作成功!");
  1941. return;
  1942. }
  1943. returnErrorMsg("找不到记录");
  1944. }
  1945. }
  1946. public void upd_erp_sampleorder()
  1947. {
  1948. if (UrlPostParmsCheck("ctid"))
  1949. {
  1950. string eid = GetPostString("ctid");
  1951. string[] eArr = eid.Split(',');
  1952. if (eArr.Length > 1)
  1953. {
  1954. List<string> eLst = new List<string>();
  1955. for (int i = 0; i < eArr.Length; i++)
  1956. {
  1957. eLst.Add("'" + eArr[i] + "'");
  1958. }
  1959. eid = string.Join(",", eLst.ToArray());
  1960. }
  1961. else
  1962. {
  1963. eid = "'" + eid + "'";
  1964. }
  1965. StringBuilder sql = new StringBuilder();
  1966. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  1967. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1968. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  1969. if (dt.Rows.Count > 0)
  1970. {
  1971. string errmsg = "";
  1972. foreach (DataRow dr in dt.Rows)
  1973. {
  1974. StringBuilder sqlsb = new StringBuilder();
  1975. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  1976. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  1977. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  1978. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  1979. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  1980. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  1981. {
  1982. continue;
  1983. }
  1984. else
  1985. {
  1986. string emsg = commonHelper.KeepChinese(apires);
  1987. errmsg += emsg;
  1988. }
  1989. }
  1990. if (errmsg.Length > 0)
  1991. {
  1992. returnErrorMsg(errmsg);
  1993. return;
  1994. }
  1995. returnSuccessMsg("操作成功");
  1996. return;
  1997. }
  1998. returnErrorMsg("找不到记录");
  1999. }
  2000. }
  2001. public void upd_erp_transcustomer()
  2002. {
  2003. if (UrlPostParmsCheck("ctid"))
  2004. {
  2005. string eid = GetPostString("ctid");
  2006. int userid = GetPostInt("CustomerUserId");
  2007. CeErpTradeCell entity = null;
  2008. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2009. if (entity != null)
  2010. {
  2011. //string[] mlist = entity.seller_memo.Split('-');
  2012. //string sql = "select * from view_erpuser where id=" + userid;
  2013. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2014. //if (dt != null && dt.Rows.Count > 0)
  2015. //{
  2016. // string nmemo = "";
  2017. // for(int i = 0; i < mlist.Length - 1; i++)
  2018. // {
  2019. // nmemo += mlist[i];
  2020. // nmemo += "-";
  2021. // }
  2022. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2023. // entity.seller_memo = nmemo;
  2024. //}
  2025. entity.CustomerUserId = userid;
  2026. entity.Update();
  2027. returnSuccessMsg("操作成功!");
  2028. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2029. return;
  2030. }
  2031. returnErrorMsg("找不到记录");
  2032. }
  2033. }
  2034. public void upd_erp_transdesigner()
  2035. {
  2036. if (UrlPostParmsCheck("ctid"))
  2037. {
  2038. string eids = GetPostString("ctid");
  2039. string[] ctidList = eids.Split(',');
  2040. int userid = GetPostInt("DesignUserId");
  2041. foreach (string ctid in ctidList)
  2042. {
  2043. CeErpTradeCell entity = null;
  2044. CeErpDesignerBill entitys = null;
  2045. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2046. entitys = CeErpDesignerBill.GetByTid(ctid);
  2047. if (entity != null)
  2048. {
  2049. if (entity.OrderState > 4)
  2050. {
  2051. continue;
  2052. }
  2053. //存在退款不能流转
  2054. if (entity.IsRefund > 0)
  2055. {
  2056. continue;
  2057. }
  2058. entity.DesignUserId = userid;
  2059. entity.WaitDesignTime = DateTime.Now;
  2060. entity.Update();
  2061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2062. }
  2063. }
  2064. returnSuccessMsg("操作成功!");
  2065. }
  2066. }
  2067. public void upd_erp_distributedesigner()
  2068. {
  2069. if (UrlPostParmsCheck("ctid"))
  2070. {
  2071. string eid = GetPostString("ctid");
  2072. int userid = GetPostInt("DesignUserId");
  2073. string[] idlist = eid.Split(',');
  2074. if (idlist.Length <= 0)
  2075. {
  2076. returnErrorMsg("订单不能为空");
  2077. return;
  2078. }
  2079. foreach (string ctid in idlist)
  2080. {
  2081. CeErpTradeCell entity = null;
  2082. CeErpDesignerBill entitys = null;
  2083. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2084. else continue;
  2085. if (entity != null)
  2086. {
  2087. if (userid == 2125 || userid == 3542)
  2088. { }
  2089. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2090. {
  2091. returnErrorMsg("金额错误的订单无法指派");
  2092. return;
  2093. }
  2094. if (entity.OrderState >= 5)
  2095. {
  2096. returnErrorMsg("已经设计完成无法指派");
  2097. return;
  2098. }
  2099. if (entity.OrderState == -1)
  2100. {
  2101. returnErrorMsg("审核中的订单无法指派");
  2102. return;
  2103. }
  2104. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2105. {
  2106. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2107. return;
  2108. }
  2109. if (entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize")
  2110. {
  2111. returnErrorMsg("指派设计共创无法再次指派!");
  2112. return;
  2113. }
  2114. entity.OrderState = 3;
  2115. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2116. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2117. {
  2118. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2119. entity.SupplierId = suid;
  2120. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2121. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2122. }
  2123. if (userid == 2125 && entity.seller_memo != "")
  2124. {
  2125. apiDesign.API_GetPrintData_CreateOrder(entity);
  2126. }
  2127. if (userid == 3542 && entity.seller_memo != "")
  2128. {
  2129. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2130. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2131. if (response.msg != "设计共创:成功")
  2132. {
  2133. returnErrorMsg(response.msg);
  2134. return;
  2135. }
  2136. entity.DispatchSort = 2;
  2137. entity.OrderState = 3;
  2138. }
  2139. entity.DesignUserId = userid;
  2140. entity.WaitDesignTime = DateTime.Now;
  2141. entity.Update();
  2142. string name = commonHelper.getUserNameById(userid);
  2143. commonHelper.UpdateRelationOrder(entity.ctid);
  2144. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2145. }
  2146. }
  2147. returnSuccessMsg("操作成功!");
  2148. return;
  2149. }
  2150. }
  2151. public void get_erp_myorderlist()
  2152. {
  2153. DataStruct dStruct = GetPostStruct();
  2154. List<string> lw = new List<string>();
  2155. string tid = GetPostString("ctid");
  2156. if (tid.Length > 0)
  2157. {
  2158. lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2159. }
  2160. else
  2161. {
  2162. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2163. }
  2164. //12-1 修改
  2165. string urgent = GetPostString("urgent");
  2166. string back = GetPostString("back");
  2167. string offlineSearch = GetPostString("offlineSearch");
  2168. if (!string.IsNullOrWhiteSpace(urgent))
  2169. {
  2170. if (urgent.Equals("true"))
  2171. {
  2172. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2173. }
  2174. }
  2175. if (!string.IsNullOrWhiteSpace(back))
  2176. {
  2177. if (back.Equals("true"))
  2178. {
  2179. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2180. }
  2181. }
  2182. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2183. {
  2184. if (offlineSearch.Equals("true"))
  2185. {
  2186. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2187. }
  2188. }
  2189. //end
  2190. string shopname = GetPostString("shopname");
  2191. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2192. string buyernick = GetPostString("buyer_nick");
  2193. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2194. string design = GetPostString("design");
  2195. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2196. string orderState = GetPostString("orderState");
  2197. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2198. string sellermemo = GetPostString("seller_memo");
  2199. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2200. string date1 = GetPostString("date1");
  2201. string date2 = GetPostString("date2");
  2202. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2203. if (dw.Length > 0) lw.Add(dw);
  2204. string price1 = GetPostString("price1");
  2205. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2206. string price2 = GetPostString("price2");
  2207. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2208. string urgency = GetPostString("urgency");
  2209. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2210. string after = GetPostString("after");
  2211. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2212. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2213. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2214. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2215. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2216. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2217. writeGridDataTableJson(dStruct.TotalCount, dt);
  2218. }
  2219. public void get_erp_myreturnorderlist()
  2220. {
  2221. DataStruct dStruct = GetPostStruct();
  2222. List<string> lw = new List<string>();
  2223. string tid = GetPostString("ctid");
  2224. if (tid.Length > 0)
  2225. {
  2226. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  2227. }
  2228. else
  2229. {
  2230. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2231. }
  2232. string shopname = GetPostString("shopname");
  2233. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2234. string buyernick = GetPostString("buyer_nick");
  2235. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2236. string design = GetPostString("design");
  2237. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2238. string orderState = GetPostString("orderState");
  2239. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2240. string sellermemo = GetPostString("seller_memo");
  2241. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2242. string date1 = GetPostString("date1");
  2243. string date2 = GetPostString("date2");
  2244. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2245. if (dw.Length > 0) lw.Add(dw);
  2246. string price1 = GetPostString("price1");
  2247. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2248. string price2 = GetPostString("price2");
  2249. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2250. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2251. {
  2252. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2253. }
  2254. else
  2255. {
  2256. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2257. }
  2258. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2259. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2260. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2261. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2262. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2263. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2264. if (dt != null && dt.Rows.Count > 0)
  2265. {
  2266. foreach (DataRow dr in dt.Rows)
  2267. {
  2268. try
  2269. {
  2270. // 对象操作
  2271. if (dStruct.PageSize != 100000)
  2272. {
  2273. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2274. dr["gongchuang"] = response.code;
  2275. }
  2276. }
  2277. catch (NullReferenceException ex)
  2278. {
  2279. // 处理空引用异常
  2280. }
  2281. }
  2282. }
  2283. writeGridDataTableJson(dStruct.TotalCount, dt);
  2284. }
  2285. public void get_erp_myorderlist_pregather()
  2286. {
  2287. string date1 = GetPostString("date1");
  2288. string date2 = GetPostString("date2");
  2289. int userId = CurrentUser.UserID; //客服id
  2290. string orderWhere = "";
  2291. List<string> lw = new List<string>();
  2292. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2293. if (dw.Length > 0) lw.Add(dw);
  2294. lw.Add(string.Format("CustomerUserId={0}", userId));
  2295. lw.Add(string.Format("OrderState<9"));
  2296. orderWhere = string.Join(" and ", lw.ToArray());
  2297. string orderWhere2 = "";
  2298. List<string> lw2 = new List<string>();
  2299. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2300. if (dw2.Length > 0) lw2.Add(dw2);
  2301. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2302. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2303. string sql = string.Format("select *" +
  2304. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2305. "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 " +
  2306. "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 " +
  2307. "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");
  2308. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2309. //writeGridDataTableJson(dt.Rows.Count, dt);
  2310. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2311. }
  2312. public void upd_erp_publishorder()
  2313. {
  2314. if (UrlPostParmsCheck("ctid"))
  2315. {
  2316. string eid = GetPostString("ctid");
  2317. CeErpTradeCell entity = null;
  2318. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2319. if (entity != null)
  2320. {
  2321. entity.OrderState = 0; //发布后,变为待抢单
  2322. entity.Update();
  2323. commonHelper.UpdateRelationOrder(entity.ctid);
  2324. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2325. returnSuccessMsg("发布成功!");
  2326. return;
  2327. }
  2328. returnErrorMsg("找不到记录");
  2329. }
  2330. }
  2331. public void get_erp_my_tiporder()
  2332. {
  2333. StringBuilder sql = new StringBuilder();
  2334. int userId = 0;
  2335. if (CurrentUser != null) userId = CurrentUser.UserID;
  2336. string posCode = CurrentUser.UserPost.Post.Code;
  2337. string isTipedAfterSaleVerify = GetPostString("af");
  2338. DataTable dt = new DataTable();
  2339. if (posCode != "Supplier")
  2340. {
  2341. if (posCode == "CustomerService" || posCode == "Director")
  2342. {
  2343. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2344. }
  2345. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2346. {
  2347. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2348. }
  2349. else
  2350. {
  2351. string teamIds = CurrentUser.User.TeamIds;
  2352. if (teamIds == "")
  2353. {
  2354. teamIds = "0";
  2355. }
  2356. 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);
  2357. }
  2358. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2359. }
  2360. if (dt.Rows.Count <= 0)
  2361. {
  2362. string key = "aftersale_order_" + userId;
  2363. if (RedisHelper.HasKey(key))
  2364. {
  2365. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2366. dt.Columns.Add("ctid", typeof(string));
  2367. dt.Columns.Add("IsReadTag", typeof(int));
  2368. foreach (var i in list)
  2369. {
  2370. DataRow data = dt.NewRow();
  2371. data["ctid"] = i;
  2372. data["IsReadTag"] = 4;
  2373. dt.Rows.Add(data);
  2374. }
  2375. RedisHelper.StringDelete(key);
  2376. }
  2377. }
  2378. if (dt.Rows.Count <= 0)
  2379. {
  2380. sql = new StringBuilder();
  2381. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2382. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2383. }
  2384. if (posCode == "Supplier")
  2385. {
  2386. string ids = CurrentUser.User.pemVend;
  2387. if (ids != null && ids.Length > 0)
  2388. {
  2389. string[] ids_list = ids.Split(',');
  2390. foreach (var item in ids_list)
  2391. {
  2392. string key = "return_order_" + item;
  2393. if (RedisHelper.HasKey(key))
  2394. {
  2395. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2396. dt.Columns.Add("ctid", typeof(string));
  2397. dt.Columns.Add("IsReadTag", typeof(int));
  2398. foreach (var i in list)
  2399. {
  2400. DataRow data = dt.NewRow();
  2401. data["ctid"] = i;
  2402. data["IsReadTag"] = 1;
  2403. dt.Rows.Add(data);
  2404. }
  2405. RedisHelper.StringDelete(key);
  2406. }
  2407. }
  2408. }
  2409. if (dt.Rows.Count <= 0)
  2410. {
  2411. sql = new StringBuilder();
  2412. 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);
  2413. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2414. }
  2415. }
  2416. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2417. }
  2418. public void reset_erp_tiporder()
  2419. {
  2420. string ids = GetPostString("ids");
  2421. string[] ctidList = ids.Split(',');
  2422. foreach (string ctid in ctidList)
  2423. {
  2424. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2425. if (enty != null)
  2426. {
  2427. enty.IsReadTag = 0;
  2428. enty.Update();
  2429. }
  2430. }
  2431. returnSuccessMsg("成功!");
  2432. return;
  2433. }
  2434. public void get_erp_designlist()
  2435. {
  2436. DataStruct dStruct = GetPostStruct();
  2437. List<string> lw = new List<string>();
  2438. string tid = GetPostString("ctid");
  2439. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  2440. string shopname = GetPostString("shopname");
  2441. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2442. string buyernick = GetPostString("buyer_nick");
  2443. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2444. string customer = GetPostString("customer");
  2445. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2446. string design = GetPostString("design");
  2447. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2448. string orderState = GetPostString("orderState");
  2449. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2450. lw.Add(string.Format("OrderState<6"));
  2451. string address = GetPostString("address");
  2452. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2453. string sellermemo = GetPostString("seller_memo");
  2454. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2455. string date1 = GetPostString("date1");
  2456. string date2 = GetPostString("date2");
  2457. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2458. if (dw.Length > 0) lw.Add(dw);
  2459. string apdate1 = GetPostString("apdate1");
  2460. string apdate2 = GetPostString("apdate2");
  2461. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2462. if (dwap.Length > 0) lw.Add(dwap);
  2463. string price1 = GetPostString("price1");
  2464. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2465. string price2 = GetPostString("price2");
  2466. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2467. string designTime = GetPostString("designtime");
  2468. if (designTime.Length > 0)
  2469. {
  2470. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2471. }
  2472. string usershop = CurrentUser.User.pemShop;
  2473. if (usershop.Length > 0)
  2474. {
  2475. lw.Add(string.Format("shopId in ({0})", usershop));
  2476. }
  2477. int myOrgid = CurrentUser.UserPost.OrgID;
  2478. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2479. if (myOrgCode.IndexOf("Designer") != -1)
  2480. {
  2481. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2482. {
  2483. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2484. }
  2485. else
  2486. {
  2487. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2488. }
  2489. }
  2490. else
  2491. {
  2492. string orgId = GetPostString("designerhd");
  2493. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2494. }
  2495. if (tid.Length > 0 || buyernick.Length > 0)
  2496. {
  2497. lw.Add(string.Format("OrderState >= 3"));
  2498. }
  2499. else
  2500. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2501. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2502. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2503. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2504. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2505. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2506. if (dt != null && dt.Rows.Count > 0)
  2507. {
  2508. foreach (DataRow dr in dt.Rows)
  2509. {
  2510. try
  2511. {
  2512. // 对象操作
  2513. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2514. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2515. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2516. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2517. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2518. if (dStruct.PageSize != 100000)
  2519. {
  2520. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2521. dr["gongchuang"] = response.code;
  2522. }
  2523. }
  2524. catch (NullReferenceException ex)
  2525. {
  2526. }
  2527. }
  2528. }
  2529. writeGridDataTableJson(dStruct.TotalCount, dt);
  2530. }
  2531. public void get_erp_mydesignlist()
  2532. {
  2533. DataStruct dStruct = GetPostStruct();
  2534. List<string> lw = new List<string>();
  2535. string tid = GetPostString("ctid");
  2536. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2537. string shopname = GetPostString("shopname");
  2538. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2539. string buyernick = GetPostString("buyer_nick");
  2540. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2541. string customer = GetPostString("customer");
  2542. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2543. string orderState = GetPostString("orderState");
  2544. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2545. //lw.Add(string.Format("OrderState<6"));
  2546. string date1 = GetPostString("date1");
  2547. string date2 = GetPostString("date2");
  2548. string dw = GetDateWhere("pay_time", date1, date2);
  2549. if (dw.Length > 0) lw.Add(dw);
  2550. string apdate1 = GetPostString("apdate1");
  2551. string apdate2 = GetPostString("apdate2");
  2552. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2553. if (dwap.Length > 0) lw.Add(dwap);
  2554. string price1 = GetPostString("price1");
  2555. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2556. string price2 = GetPostString("price2");
  2557. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2558. string olddownload = GetPostString("olddown");
  2559. if (olddownload == "1")
  2560. {
  2561. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2562. }
  2563. else if (olddownload == "2")
  2564. {
  2565. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2566. }
  2567. string sellermemo = GetPostString("seller_memo");
  2568. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2569. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2570. if (CurrentUser.User.TeamIds.Length > 0)
  2571. {
  2572. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2573. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2574. else
  2575. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2576. }
  2577. else
  2578. {
  2579. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2580. }
  2581. if (tid.Length <= 0)
  2582. {
  2583. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2584. }
  2585. lw.Add(string.Format("IsReturn!=3"));
  2586. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2587. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2588. string teamids = CurrentUser.User.TeamIds.ToString();
  2589. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2590. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2591. if (dt != null && dt.Rows.Count > 0)
  2592. {
  2593. foreach (DataRow dr in dt.Rows)
  2594. {
  2595. try
  2596. {
  2597. // 对象操作
  2598. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2599. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2600. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2601. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2602. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2603. if (dStruct.PageSize != 100000)
  2604. {
  2605. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2606. dr["gongchuang"] = response.code;
  2607. }
  2608. }
  2609. catch (NullReferenceException ex)
  2610. {
  2611. }
  2612. }
  2613. }
  2614. writeGridDataTableJson(dStruct.TotalCount, dt);
  2615. }
  2616. public void set_erp_startdesign()
  2617. {
  2618. if (UrlPostParmsCheck("ctid"))
  2619. {
  2620. string eid = GetPostString("ctid");
  2621. CeErpTradeCell entity = null;
  2622. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2623. if (entity != null)
  2624. {
  2625. if (entity.OrderState != 3)
  2626. {
  2627. returnErrorMsg("请刷新,订单已经设计了");
  2628. return;
  2629. }
  2630. entity.StartDesignTime = DateTime.Now;
  2631. entity.OrderState = 4;
  2632. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2633. {
  2634. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2635. entity.SupplierId = suid;
  2636. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2637. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2638. }
  2639. //entity.MakeSupplier = suname;
  2640. entity.Update();
  2641. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2642. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2643. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2644. commonHelper.getCytPrice(entity);
  2645. returnSuccessMsg("操作成功!");
  2646. return;
  2647. }
  2648. returnErrorMsg("找不到记录");
  2649. }
  2650. }
  2651. public void ins_erp_designselfmemo()
  2652. {
  2653. if (UrlPostParmsCheck("ctid"))
  2654. {
  2655. string eid = GetPostString("ctid");
  2656. string con = GetPostString("con");
  2657. CeErpTradeCell entity = null;
  2658. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2659. if (entity != null)
  2660. {
  2661. entity.DesignSelfMemo = con;
  2662. entity.Update();
  2663. returnSuccessMsg("操作成功!");
  2664. return;
  2665. }
  2666. returnErrorMsg("找不到记录");
  2667. }
  2668. }
  2669. public void ins_erp_designprice()
  2670. {
  2671. if (UrlPostParmsCheck("ctid"))
  2672. {
  2673. string eid = GetPostString("ctid");
  2674. int uid = CurrentUser.UserID;
  2675. string userName = CurrentUser.UserName;
  2676. CeErpTradeCell entity = null;
  2677. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2678. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2679. if (entitys == null)
  2680. {
  2681. entitys = new CeErpDesignerBill();
  2682. }
  2683. if (entity != null)
  2684. {
  2685. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2686. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2687. entity.StartDesignTime = DateTime.Now;
  2688. entity.OrderState = 4;
  2689. string suname = "";
  2690. if (entity.SupplierId == 0)
  2691. {
  2692. int sid = commonHelper.autoDistributeToSupplier(entity);
  2693. entity.SupplierId = sid;
  2694. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2695. }
  2696. entity.Update();
  2697. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2698. if (ceErpUserPost != null)
  2699. {
  2700. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2701. if (ceErpPost != null)
  2702. {
  2703. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2704. {
  2705. entitys.tid = entity.ctid;
  2706. entitys.oid = entity.tid;
  2707. entitys.uid = uid;
  2708. entitys.userName = userName;
  2709. entitys.designerType = 1;
  2710. entitys.designerTypeText = "内部设计师";
  2711. entitys.price = Convert.ToDouble(GetPostString("price"));
  2712. entitys.designNum = GetPostInt("designNum");
  2713. entitys.modifyNum = GetPostInt("modifyNum");
  2714. entitys.designSize = GetPostString("designSize");
  2715. entitys.modifySize = GetPostString("modifySize");
  2716. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2717. {
  2718. entitys.create_time = DateTime.Now;
  2719. entitys.create_u_id = uid;
  2720. entitys.create_u_name = userName;
  2721. entitys.Save();
  2722. }
  2723. else
  2724. {
  2725. entitys.update_time = DateTime.Now;
  2726. entitys.update_u_id = uid;
  2727. entitys.update_u_name = userName;
  2728. entitys.Update();
  2729. }
  2730. }
  2731. }
  2732. }
  2733. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2734. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2735. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2736. if (suname != "")
  2737. {
  2738. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2739. }
  2740. commonHelper.getCytPrice(entity);
  2741. returnSuccessMsg("操作成功!");
  2742. return;
  2743. }
  2744. returnErrorMsg("找不到记录");
  2745. }
  2746. }
  2747. public void upload_erp_filecomplete()
  2748. {
  2749. if (UrlPostParmsCheck("ctid"))
  2750. {
  2751. string eid = GetPostString("ctid");
  2752. CeErpTradeCell entity = null;
  2753. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2754. if (entity != null)
  2755. {
  2756. entity.OrderState = 5; //设计完成
  2757. entity.Update();
  2758. returnSuccessMsg(eid + "上传成功,设计完成!");
  2759. return;
  2760. }
  2761. returnErrorMsg("找不到订单记录");
  2762. }
  2763. }
  2764. public void get_erp_designovertimelist()
  2765. {
  2766. DataStruct dStruct = GetPostStruct();
  2767. List<string> lw = new List<string>();
  2768. string tid = GetPostString("ctid");
  2769. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2770. string shopname = GetPostString("shopname");
  2771. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2772. string buyernick = GetPostString("buyer_nick");
  2773. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2774. string ResponsibleMan = GetPostString("responsible");
  2775. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2776. string date1 = GetPostString("date1");
  2777. string date2 = GetPostString("date2");
  2778. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2779. if (dw.Length > 0) lw.Add(dw);
  2780. string price1 = GetPostString("price1");
  2781. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2782. string price2 = GetPostString("price2");
  2783. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2784. string orderState = GetPostString("orderState");
  2785. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2786. string sellermemo = GetPostString("seller_memo");
  2787. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2788. lw.Add(string.Format("UnusualTag=3"));
  2789. lw.Add(string.Format("IsRefund<={0}", 1));
  2790. dStruct.Order = "WaitDesignTime desc";
  2791. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2792. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2793. writeGridDataTableJson(dStruct.TotalCount, dt);
  2794. }
  2795. //设计管理 获取抢单大厅列表
  2796. public void get_erp_grabinglist()
  2797. {
  2798. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2799. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2800. bool oldOrder = false;
  2801. if (org != null)
  2802. {
  2803. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2804. }
  2805. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2806. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2807. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2808. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2809. //先处理订单数据
  2810. if (dt.Rows.Count > 0)
  2811. {
  2812. Dictionary<string, int> design = null;
  2813. int count = 0;
  2814. foreach (DataRow row in dt.Rows)
  2815. {
  2816. if (map.ContainsKey(row["ShopId"].ToString()))
  2817. {
  2818. map.TryGetValue(row["ShopId"].ToString(), out design);
  2819. }
  2820. else
  2821. {
  2822. design = new Dictionary<string, int>();
  2823. }
  2824. if (design.ContainsKey(row["ProductId"].ToString()))
  2825. {
  2826. design.TryGetValue(row["ProductId"].ToString(), out count);
  2827. }
  2828. count++;
  2829. design[row["ProductId"].ToString()] = count;
  2830. map[row["ShopId"].ToString()] = design;
  2831. }
  2832. }
  2833. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2834. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2835. //把店铺排序和技能排序分类
  2836. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2837. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2838. if (design_dt.Rows.Count > 0)
  2839. {
  2840. Dictionary<string, string> design = null;
  2841. List<string> shopIds = null;
  2842. foreach (DataRow row in design_dt.Rows)
  2843. {
  2844. if ("0".Equals(row["designId"].ToString()))
  2845. {
  2846. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2847. {
  2848. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2849. }
  2850. else
  2851. {
  2852. shopIds = new List<string>();
  2853. }
  2854. shopIds.Add(row["shopId"].ToString());
  2855. shop_orders[row["orders"].ToString()] = shopIds;
  2856. }
  2857. else
  2858. {
  2859. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2860. {
  2861. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2862. }
  2863. else
  2864. {
  2865. design = new Dictionary<string, string>();
  2866. }
  2867. design[row["orders"].ToString()] = row["designId"].ToString();
  2868. design_orders[row["shopId"].ToString()] = design;
  2869. }
  2870. }
  2871. //处理成key value后根据key排序
  2872. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2873. foreach (List<string> val in shop_orders.Values)
  2874. {
  2875. if (val != null)
  2876. {
  2877. foreach (string key in val)
  2878. {
  2879. if (design_orders.ContainsKey(key.ToString()))
  2880. {
  2881. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2882. }
  2883. }
  2884. }
  2885. }
  2886. }
  2887. //校验哪个优先级有订单
  2888. Dictionary<string, string> designIds = new Dictionary<string, string>();
  2889. foreach (string key in shop_orders.Keys)
  2890. {
  2891. List<string> ids = null;
  2892. shop_orders.TryGetValue(key, out ids);
  2893. //id为shopid
  2894. foreach (string id in ids)
  2895. {
  2896. Dictionary<string, int> list = null;
  2897. Dictionary<string, string> desing = null;
  2898. map.TryGetValue(id, out list);
  2899. design_orders.TryGetValue(id, out desing);
  2900. if (list != null && desing != null)
  2901. {
  2902. foreach (var item in desing)
  2903. {
  2904. int count = 0;
  2905. if (list.ContainsKey(item.Value))
  2906. {
  2907. list.TryGetValue(item.Value, out count);
  2908. if (count > 0)
  2909. {
  2910. designIds[id] = item.Value;
  2911. break;
  2912. }
  2913. }
  2914. }
  2915. }
  2916. }
  2917. if (designIds.Count > 0)
  2918. {
  2919. break;
  2920. }
  2921. }
  2922. DataTable table = new DataTable();
  2923. table.Columns.Add("tid", typeof(string));
  2924. table.Columns.Add("ctid", typeof(string));
  2925. table.Columns.Add("seller_nick", typeof(string));
  2926. table.Columns.Add("productName", typeof(string));
  2927. table.Columns.Add("pay_time", typeof(string));
  2928. table.Columns.Add("seller_memo", typeof(string));
  2929. if (designIds.Count > 0)
  2930. {
  2931. string shopId = "";
  2932. string productId = "";
  2933. foreach (var designInfo in designIds)
  2934. {
  2935. shopId = designInfo.Key;
  2936. productId = designInfo.Value;
  2937. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  2938. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  2939. if (dt.Rows.Count > 0)
  2940. {
  2941. foreach (DataRow row in dt.Rows)
  2942. {
  2943. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  2944. {
  2945. DataRow data = table.NewRow();
  2946. data["ctid"] = row["ctid"].ToString();
  2947. data["tid"] = row["tid"].ToString();
  2948. data["seller_nick"] = ceErpShop.ShopName;
  2949. data["pay_time"] = row["pay_time"].ToString();
  2950. data["seller_memo"] = row["seller_memo"].ToString();
  2951. data["productName"] = ceErpProduct.PType;
  2952. table.Rows.Add(data);
  2953. }
  2954. }
  2955. }
  2956. }
  2957. }
  2958. writeGridDataTableJson(table.Rows.Count, table);
  2959. }
  2960. private object rushLockObject = new object();
  2961. public void set_erp_grabingorder()
  2962. {
  2963. if (UrlPostParmsCheck("ctid"))
  2964. {
  2965. int total = CurrentUser.User.Person.Total;
  2966. int userId = CurrentUser.User.ID;
  2967. int noFinish = CurrentUser.User.Person.NoFinish;
  2968. int finalization = CurrentUser.User.Person.Finalization;
  2969. string eids = GetPostString("ctid");
  2970. string key = "RushKey_" + userId;
  2971. int count = 0;
  2972. if (erpRedis.RedisHelper.KeyExists(key))
  2973. {
  2974. string redisCount = erpRedis.RedisHelper.StringGet(key);
  2975. if (redisCount != null)
  2976. {
  2977. count = Convert.ToInt32(redisCount);
  2978. }
  2979. }
  2980. if (count >= total)
  2981. {
  2982. returnErrorMsg("半小时内已经抢" + total + "单");
  2983. return;
  2984. }
  2985. string[] ctidlist = eids.Split(',');
  2986. if (count + ctidlist.Length > total)
  2987. {
  2988. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  2989. return;
  2990. }
  2991. int itag = 0;
  2992. lock (rushLockObject)
  2993. {
  2994. if (ctidlist.Length > 0)
  2995. {
  2996. string[] dtList = new string[ctidlist.Length];
  2997. for (int i = 0; i < ctidlist.Length; i++)
  2998. {
  2999. dtList[i] = "'" + ctidlist[i] + "'";
  3000. }
  3001. 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"));
  3002. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3003. if (dt_user.Rows.Count > 0)
  3004. {
  3005. int doing = 0;//未定稿
  3006. int finish = 0;//已完成
  3007. foreach (DataRow dr in dt_user.Rows)
  3008. {
  3009. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3010. {
  3011. doing++;
  3012. }
  3013. else
  3014. {
  3015. finish++;
  3016. }
  3017. }
  3018. if (doing >= noFinish)
  3019. {
  3020. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3021. return;
  3022. }
  3023. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3024. {
  3025. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3026. return;
  3027. }
  3028. }
  3029. //校验选择单子状态
  3030. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3031. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3032. if (dt.Rows.Count > 0)
  3033. {
  3034. List<string> list = new List<string>();
  3035. foreach (DataRow dr in dt.Rows)
  3036. {
  3037. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3038. {
  3039. list.Add(dr["ctid"].ToString());
  3040. }
  3041. }
  3042. if (list.Count > 0)
  3043. {
  3044. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3045. return;
  3046. }
  3047. }
  3048. foreach (string ctid in ctidlist)
  3049. {
  3050. CeErpTradeCell entity = null;
  3051. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3052. if (entity != null)
  3053. {
  3054. entity.OrderState = 3;
  3055. entity.DesignUserId = CurrentUser.UserID;
  3056. entity.WaitDesignTime = DateTime.Now;
  3057. entity.StartDesignTime = DateTime.Now;
  3058. entity.Update();
  3059. commonHelper.UpdateRelationOrder(entity.ctid);
  3060. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3061. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3062. itag++;
  3063. }
  3064. }
  3065. }
  3066. }
  3067. count += ctidlist.Length;
  3068. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3069. if (itag == 0)
  3070. returnErrorMsg("没有找到相关订单");
  3071. else
  3072. returnSuccessMsg("抢单成功!");
  3073. return;
  3074. }
  3075. }
  3076. public void get_erp_waitorderlist()
  3077. {
  3078. DataStruct dStruct = GetPostStruct();
  3079. List<string> lw = new List<string>();
  3080. string tid = GetPostString("ctid");
  3081. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3082. string shopname = GetPostString("shopname");
  3083. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3084. string buyernick = GetPostString("buyer_nick");
  3085. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3086. string customer = GetPostString("customer");
  3087. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3088. string design = GetPostString("design");
  3089. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3090. string orderState = GetPostString("orderState");
  3091. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3092. string supplier = GetPostString("supplier");
  3093. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3094. string sellermemo = GetPostString("seller_memo");
  3095. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3096. string otherMemo = GetPostString("otherMemo");
  3097. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3098. string address = GetPostString("address");
  3099. 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));
  3100. string date1 = GetPostString("date1");
  3101. string date2 = GetPostString("date2");
  3102. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3103. if (dw.Length > 0) lw.Add(dw);
  3104. string price1 = GetPostString("price1");
  3105. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3106. string price2 = GetPostString("price2");
  3107. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3108. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3109. lw.Add(string.Format("IsSample != 2 "));
  3110. lw.Add(string.Format("OrderState = 5 "));
  3111. lw.Add(string.Format("IsRefund<={0}", 1));
  3112. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3113. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3114. string pagesize = GetPostString("pagesize");
  3115. if (pagesize != null)
  3116. {
  3117. dStruct.PageSize = 200;
  3118. }
  3119. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3120. foreach (DataRow dr in dt.Rows)
  3121. {
  3122. 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();
  3123. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3124. {
  3125. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3126. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3127. entity.SupplierId = suid;
  3128. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3129. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3130. entity.Update();
  3131. }
  3132. }
  3133. writeGridDataTableJson(dStruct.TotalCount, dt);
  3134. }
  3135. public void get_erp_supplierwaitorderlist()
  3136. {
  3137. DataStruct dStruct = GetPostStruct();
  3138. List<string> lw = new List<string>();
  3139. string tid = GetPostString("ctid");
  3140. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3141. string shopname = GetPostString("shopname");
  3142. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3143. string sellermemo = GetPostString("seller_memo");
  3144. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3145. string date1 = GetPostString("date1");
  3146. string date2 = GetPostString("date2");
  3147. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3148. if (dw.Length > 0) lw.Add(dw);
  3149. lw.Add(string.Format("OrderState = 5 "));
  3150. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3151. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3152. {
  3153. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3154. }
  3155. string supplier = GetPostString("supplier");
  3156. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3157. {
  3158. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3159. }
  3160. lw.Add(string.Format("IsRefund<={0}", 1));
  3161. dStruct.Order = "FinishDesignTime desc";
  3162. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3163. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3164. if (dt != null)
  3165. {
  3166. foreach (DataRow dr in dt.Rows)
  3167. {
  3168. 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();
  3169. }
  3170. }
  3171. writeGridDataTableJson(dStruct.TotalCount, dt);
  3172. }
  3173. public void upd_erp_verifytosupplier()
  3174. {
  3175. if (UrlPostParmsCheck("ctid"))
  3176. {
  3177. string eids = GetPostString("ctid");
  3178. CeErpTradeCell entity = null;
  3179. string[] eidsList = eids.Split(',');
  3180. if (eidsList.Length <= 0)
  3181. {
  3182. returnErrorMsg("订单号不能空");
  3183. return;
  3184. }
  3185. List<string> tLst = new List<string>();
  3186. foreach (string ctidstr in eidsList)
  3187. {
  3188. tLst.Add("'" + ctidstr + "'");
  3189. CeErpDataSendOrderInfo.createObject(ctidstr);
  3190. }
  3191. string needtids = string.Join(",", tLst.ToArray());
  3192. StringBuilder sql = new StringBuilder();
  3193. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3194. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3195. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3196. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3197. returnSuccessMsg("操作成功!");
  3198. return;
  3199. /**foreach (string ctidstr in eidsList)
  3200. {
  3201. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3202. if (entity != null)
  3203. {
  3204. if (entity.SupplierId == 0)
  3205. {
  3206. continue;
  3207. }
  3208. entity.IsVerifyToSupplier = true;
  3209. if (entity.IsReturn == 1) //1是供应商打回
  3210. {
  3211. entity.IsReturn = 0;
  3212. }
  3213. entity.FinishPlaceTime = DateTime.Now;
  3214. entity.PlaceUserId = CurrentUser.UserID;
  3215. entity.Update();
  3216. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3217. }
  3218. }
  3219. returnSuccessMsg("操作成功!");
  3220. return;**/
  3221. }
  3222. }
  3223. public void upd_erp_supplierback()
  3224. {
  3225. if (UrlPostParmsCheck("ctid"))
  3226. {
  3227. string eid = GetPostString("ctid");
  3228. string reason = GetPostString("returnreason");
  3229. CeErpTradeCell entity = null;
  3230. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3231. if (entity != null)
  3232. {
  3233. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3234. {
  3235. string key = "return_order_" + entity.SupplierId;
  3236. List<string> list = new List<string>();
  3237. if (RedisHelper.HasKey(key))
  3238. {
  3239. object data = RedisHelper.StringGet(key);
  3240. list = Convert.ToString(data).Split(',').ToList();
  3241. }
  3242. list.Add(eid);
  3243. RedisHelper.StringSet(key, string.Join(",", list));
  3244. }
  3245. entity.IsVerifyToSupplier = false;
  3246. entity.IsReturn = 1;
  3247. entity.ReturnTime = DateTime.Now;
  3248. entity.ReturnReason = reason;
  3249. if (entity.OrderState == 6)
  3250. {
  3251. entity.OrderState = 5;
  3252. }
  3253. entity.Update();
  3254. CeErpSukuraData.createInfo(entity.ctid, 5);
  3255. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3256. returnSuccessMsg("操作成功!");
  3257. return;
  3258. }
  3259. returnErrorMsg("找不到订单记录");
  3260. }
  3261. }
  3262. public void upd_erp_toaftersaleorder()
  3263. {
  3264. if (UrlPostParmsCheck("ctid"))
  3265. {
  3266. string eid = GetPostString("ctid");
  3267. string reason = GetPostString("returnreason");
  3268. CeErpTradeCell entity = null;
  3269. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3270. if (entity != null)
  3271. {
  3272. if (entity.isAfterSaleOrder != 1)
  3273. {
  3274. returnErrorMsg("带S的售后单才能打回给售后");
  3275. return;
  3276. }
  3277. if (entity.OrderState >= 5)
  3278. {
  3279. returnErrorMsg("已经设计完成了不能打回给售后");
  3280. return;
  3281. }
  3282. entity.OrderState = 0;
  3283. entity.IsReturn = 3;
  3284. entity.ReturnTime = DateTime.Now;
  3285. entity.ReturnReason = reason;
  3286. entity.Update();
  3287. CeErpSukuraData.createInfo(entity.ctid, 5);
  3288. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3289. returnSuccessMsg("操作成功!");
  3290. return;
  3291. }
  3292. returnErrorMsg("找不到订单记录");
  3293. }
  3294. }
  3295. public void upd_erp_aftersaletodesign()
  3296. {
  3297. if (UrlPostParmsCheck("ctid"))
  3298. {
  3299. string eid = GetPostString("ctid");
  3300. CeErpTradeCell entity = null;
  3301. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3302. if (entity != null)
  3303. {
  3304. entity.OrderState = 3;
  3305. entity.IsReturn = 0;
  3306. entity.Update();
  3307. CeErpSukuraData.createInfo(entity.ctid, 5);
  3308. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3309. returnSuccessMsg("操作成功!");
  3310. return;
  3311. }
  3312. returnErrorMsg("找不到订单记录");
  3313. }
  3314. }
  3315. public void assign_erp_supplier()
  3316. {
  3317. if (UrlPostParmsCheck("ctid"))
  3318. {
  3319. string eids = GetPostString("ctid");
  3320. int sid = GetPostInt("SupplierName");
  3321. string fromTag = GetPostString("tag");
  3322. string[] eidList = eids.Split(',');
  3323. if (eidList.Length <= 0)
  3324. {
  3325. returnErrorMsg("指派不能为空");
  3326. return;
  3327. }
  3328. string errMsg = "";
  3329. string suname = commonHelper.getSupplierNameById(sid);
  3330. foreach (string ctid in eidList)
  3331. {
  3332. CeErpTradeCell entity = null;
  3333. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3334. if (entity != null)
  3335. {
  3336. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3337. {
  3338. errMsg += (ctid + "指派失败!!!");
  3339. continue;
  3340. }
  3341. entity.SupplierId = sid;
  3342. entity.Update();
  3343. commonHelper.UpdateRelationOrder(entity.ctid);
  3344. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3345. if (entity.OrderState >= 6)
  3346. {
  3347. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3348. //{
  3349. // string msl = entity.MakeSupplier;
  3350. // string[] mslist = msl.Split(',');
  3351. // 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);
  3352. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3353. //}
  3354. //else
  3355. //{
  3356. StringBuilder sql = new StringBuilder();
  3357. 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);
  3358. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3359. //}
  3360. }
  3361. }
  3362. else
  3363. {
  3364. continue;
  3365. }
  3366. }
  3367. if (errMsg.Length > 0)
  3368. {
  3369. returnErrorMsg(errMsg);
  3370. return;
  3371. }
  3372. returnSuccessMsg("操作成功!");
  3373. return;
  3374. }
  3375. }
  3376. public void assign_erp_makesupplier()
  3377. {
  3378. if (UrlPostParmsCheck("ctid"))
  3379. {
  3380. string eids = GetPostString("ctid");
  3381. string sname = GetPostString("SupplierName");
  3382. string[] eidList = eids.Split(',');
  3383. if (eidList.Length <= 0)
  3384. {
  3385. returnErrorMsg("指派不能为空");
  3386. return;
  3387. }
  3388. List<string> tLst = new List<string>();
  3389. foreach (string ctid in eidList)
  3390. {
  3391. CeErpTradeCell entity = null;
  3392. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3393. if (entity != null)
  3394. {
  3395. entity.MakeSupplier = sname;
  3396. entity.Update();
  3397. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3398. tLst.Add("'" + ctid + "'");
  3399. }
  3400. else
  3401. {
  3402. continue;
  3403. }
  3404. }
  3405. string ctids = string.Join(",", tLst.ToArray());
  3406. StringBuilder sql2 = new StringBuilder();
  3407. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3408. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3409. returnSuccessMsg("操作成功!");
  3410. return;
  3411. }
  3412. }
  3413. public void ins_erp_returnreason()
  3414. {
  3415. if (UrlPostParmsCheck("ctid"))
  3416. {
  3417. string eid = GetPostString("ctid");
  3418. CeErpTradeCell entity = null;
  3419. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3420. string userpost = CurrentUser.UserPost.Post.Code;
  3421. if (entity != null)
  3422. {
  3423. bool isPlace = false;
  3424. if (entity.OrderState > 6)
  3425. {
  3426. returnErrorMsg("已发货无法打回!");
  3427. return;
  3428. }
  3429. if (entity.OrderState == 6)
  3430. {
  3431. isPlace = true;
  3432. }
  3433. bool isNeedUpdateCell2 = false;
  3434. if (entity.OrderState >= 6)
  3435. {
  3436. isNeedUpdateCell2 = true;
  3437. }
  3438. int returnTag = 2;
  3439. if (userpost == "Supplier")
  3440. {
  3441. returnTag = 1;
  3442. }
  3443. if (entity.IsXianHuo == 0)
  3444. {
  3445. if (returnTag == 2)
  3446. {
  3447. int toType = GetPostInt("totype");
  3448. if (toType == 1)
  3449. {
  3450. entity.OrderState = 0;
  3451. entity.ReturnUserType = 1;
  3452. string clearman = GetPostString("clearman");
  3453. if (!string.IsNullOrEmpty(clearman))
  3454. {
  3455. entity.DesignUserId = 0;
  3456. }
  3457. }
  3458. else
  3459. {
  3460. entity.OrderState = 3;
  3461. entity.ReturnUserType = 2;
  3462. }
  3463. entity.IsReadTag = 1;
  3464. }
  3465. else if (returnTag == 1)
  3466. {
  3467. entity.OrderState = 5;
  3468. }
  3469. entity.IsVerifyToSupplier = false;
  3470. }
  3471. if (entity.IsXianHuo == 1)
  3472. {
  3473. entity.OrderState = 5;
  3474. }
  3475. entity.UnusualTag = 0;
  3476. entity.UnusualTime = null;
  3477. entity.UnusualCon = "";
  3478. entity.IsReturn = returnTag;
  3479. entity.ReturnTime = DateTime.Now;
  3480. entity.ReturnReason = GetPostString("returnreason");
  3481. entity.Update();
  3482. if (entity.OrderState == 3)
  3483. {
  3484. ApiVo apiVo = new ApiVo();
  3485. apiVo.orderNumber = entity.ctid;
  3486. apiVo.actionName = "rebutDesign";
  3487. apiVo.orderRemarks = entity.ReturnReason;
  3488. designHelper.API_WorkCore(apiVo);//rebutDesign
  3489. }
  3490. CeErpSukuraData.createInfo(entity.ctid, 5);
  3491. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3492. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3493. if (isPlace)
  3494. {
  3495. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3496. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3497. if (dth != null && dth.Rows.Count > 0)
  3498. {
  3499. dataSendOrderBean dataSendOrderBean = null;
  3500. foreach (DataRow item in dth.Rows)
  3501. {
  3502. try
  3503. {
  3504. dataSendOrderBean = new dataSendOrderBean();
  3505. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3506. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3507. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3508. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3509. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3510. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3511. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3512. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3513. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3514. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3515. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3516. dataSendOrderBean.Radio1723534706288 = "打回";
  3517. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3518. if (result != null)
  3519. {
  3520. if ("0".Equals(result.errcode))
  3521. {
  3522. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3523. }
  3524. else
  3525. {
  3526. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3527. }
  3528. }
  3529. }
  3530. catch (Exception ex)
  3531. {
  3532. }
  3533. }
  3534. }
  3535. }
  3536. if (isNeedUpdateCell2)
  3537. {
  3538. if (entity.MakeSupplier.IndexOf(",") != -1)
  3539. {
  3540. StringBuilder sql2 = new StringBuilder();
  3541. 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);
  3542. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3543. }
  3544. else
  3545. {
  3546. StringBuilder sql2 = new StringBuilder();
  3547. 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);
  3548. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3549. }
  3550. }
  3551. returnSuccessMsg("操作成功!");
  3552. return;
  3553. }
  3554. returnErrorMsg("找不到订单记录");
  3555. }
  3556. }
  3557. public void cyt_erp_returnreason()
  3558. {
  3559. if (UrlPostParmsCheck("ctid"))
  3560. {
  3561. string eid = GetPostString("ctid");
  3562. CeErpTradeCell entity = null;
  3563. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3564. string userpost = CurrentUser.UserPost.Post.Code;
  3565. if (entity != null)
  3566. {
  3567. if (entity.OrderState > 6)
  3568. {
  3569. returnErrorMsg("已发货无法打回!");
  3570. return;
  3571. }
  3572. JObject jsonObject = new JObject
  3573. {
  3574. { "Userid", "77886" },
  3575. { "Pwd", "lt666888" },
  3576. { "LTOrderId",eid }
  3577. };
  3578. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3579. JObject jsonObjects = JObject.Parse(response);
  3580. string msg = (string)jsonObjects["msg"];
  3581. if (msg != "取消成功")
  3582. {
  3583. returnErrorMsg(msg);
  3584. return;
  3585. }
  3586. bool isNeedUpdateCell2 = false;
  3587. if (entity.OrderState >= 6)
  3588. {
  3589. isNeedUpdateCell2 = true;
  3590. }
  3591. int returnTag = 2;
  3592. if (userpost == "Supplier")
  3593. {
  3594. returnTag = 1;
  3595. }
  3596. if (entity.IsXianHuo == 0)
  3597. {
  3598. if (returnTag == 2)
  3599. {
  3600. int toType = GetPostInt("totype");
  3601. if (toType == 1)
  3602. {
  3603. entity.OrderState = 0;
  3604. entity.ReturnUserType = 1;
  3605. }
  3606. else
  3607. {
  3608. entity.OrderState = 4;
  3609. entity.ReturnUserType = 2;
  3610. }
  3611. entity.IsReadTag = 1;
  3612. }
  3613. else if (returnTag == 1)
  3614. {
  3615. entity.OrderState = 5;
  3616. }
  3617. entity.IsVerifyToSupplier = false;
  3618. }
  3619. entity.UnusualTag = 0;
  3620. entity.UnusualTime = null;
  3621. entity.UnusualCon = "";
  3622. entity.IsReturn = returnTag;
  3623. entity.ReturnTime = DateTime.Now;
  3624. entity.ReturnReason = GetPostString("returnreason");
  3625. entity.Update();
  3626. if (entity.OrderState == 4)
  3627. {
  3628. ApiVo apiVo = new ApiVo();
  3629. apiVo.orderNumber = entity.ctid;
  3630. apiVo.actionName = "rebutDesign";
  3631. apiVo.orderRemarks = entity.ReturnReason;
  3632. designHelper.API_WorkCore(apiVo);//rebutDesign
  3633. }
  3634. CeErpSukuraData.createInfo(entity.ctid, 5);
  3635. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3636. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3637. if (isNeedUpdateCell2)
  3638. {
  3639. if (entity.MakeSupplier.IndexOf(",") != -1)
  3640. {
  3641. StringBuilder sql2 = new StringBuilder();
  3642. 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);
  3643. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3644. }
  3645. else
  3646. {
  3647. StringBuilder sql2 = new StringBuilder();
  3648. 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);
  3649. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3650. }
  3651. }
  3652. returnSuccessMsg("操作成功!");
  3653. return;
  3654. }
  3655. returnErrorMsg("找不到订单记录");
  3656. }
  3657. }
  3658. public void upd_erp_xianhuoreturntag()
  3659. {
  3660. if (UrlPostParmsCheck("ctid"))
  3661. {
  3662. string eids = GetPostString("ctid");
  3663. string[] ctids = eids.Split(',');
  3664. foreach (string ctid in ctids)
  3665. {
  3666. CeErpTradeCell entity = null;
  3667. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3668. if (entity != null)
  3669. {
  3670. entity.IsReturn = 0;
  3671. entity.Update();
  3672. CeErpSukuraData.createInfo(entity.ctid, 5);
  3673. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3674. }
  3675. }
  3676. returnSuccessMsg("操作成功!");
  3677. return;
  3678. }
  3679. }
  3680. public void get_erp_waitdeliverylist()
  3681. {
  3682. DataStruct dStruct = GetPostStruct();
  3683. List<string> lw = new List<string>();
  3684. string tid = GetPostString("ctid");
  3685. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3686. string shopname = GetPostString("shopname");
  3687. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3688. string buyernick = GetPostString("buyer_nick");
  3689. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3690. //if (tid.Length == 0 && buyernick.Length == 0)
  3691. //{
  3692. // lw.Add(string.Format("IsRefund<={0}", 1));
  3693. //}
  3694. string customer = GetPostString("customer");
  3695. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3696. string design = GetPostString("design");
  3697. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3698. string orderState = GetPostString("orderState");
  3699. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3700. string address = GetPostString("address");
  3701. 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));
  3702. string sellermemo = GetPostString("seller_memo");
  3703. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3704. string supplier = GetPostString("supplier");
  3705. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3706. string OrderArea = GetPostString("order_area");
  3707. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3708. string placedate1 = GetPostString("placedate1");
  3709. string placedate2 = GetPostString("placedate2");
  3710. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3711. if (fdw.Length > 0) lw.Add(fdw);
  3712. string price1 = GetPostString("price1");
  3713. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3714. string price2 = GetPostString("price2");
  3715. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3716. string unusualCon = GetPostString("unusualcon");
  3717. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3718. string otherMemo = GetPostString("otherMemo");
  3719. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3720. string posTag = CurrentUser.UserPost.Post.Code;
  3721. if (posTag == "Supplier")
  3722. {
  3723. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3724. }
  3725. lw.Add(string.Format("OrderState = 6 "));
  3726. lw.Add(string.Format("type != 'PDD' "));
  3727. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3728. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3729. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3730. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3731. writeGridDataTableJson(dStruct.TotalCount, dt);
  3732. }
  3733. public void get_erp_pddderiving()
  3734. {
  3735. DataStruct dStruct = GetPostStruct();
  3736. List<string> lw = new List<string>();
  3737. string tid = GetPostString("ctid");
  3738. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid));
  3739. string shopname = GetPostString("shopname");
  3740. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3741. string buyernick = GetPostString("buyer_nick");
  3742. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3743. //if (tid.Length == 0 && buyernick.Length == 0)
  3744. //{
  3745. // lw.Add(string.Format("IsRefund<={0}", 1));
  3746. //}
  3747. string customer = GetPostString("customer");
  3748. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3749. string design = GetPostString("design");
  3750. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3751. string orderState = GetPostString("orderState");
  3752. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3753. string address = GetPostString("address");
  3754. 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));
  3755. string sellermemo = GetPostString("seller_memo");
  3756. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3757. string supplier = GetPostString("supplier");
  3758. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3759. string OrderArea = GetPostString("order_area");
  3760. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3761. string placedate1 = GetPostString("placedate1");
  3762. string placedate2 = GetPostString("placedate2");
  3763. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3764. if (fdw.Length > 0) lw.Add(fdw);
  3765. string price1 = GetPostString("price1");
  3766. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3767. string price2 = GetPostString("price2");
  3768. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3769. string unusualCon = GetPostString("unusualcon");
  3770. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3771. string posTag = CurrentUser.UserPost.Post.Code;
  3772. if (posTag == "Supplier")
  3773. {
  3774. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3775. }
  3776. lw.Add(string.Format("OrderState = 6 "));
  3777. lw.Add(string.Format("type = 'PDD' "));
  3778. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3779. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3780. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3781. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3782. writeGridDataTableJson(dStruct.TotalCount, dt);
  3783. }
  3784. public void get_erp_jdderiving()
  3785. {
  3786. DataStruct dStruct = GetPostStruct();
  3787. List<string> lw = new List<string>();
  3788. string tid = GetPostString("ctid");
  3789. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  3790. string shopname = GetPostString("shopname");
  3791. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3792. string buyernick = GetPostString("buyer_nick");
  3793. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3794. //if (tid.Length == 0 && buyernick.Length == 0)
  3795. //{
  3796. // lw.Add(string.Format("IsRefund<={0}", 1));
  3797. //}
  3798. string customer = GetPostString("customer");
  3799. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3800. string design = GetPostString("design");
  3801. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3802. string orderState = GetPostString("orderState");
  3803. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3804. string address = GetPostString("address");
  3805. 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));
  3806. string sellermemo = GetPostString("seller_memo");
  3807. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3808. string supplier = GetPostString("supplier");
  3809. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3810. string OrderArea = GetPostString("order_area");
  3811. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3812. string placedate1 = GetPostString("placedate1");
  3813. string placedate2 = GetPostString("placedate2");
  3814. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3815. if (fdw.Length > 0) lw.Add(fdw);
  3816. string price1 = GetPostString("price1");
  3817. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3818. string price2 = GetPostString("price2");
  3819. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3820. string unusualCon = GetPostString("unusualcon");
  3821. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3822. string posTag = CurrentUser.UserPost.Post.Code;
  3823. if (posTag == "Supplier")
  3824. {
  3825. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3826. }
  3827. lw.Add(string.Format("OrderState = 6 "));
  3828. lw.Add(string.Format("type = 'JD' "));
  3829. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3830. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3831. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3832. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3833. writeGridDataTableJson(dStruct.TotalCount, dt);
  3834. }
  3835. public void get_erp_demoorderlist()
  3836. {
  3837. DataStruct dStruct = GetPostStruct();
  3838. List<string> lw = new List<string>();
  3839. string tid = GetPostString("ctid");
  3840. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  3841. string shopname = GetPostString("shopname");
  3842. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3843. string buyernick = GetPostString("buyer_nick");
  3844. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3845. string customer = GetPostString("customer");
  3846. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3847. string design = GetPostString("design");
  3848. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3849. string orderState = GetPostString("orderState");
  3850. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3851. string address = GetPostString("address");
  3852. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3853. string sellermemo = GetPostString("seller_memo");
  3854. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3855. string supplier = GetPostString("supplier");
  3856. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3857. string OrderArea = GetPostString("order_area");
  3858. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3859. string date1 = GetPostString("date1");
  3860. string date2 = GetPostString("date2");
  3861. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3862. if (dw.Length > 0) lw.Add(dw);
  3863. string price1 = GetPostString("price1");
  3864. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3865. string price2 = GetPostString("price2");
  3866. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3867. string posTag = CurrentUser.UserPost.Post.Code;
  3868. if (posTag == "Supplier")
  3869. {
  3870. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3871. }
  3872. //lw.Add(string.Format("OrderState = 6 "));
  3873. lw.Add(string.Format("IsSample={0}", 3));
  3874. lw.Add(string.Format("IsRefund<={0}", 1));
  3875. dStruct.Order = "pay_time desc";
  3876. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3877. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3878. writeGridDataTableJson(dStruct.TotalCount, dt);
  3879. }
  3880. public void save_erp_checkmemo()
  3881. {
  3882. if (UrlPostParmsCheck("ctid"))
  3883. {
  3884. string ctid = GetPostString("ctid");
  3885. CeErpTradeCell entity = null;
  3886. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3887. if (entity != null)
  3888. {
  3889. entity.CheckMemo = GetPostString("CheckMemo");
  3890. entity.Update();
  3891. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  3892. if (trade != null)
  3893. {
  3894. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  3895. }
  3896. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  3897. returnSuccessMsg("保存成功!");
  3898. return;
  3899. }
  3900. returnErrorMsg("找不到记录");
  3901. }
  3902. }
  3903. public void get_erp_returnlist()
  3904. {
  3905. DataStruct dStruct = GetPostStruct();
  3906. List<string> lw = new List<string>();
  3907. string tid = GetPostString("ctid");
  3908. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3909. string shopname = GetPostString("shopname");
  3910. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3911. string buyernick = GetPostString("buyer_nick");
  3912. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3913. string customer = GetPostString("customer");
  3914. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3915. string design = GetPostString("design");
  3916. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3917. string orderState = GetPostString("orderState");
  3918. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3919. string address = GetPostString("address");
  3920. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  3921. string sellermemo = GetPostString("seller_memo");
  3922. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3923. string supplier = GetPostString("supplier");
  3924. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3925. string date1 = GetPostString("date1");
  3926. string date2 = GetPostString("date2");
  3927. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3928. if (dw.Length > 0) lw.Add(dw);
  3929. string bdate1 = GetPostString("backdate1");
  3930. string bdate2 = GetPostString("backdate2");
  3931. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3932. if (dw_back.Length > 0) lw.Add(dw_back);
  3933. string price1 = GetPostString("price1");
  3934. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3935. string price2 = GetPostString("price2");
  3936. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3937. lw.Add(string.Format("IsReturn>0"));
  3938. lw.Add(string.Format("IsXianHuo=0"));
  3939. lw.Add(string.Format("IsReturn!=3"));
  3940. string backtype = GetPostString("backtype");
  3941. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  3942. dStruct.Order = "FinishDesignTime desc";
  3943. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3944. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3945. writeGridDataTableJson(dStruct.TotalCount, dt);
  3946. }
  3947. public void get_erp_today_sumreturn()
  3948. {
  3949. DataStruct dStruct = GetPostStruct();
  3950. List<string> lw = new List<string>();
  3951. string bdate1 = GetPostString("returnTimeS");
  3952. string bdate2 = GetPostString("returnTimeE");
  3953. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  3954. if (dw_back.Length > 0) lw.Add(dw_back);
  3955. lw.Add(string.Format("IsReturn=0"));
  3956. lw.Add(string.Format("IsXianHuo=0"));
  3957. string mainWhere = string.Join(" and ", lw.ToArray());
  3958. string sql = "";
  3959. if (dw_back.Length > 0)
  3960. {
  3961. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  3962. }
  3963. else
  3964. {
  3965. 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 + "'";
  3966. }
  3967. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3968. decimal total = 0, today_finish = 0;
  3969. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  3970. {
  3971. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  3972. }
  3973. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  3974. {
  3975. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  3976. }
  3977. var res = new
  3978. {
  3979. data = total,
  3980. data1 = today_finish,
  3981. };
  3982. string ro_jsond = JsonConvert.SerializeObject(res);
  3983. returnSuccess(ro_jsond);
  3984. return;
  3985. }
  3986. public void get_erp_allreturnlist()
  3987. {
  3988. DataStruct dStruct = GetPostStruct();
  3989. List<string> lw = new List<string>();
  3990. string tid = GetPostString("ctid");
  3991. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  3992. string shopname = GetPostString("shopname");
  3993. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  3994. string buyernick = GetPostString("buyer_nick");
  3995. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  3996. string customer = GetPostString("customer");
  3997. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3998. string design = GetPostString("design");
  3999. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4000. string orderState = GetPostString("orderState");
  4001. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4002. string address = GetPostString("address");
  4003. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4004. string sellermemo = GetPostString("seller_memo");
  4005. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4006. string supplier = GetPostString("supplier");
  4007. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4008. string date1 = GetPostString("date1");
  4009. string date2 = GetPostString("date2");
  4010. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4011. if (dw.Length > 0) lw.Add(dw);
  4012. string bdate1 = GetPostString("backdate1");
  4013. string bdate2 = GetPostString("backdate2");
  4014. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4015. if (dw_back.Length > 0) lw.Add(dw_back);
  4016. string price1 = GetPostString("price1");
  4017. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4018. string price2 = GetPostString("price2");
  4019. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4020. string backreason = GetPostString("backreason");
  4021. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4022. lw.Add(string.Format("IsXianHuo=0"));
  4023. lw.Add(string.Format("ReturnTime != ''"));
  4024. string backtype = GetPostString("backtype");
  4025. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4026. dStruct.Order = "FinishDesignTime desc";
  4027. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4028. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4029. writeGridDataTableJson(dStruct.TotalCount, dt);
  4030. }
  4031. public void get_erp_aftersalereturnlist()
  4032. {
  4033. DataStruct dStruct = GetPostStruct();
  4034. List<string> lw = new List<string>();
  4035. string tid = GetPostString("ctid");
  4036. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4037. string shopname = GetPostString("shopname");
  4038. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4039. string buyernick = GetPostString("buyer_nick");
  4040. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4041. string customer = GetPostString("customer");
  4042. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4043. string design = GetPostString("design");
  4044. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4045. string orderState = GetPostString("orderState");
  4046. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4047. string address = GetPostString("address");
  4048. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4049. string sellermemo = GetPostString("seller_memo");
  4050. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4051. string supplier = GetPostString("supplier");
  4052. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4053. string date1 = GetPostString("date1");
  4054. string date2 = GetPostString("date2");
  4055. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4056. if (dw.Length > 0) lw.Add(dw);
  4057. string bdate1 = GetPostString("backdate1");
  4058. string bdate2 = GetPostString("backdate2");
  4059. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4060. if (dw_back.Length > 0) lw.Add(dw_back);
  4061. string price1 = GetPostString("price1");
  4062. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4063. string price2 = GetPostString("price2");
  4064. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4065. lw.Add(string.Format("IsReturn=3"));
  4066. string backtype = GetPostString("backtype");
  4067. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4068. string backreason = GetPostString("backreason");
  4069. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4070. dStruct.Order = "ReturnTime desc";
  4071. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4072. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4073. writeGridDataTableJson(dStruct.TotalCount, dt);
  4074. }
  4075. public void get_erp_xianhuoreturnlist()
  4076. {
  4077. DataStruct dStruct = GetPostStruct();
  4078. List<string> lw = new List<string>();
  4079. string tid = GetPostString("ctid");
  4080. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4081. string shopname = GetPostString("shopname");
  4082. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4083. string buyernick = GetPostString("buyer_nick");
  4084. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4085. string customer = GetPostString("customer");
  4086. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4087. string design = GetPostString("design");
  4088. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4089. string orderState = GetPostString("orderState");
  4090. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4091. string address = GetPostString("address");
  4092. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4093. string sellermemo = GetPostString("seller_memo");
  4094. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4095. string supplier = GetPostString("supplier");
  4096. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4097. string OrderArea = GetPostString("order_area");
  4098. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4099. string date1 = GetPostString("date1");
  4100. string date2 = GetPostString("date2");
  4101. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4102. if (dw.Length > 0) lw.Add(dw);
  4103. string price1 = GetPostString("price1");
  4104. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4105. string price2 = GetPostString("price2");
  4106. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4107. string posTag = CurrentUser.UserPost.Post.Code;
  4108. if (posTag == "Supplier")
  4109. {
  4110. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4111. }
  4112. lw.Add(string.Format("OrderState=6 "));
  4113. lw.Add(string.Format("IsXianHuo=1 "));
  4114. lw.Add(string.Format("IsReturn>0 "));
  4115. lw.Add(string.Format("IsReturn!=3"));
  4116. lw.Add(string.Format("IsRefund<={0}", 1));
  4117. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4118. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4119. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4120. writeGridDataTableJson(dStruct.TotalCount, dt);
  4121. }
  4122. public void set_erp_orderdelivery()
  4123. {
  4124. if (UrlPostParmsCheck("ctid"))
  4125. {
  4126. string eid = GetPostString("ctid");
  4127. CeErpTradeCell entity = null;
  4128. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4129. if (entity != null)
  4130. {
  4131. if (entity.OrderState >= 7)
  4132. {
  4133. returnErrorMsg("此单已发货,无需重复发货");
  4134. return;
  4135. }
  4136. if (entity.OrderState != 6)
  4137. {
  4138. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4139. return;
  4140. }
  4141. string shop = GetPostString("seller_nick");
  4142. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4143. string comName = GetPostString("comName");
  4144. string comCode = GetPostString("comCode");
  4145. string outSid = GetPostString("outSid");
  4146. string deliveryType = GetPostString("deliveryType");
  4147. string deliveryMemo = GetPostString("deliveryMemo");
  4148. outSid = outSid.Trim();
  4149. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4150. if (mainEn == null)
  4151. {
  4152. returnErrorMsg("找不到原始订单记录");
  4153. return;
  4154. }
  4155. bool isInitOrderDeliv = false;
  4156. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4157. {
  4158. isInitOrderDeliv = true;
  4159. }
  4160. string apires = "";
  4161. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4162. 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)
  4163. {
  4164. apires = "发货成功true";
  4165. }
  4166. else
  4167. {
  4168. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4169. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4170. }
  4171. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4172. {
  4173. entity.OrderState = 7;//发货后订单已发货
  4174. entity.OutSid = outSid;
  4175. entity.MemoOpt = 0;
  4176. entity.Update();
  4177. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4178. commonHelper.UpdateRelationOrder(entity.ctid);
  4179. //还要插入快递信息到 快递信息表
  4180. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4181. exinfo.tid = eid;
  4182. exinfo.out_sid = outSid;
  4183. exinfo.company_code = comCode;
  4184. exinfo.company_name = comName;
  4185. exinfo.delivery_memo = deliveryMemo;
  4186. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4187. exinfo.deliveryType = deliveryType;
  4188. exinfo.Create();
  4189. returnSuccessMsg("发货操作成功!");
  4190. commonHelper.UpdateRelationOrder(entity.ctid);
  4191. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4192. CeErpSukuraData.createInfo(entity.ctid, 4);
  4193. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4194. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4195. }
  4196. else
  4197. {
  4198. string errmsg = commonHelper.KeepChinese(apires);
  4199. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4200. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4201. }
  4202. return;
  4203. }
  4204. returnErrorMsg("找不到订单记录");
  4205. }
  4206. }
  4207. public void set_erp_multidelivery()
  4208. {
  4209. string eids = GetPostString("tids");
  4210. string[] eidList = eids.Split(',');
  4211. if (eidList.Length <= 0)
  4212. {
  4213. returnErrorMsg("发货不能为空");
  4214. return;
  4215. }
  4216. foreach (string ctid in eidList)
  4217. {
  4218. if (ctid.Length <= 0) continue;
  4219. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4220. if (expInfo != null)
  4221. {
  4222. StringBuilder sql = new StringBuilder();
  4223. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4224. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4225. if (dt.Rows.Count > 0)
  4226. {
  4227. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4228. {
  4229. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4230. expInfo.state = "异常";
  4231. expInfo.isMultiDelivery = 1;
  4232. expInfo.Update();
  4233. continue;
  4234. }
  4235. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4236. {
  4237. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4238. expInfo.state = "异常";
  4239. expInfo.Update();
  4240. continue;
  4241. }
  4242. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4243. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4244. bool isInitOrderDeliv = false;
  4245. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4246. {
  4247. isInitOrderDeliv = true;
  4248. expInfo.isMultiDelivery = 1;
  4249. }
  4250. if (ctid.IndexOf("N") != -1)
  4251. {
  4252. StringBuilder sqlbucha = new StringBuilder();
  4253. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4254. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4255. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4256. commonHelper.UpdateRelationOrder(ctid);
  4257. expInfo.delivery_memo = "发货成功";
  4258. expInfo.state = "发货成功";
  4259. expInfo.isMultiDelivery = 1;
  4260. expInfo.Update();
  4261. }
  4262. else
  4263. {
  4264. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4265. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4266. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4267. {
  4268. expInfo.delivery_memo = "发货成功";
  4269. expInfo.state = "发货成功";
  4270. expInfo.isMultiDelivery = 1;
  4271. expInfo.Update();
  4272. commonHelper.UpdateRelationOrder(ctid);
  4273. CeErpSukuraData.createInfo(ctid, 4);
  4274. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4275. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4276. }
  4277. else
  4278. {
  4279. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4280. expInfo.state = "异常";
  4281. expInfo.Update();
  4282. }
  4283. }
  4284. }
  4285. }
  4286. }
  4287. returnSuccessMsg("操作完成");
  4288. }
  4289. public void reset_erp_memoopt()
  4290. {
  4291. if (UrlPostParmsCheck("ctid"))
  4292. {
  4293. string eid = GetPostString("ctid");
  4294. CeErpTradeCell entity = null;
  4295. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4296. if (entity != null)
  4297. {
  4298. string stropt = "";
  4299. if (entity.MemoOpt == 1)
  4300. {
  4301. stropt = "“改稿”";
  4302. }
  4303. else if (entity.MemoOpt == 2)
  4304. {
  4305. stropt = "“定稿”";
  4306. }
  4307. else if (entity.MemoOpt == 3)
  4308. {
  4309. stropt = "“完成查货”";
  4310. CeErpSukuraData.createInfo(entity.ctid, 6);
  4311. }
  4312. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4313. entity.MemoOpt = 0;
  4314. entity.Update();
  4315. returnSuccessMsg("操作成功!");
  4316. return;
  4317. }
  4318. returnErrorMsg("找不到记录");
  4319. }
  4320. }
  4321. public void get_erp_deliveryunusual()
  4322. {
  4323. DataStruct dStruct = GetPostStruct();
  4324. List<string> lw = new List<string>();
  4325. string tid = GetPostString("ctid");
  4326. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4327. string shopname = GetPostString("shopname");
  4328. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4329. string buyernick = GetPostString("buyer_nick");
  4330. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4331. string customer = GetPostString("customer");
  4332. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4333. string design = GetPostString("design");
  4334. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4335. string sellermemo = GetPostString("seller_memo");
  4336. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4337. string supplier = GetPostString("supplier");
  4338. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4339. string date1 = GetPostString("date1");
  4340. string date2 = GetPostString("date2");
  4341. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4342. if (dw.Length > 0) lw.Add(dw);
  4343. string placedate1 = GetPostString("placedate1");
  4344. string placedate2 = GetPostString("placedate2");
  4345. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4346. if (dw_place.Length > 0) lw.Add(dw_place);
  4347. string price1 = GetPostString("price1");
  4348. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4349. string price2 = GetPostString("price2");
  4350. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4351. string unusualCon = GetPostString("unusualcon");
  4352. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4353. string posTag = CurrentUser.UserPost.Post.Code;
  4354. if (posTag == "Supplier")
  4355. {
  4356. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4357. }
  4358. lw.Add(string.Format("OrderState = 6"));
  4359. lw.Add(string.Format("UnusualTag = 5"));
  4360. lw.Add(string.Format("IsRefund<={0}", 1));
  4361. dStruct.Order = "FinishPlaceTime desc";
  4362. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4363. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4364. writeGridDataTableJson(dStruct.TotalCount, dt);
  4365. }
  4366. public void get_erp_deliveryedlist()
  4367. {
  4368. DataStruct dStruct = GetPostStruct();
  4369. List<string> lw = new List<string>();
  4370. string tid = GetPostString("ctid");
  4371. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4372. string shopname = GetPostString("shopname");
  4373. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4374. string buyernick = GetPostString("buyer_nick");
  4375. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4376. string customer = GetPostString("customer");
  4377. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4378. string design = GetPostString("design");
  4379. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4380. string sellermemo = GetPostString("seller_memo");
  4381. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4382. string logistics = GetPostString("logistics");
  4383. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4384. string date1 = GetPostString("date1");
  4385. string date2 = GetPostString("date2");
  4386. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4387. //if (dw.Length > 0) lw.Add(dw);
  4388. string placedate1 = GetPostString("placedate1");
  4389. string placedate2 = GetPostString("placedate2");
  4390. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4391. if (fdw.Length > 0) lw.Add(fdw);
  4392. string devdate1 = GetPostString("deliverydate1");
  4393. string devdate2 = GetPostString("deliverydate2");
  4394. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4395. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4396. string price1 = GetPostString("price1");
  4397. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4398. string price2 = GetPostString("price2");
  4399. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4400. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4401. {
  4402. if (tid.Length > 0)
  4403. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4404. if (buyernick.Length > 0)
  4405. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4406. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4407. if (dw.Length > 0) lw.Add(dw);
  4408. }
  4409. else
  4410. {
  4411. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4412. }
  4413. string posTag = CurrentUser.UserPost.Post.Code;
  4414. if (posTag == "Supplier")
  4415. {
  4416. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4417. }
  4418. else
  4419. {
  4420. string supplier = GetPostString("supplier");
  4421. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4422. }
  4423. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4424. lw.Add(string.Format("IsRefund!={0}", 2));
  4425. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4426. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4427. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4428. if (dt != null)
  4429. {
  4430. foreach (DataRow dr in dt.Rows)
  4431. {
  4432. 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();
  4433. }
  4434. }
  4435. writeGridDataTableJson(dStruct.TotalCount, dt);
  4436. }
  4437. public void get_erp_pdddeliveryed()
  4438. {
  4439. DataStruct dStruct = GetPostStruct();
  4440. List<string> lw = new List<string>();
  4441. string tid = GetPostString("ctid");
  4442. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4443. string shopname = GetPostString("shopname");
  4444. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4445. string buyernick = GetPostString("buyer_nick");
  4446. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4447. string customer = GetPostString("customer");
  4448. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4449. string design = GetPostString("design");
  4450. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4451. string sellermemo = GetPostString("seller_memo");
  4452. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4453. string logistics = GetPostString("logistics");
  4454. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4455. string date1 = GetPostString("date1");
  4456. string date2 = GetPostString("date2");
  4457. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4458. //if (dw.Length > 0) lw.Add(dw);
  4459. string placedate1 = GetPostString("placedate1");
  4460. string placedate2 = GetPostString("placedate2");
  4461. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4462. if (fdw.Length > 0) lw.Add(fdw);
  4463. string devdate1 = GetPostString("deliverydate1");
  4464. string devdate2 = GetPostString("deliverydate2");
  4465. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4466. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4467. string price1 = GetPostString("price1");
  4468. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4469. string price2 = GetPostString("price2");
  4470. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4471. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4472. {
  4473. if (tid.Length > 0)
  4474. lw.Add(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4475. if (buyernick.Length > 0)
  4476. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4477. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4478. if (dw.Length > 0) lw.Add(dw);
  4479. }
  4480. else
  4481. {
  4482. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4483. }
  4484. string posTag = CurrentUser.UserPost.Post.Code;
  4485. if (posTag == "Supplier")
  4486. {
  4487. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4488. }
  4489. else
  4490. {
  4491. string supplier = GetPostString("supplier");
  4492. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4493. }
  4494. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4495. lw.Add(string.Format("type = 'PDD' "));
  4496. lw.Add(string.Format("IsRefund!={0}", 2));
  4497. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4498. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4499. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4500. foreach (DataRow dr in dt.Rows)
  4501. {
  4502. 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();
  4503. }
  4504. writeGridDataTableJson(dStruct.TotalCount, dt);
  4505. }
  4506. public void get_erp_jddeliveryed()
  4507. {
  4508. DataStruct dStruct = GetPostStruct();
  4509. List<string> lw = new List<string>();
  4510. string tid = GetPostString("ctid");
  4511. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4512. string shopname = GetPostString("shopname");
  4513. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4514. string buyernick = GetPostString("buyer_nick");
  4515. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4516. string customer = GetPostString("customer");
  4517. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4518. string design = GetPostString("design");
  4519. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4520. string sellermemo = GetPostString("seller_memo");
  4521. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4522. string date1 = GetPostString("date1");
  4523. string date2 = GetPostString("date2");
  4524. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4525. //if (dw.Length > 0) lw.Add(dw);
  4526. string placedate1 = GetPostString("placedate1");
  4527. string placedate2 = GetPostString("placedate2");
  4528. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4529. if (fdw.Length > 0) lw.Add(fdw);
  4530. string devdate1 = GetPostString("deliverydate1");
  4531. string devdate2 = GetPostString("deliverydate2");
  4532. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4533. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4534. string price1 = GetPostString("price1");
  4535. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4536. string price2 = GetPostString("price2");
  4537. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4538. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4539. {
  4540. if (tid.Length > 0)
  4541. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4542. if (buyernick.Length > 0)
  4543. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4544. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4545. if (dw.Length > 0) lw.Add(dw);
  4546. }
  4547. else
  4548. {
  4549. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4550. }
  4551. string posTag = CurrentUser.UserPost.Post.Code;
  4552. if (posTag == "Supplier")
  4553. {
  4554. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4555. }
  4556. else
  4557. {
  4558. string supplier = GetPostString("supplier");
  4559. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4560. }
  4561. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4562. lw.Add(string.Format("type = 'JD' "));
  4563. lw.Add(string.Format("IsRefund!={0}", 2));
  4564. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4565. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4566. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4567. foreach (DataRow dr in dt.Rows)
  4568. {
  4569. 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();
  4570. }
  4571. writeGridDataTableJson(dStruct.TotalCount, dt);
  4572. }
  4573. public void get_erp_allplacelist()
  4574. {
  4575. DataStruct dStruct = GetPostStruct();
  4576. List<string> lw = new List<string>();
  4577. string tid = GetPostString("ctid");
  4578. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4579. string shopname = GetPostString("shopname");
  4580. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4581. string buyernick = GetPostString("buyer_nick");
  4582. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4583. string customer = GetPostString("customer");
  4584. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4585. string design = GetPostString("design");
  4586. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4587. string sellermemo = GetPostString("seller_memo");
  4588. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4589. string supplier = GetPostString("supplier");
  4590. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4591. string date1 = GetPostString("date1");
  4592. string date2 = GetPostString("date2");
  4593. string pldate1 = GetPostString("placedate1");
  4594. string pldate2 = GetPostString("placedate2");
  4595. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4596. //if (dw.Length > 0) lw.Add(dw);
  4597. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4598. {
  4599. if (tid.Length > 0)
  4600. lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  4601. if (buyernick.Length > 0)
  4602. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4603. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4604. if (dw.Length > 0) lw.Add(dw);
  4605. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4606. if (dw_place.Length > 0) lw.Add(dw_place);
  4607. }
  4608. else
  4609. {
  4610. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4611. {
  4612. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4613. }
  4614. }
  4615. string price1 = GetPostString("price1");
  4616. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4617. string price2 = GetPostString("price2");
  4618. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4619. string posTag = CurrentUser.UserPost.Post.Code;
  4620. if (posTag == "Supplier")
  4621. {
  4622. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4623. }
  4624. lw.Add(string.Format("OrderState >= 6"));
  4625. lw.Add(string.Format("IsSample != 2 "));
  4626. lw.Add(string.Format("isDianziOrder = 0 "));
  4627. //lw.Add(string.Format("IsRefund<={0}", 1));
  4628. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4629. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4630. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4631. foreach (DataRow dr in dt.Rows)
  4632. {
  4633. 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();
  4634. }
  4635. writeGridDataTableJson(dStruct.TotalCount, dt);
  4636. }
  4637. public void get_erp_financeallplacelist()
  4638. {
  4639. DataStruct dStruct = GetPostStruct();
  4640. List<string> lw = new List<string>();
  4641. string tid = GetPostString("ctid");
  4642. if (tid.Length > 0) lw.Add(string.Format("(ctid ='{0}' or orderSn ='{0}')", tid));
  4643. string shopname = GetPostString("shopname");
  4644. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4645. string buyernick = GetPostString("buyer_nick");
  4646. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4647. string customer = GetPostString("customer");
  4648. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4649. string design = GetPostString("design");
  4650. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4651. string sellermemo = GetPostString("seller_memo");
  4652. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4653. string supplier = GetPostString("supplier");
  4654. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4655. string date1 = GetPostString("date1");
  4656. string date2 = GetPostString("date2");
  4657. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4658. if (dw.Length > 0) lw.Add(dw);
  4659. string pldate1 = GetPostString("placedate1");
  4660. string pldate2 = GetPostString("placedate2");
  4661. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4662. if (dw_place.Length > 0) lw.Add(dw_place);
  4663. string price1 = GetPostString("price1");
  4664. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4665. string price2 = GetPostString("price2");
  4666. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4667. string posTag = CurrentUser.UserPost.Post.Code;
  4668. if (posTag == "Supplier")
  4669. {
  4670. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4671. }
  4672. //lw.Add(string.Format("OrderState >= 6"));
  4673. lw.Add(string.Format("IsSample != 2 "));
  4674. lw.Add(string.Format("isDianziOrder = 0 "));
  4675. //lw.Add(string.Format("IsRefund<={0}", 1));
  4676. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4677. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4678. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  4679. foreach (DataRow dr in dt.Rows)
  4680. {
  4681. 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();
  4682. }
  4683. writeGridDataTableJson(dStruct.TotalCount, dt);
  4684. }
  4685. public void get_erp_expresslist()
  4686. {
  4687. int listtype = GetInt("ltype");
  4688. DataStruct dStruct = GetPostStruct();
  4689. List<string> lw = new List<string>();
  4690. string tid = GetPostString("tid");
  4691. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  4692. string outsid = GetPostString("out_sid");
  4693. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  4694. string importer = GetPostString("ImportUserName");
  4695. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  4696. string file = GetPostString("import_file");
  4697. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  4698. string printman = GetPostString("printman");
  4699. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  4700. string date1 = GetPostString("date1");
  4701. string date2 = GetPostString("date2");
  4702. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4703. if (dw.Length > 0) lw.Add(dw);
  4704. string fdate1 = GetPostString("finishdate1");
  4705. string fdate2 = GetPostString("finishdate2");
  4706. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  4707. if (fdw.Length > 0) lw.Add(fdw);
  4708. if (listtype == 1)
  4709. {
  4710. lw.Add(string.Format("importUserId !=0"));
  4711. }
  4712. string posTag = CurrentUser.UserPost.Post.Code;
  4713. if (posTag == "Supplier")
  4714. {
  4715. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4716. }
  4717. if (dStruct.PageSize != 100000)
  4718. {
  4719. dStruct.Order = "isMultiDelivery asc, import_time desc";
  4720. }
  4721. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4722. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  4723. writeGridDataTableJson(dStruct.TotalCount, dt);
  4724. }
  4725. public void set_erp_buchaorderdelivery()
  4726. {
  4727. if (UrlPostParmsCheck("ctid"))
  4728. {
  4729. string eid = GetPostString("ctid");
  4730. CeErpTradeCell entity = null;
  4731. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4732. if (entity != null)
  4733. {
  4734. if (entity.IsSample != 2)
  4735. {
  4736. returnErrorMsg("补差价单才能标记为已发货");
  4737. return;
  4738. }
  4739. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  4740. entity.OrderState = 7;
  4741. entity.Update();
  4742. returnSuccessMsg("操作成功!");
  4743. return;
  4744. }
  4745. returnErrorMsg("找不到记录");
  4746. }
  4747. }
  4748. public void get_stdtemplates()
  4749. {
  4750. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  4751. //string res = taobaoHelper.test();
  4752. string res = apiHelper.API_PrintTemplate();
  4753. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4754. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  4755. {
  4756. int sidx = res.IndexOf("error_code");
  4757. int eidx = res.IndexOf("success");
  4758. string msg = res.Substring(sidx, eidx - sidx);
  4759. returnErrorMsg(msg);
  4760. return;
  4761. }
  4762. if (res.Length <= 0)
  4763. {
  4764. returnErrorMsg("模板数据为空!");
  4765. return;
  4766. }
  4767. ReturnSuccess(res);
  4768. }
  4769. public void cancel_print_order()
  4770. {
  4771. if (UrlPostParmsCheck("ctid"))
  4772. {
  4773. string ctid = GetPostString("ctid");
  4774. CeErpTradeCell entity = null;
  4775. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4776. if (entity != null)
  4777. {
  4778. string res = "";
  4779. string code = entity.LastBillWaybillCode;
  4780. if (code == "")
  4781. {
  4782. code = entity.OutSid;
  4783. }
  4784. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  4785. XLog.SaveLog(0, "取消面单" + res);
  4786. }
  4787. }
  4788. }
  4789. public void set_erp_printwaybill()
  4790. {
  4791. if (UrlPostParmsCheck("ctid"))
  4792. {
  4793. string ctid = GetPostString("ctid");
  4794. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  4795. string cpName = GetPostString("cpname");
  4796. string isTogether = GetPostString("together");
  4797. //var res_obj = new
  4798. //{
  4799. // restype = 1,
  4800. // 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\"}"
  4801. //};
  4802. //string ro_json = JsonConvert.SerializeObject(res_obj);
  4803. //ReturnSuccess(ro_json);
  4804. //return;
  4805. bool isUseLastWayBillCode = false;
  4806. CeErpTradeCell entity = null;
  4807. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4808. if (entity != null)
  4809. {
  4810. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  4811. {
  4812. isUseLastWayBillCode = true;
  4813. }
  4814. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  4815. {
  4816. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  4817. return;
  4818. }
  4819. }
  4820. string res = "";
  4821. Api_waybill_code_response_Obj fullObj = null;
  4822. string pData_str = "";
  4823. string curUseWayBillCode = "";
  4824. if (isUseLastWayBillCode == false)
  4825. {
  4826. res = apiHelper.API_GetWaybill(cpCode, ctid);
  4827. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  4828. if (res.IndexOf("failure") != -1)
  4829. {
  4830. //int idx = res.IndexOf("sub_message");
  4831. //int idx2 = res.IndexOf("flag");
  4832. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  4833. string errMsgNeed = commonHelper.KeepChinese(res);
  4834. var res_objd = new
  4835. {
  4836. restype = 0,
  4837. data = "获取面单失败" + errMsgNeed
  4838. };
  4839. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  4840. returnSuccess(ro_jsond);
  4841. if (res.IndexOf("停发") != -1)
  4842. {
  4843. entity.UnusualCon = "物流停发";
  4844. entity.Update();
  4845. }
  4846. //returnErrorMsg("获取面单失败,"+emsg);
  4847. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  4848. return;
  4849. }
  4850. else if (res.IndexOf("errorMsg") != -1)
  4851. {
  4852. //int idx = res.IndexOf("errorMsg");
  4853. //int idx2 = res.IndexOf("}]}");
  4854. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  4855. string errMsgNeed = commonHelper.KeepChinese(res);
  4856. var res_objf = new
  4857. {
  4858. restype = 0,
  4859. data = "获取面单失败2" + errMsgNeed
  4860. };
  4861. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4862. if (res.IndexOf("停发") != -1)
  4863. {
  4864. entity.UnusualCon = "物流停发";
  4865. entity.Update();
  4866. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4867. if (trade != null)
  4868. {
  4869. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  4870. }
  4871. }
  4872. returnSuccess(ro_jsonf);
  4873. //returnErrorMsg("获取面单失败," + emsg);
  4874. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  4875. return;
  4876. }
  4877. try
  4878. {
  4879. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  4880. //res = res.Replace(" ", "");
  4881. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  4882. }
  4883. catch (Exception ex)
  4884. {
  4885. XLog.SaveLog(0, "生成fullObj" + res);
  4886. var res_objf = new
  4887. {
  4888. restype = 0,
  4889. data = "生成fullObj发生错误" + ex.Message
  4890. };
  4891. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4892. returnSuccess(ro_jsonf);
  4893. return;
  4894. }
  4895. if (fullObj.response.data.content.Count > 0)
  4896. {
  4897. ContentItem codeObj = fullObj.response.data.content[0];
  4898. if (cpCode.IndexOf("SFFQ-") != -1)
  4899. {
  4900. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  4901. }
  4902. else
  4903. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  4904. curUseWayBillCode = codeObj.waybillCode;
  4905. }
  4906. else
  4907. {
  4908. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  4909. var res_objf = new
  4910. {
  4911. restype = 0,
  4912. data = "生成fullObj找不到快递单号waybillCode"
  4913. };
  4914. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  4915. returnSuccess(ro_jsonf);
  4916. return;
  4917. }
  4918. }
  4919. else
  4920. {
  4921. //使用上次打印的快递单号
  4922. if (cpCode == "SFFQ-LY")
  4923. {
  4924. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  4925. }
  4926. else
  4927. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  4928. curUseWayBillCode = entity.LastBillWaybillCode;
  4929. }
  4930. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  4931. {
  4932. var res_obje = new
  4933. {
  4934. restype = 0,
  4935. data = "获取加密打印数据失败"
  4936. };
  4937. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  4938. returnSuccess(ro_jsone);
  4939. entity.LastBillCpCode = cpCode;
  4940. entity.LastBillWaybillCode = curUseWayBillCode;
  4941. entity.Update();
  4942. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  4943. //returnErrorMsg("获取加密打印数据失败");
  4944. return;
  4945. }
  4946. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  4947. //string msg = "{\"data\":\""+pageUrl+"\"}";
  4948. string btnType = "";
  4949. if (entity != null)
  4950. {
  4951. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4952. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4953. //cpcode是 YTO-CAINIAO
  4954. //string comCode = cpCode.Split('-')[0].ToString();
  4955. string apires = "";
  4956. if (ctid.IndexOf("N") != -1)
  4957. {
  4958. apires = "发货成功";
  4959. }
  4960. else
  4961. {
  4962. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4963. }
  4964. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  4965. //打单后发货
  4966. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  4967. {
  4968. try
  4969. {
  4970. btnType = "待发货";
  4971. entity.OutSid = curUseWayBillCode;
  4972. entity.OrderState = 7;
  4973. entity.IsUrgency = false;
  4974. entity.LastBillCpCode = "";
  4975. entity.LastBillWaybillCode = "";
  4976. entity.FinishDeliveryTime = DateTime.Now;
  4977. entity.IsReturn = 0;
  4978. entity.MemoOpt = 0;
  4979. entity.Update();
  4980. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  4981. //还要插入快递信息到 快递信息表
  4982. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4983. exinfo.tid = entity.ctid;
  4984. exinfo.out_sid = entity.OutSid;
  4985. exinfo.company_code = cpCode;
  4986. exinfo.company_name = cpName;
  4987. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4988. exinfo.deliveryType = "发货成功";
  4989. exinfo.print_time = DateTime.Now;
  4990. exinfo.printUser = CurrentUser.UserName;
  4991. exinfo.Create();
  4992. commonHelper.UpdateRelationOrder(entity.ctid);
  4993. CeErpSukuraData.createInfo(ctid, 4);
  4994. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  4995. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  4996. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4997. if (isTogether == "1")
  4998. {
  4999. StringBuilder sqlsb = new StringBuilder();
  5000. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5001. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5002. }
  5003. }
  5004. catch (Exception ex)
  5005. {
  5006. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5007. }
  5008. }
  5009. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5010. {
  5011. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5012. if (entity.OrderState == 6)
  5013. {
  5014. entity.OrderState = 7;
  5015. }
  5016. entity.FinishDeliveryTime = DateTime.Now;
  5017. btnType = "已发货";
  5018. entity.Update();
  5019. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5020. exinfo.tid = entity.ctid;
  5021. exinfo.out_sid = entity.OutSid;
  5022. exinfo.company_code = cpCode;
  5023. exinfo.company_name = cpName;
  5024. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5025. exinfo.deliveryType = "发货成功";
  5026. exinfo.print_time = DateTime.Now;
  5027. exinfo.printUser = CurrentUser.UserName;
  5028. exinfo.Create();
  5029. commonHelper.UpdateRelationOrder(entity.ctid);
  5030. CeErpSukuraData.createInfo(entity.ctid, 4);
  5031. if (isTogether == "1")
  5032. {
  5033. StringBuilder sqlsb = new StringBuilder();
  5034. sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
  5035. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5036. }
  5037. //不处理
  5038. }
  5039. else
  5040. {
  5041. entity.LastBillCpCode = cpCode;
  5042. entity.LastBillWaybillCode = curUseWayBillCode;
  5043. entity.Update();
  5044. string errmsg = commonHelper.KeepChinese(apires);
  5045. var res_objz = new
  5046. {
  5047. restype = 0,
  5048. data = "打单后发货失败"
  5049. };
  5050. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5051. returnSuccess(ro_jsonz);
  5052. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5053. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5054. return;
  5055. }
  5056. }
  5057. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5058. var res_obj = new
  5059. {
  5060. restype = 1,
  5061. data = pData_str
  5062. };
  5063. string ro_json = JsonConvert.SerializeObject(res_obj);
  5064. ReturnSuccess(ro_json);
  5065. return;
  5066. }
  5067. }
  5068. private string GetUTF8String(byte[] vs)
  5069. {
  5070. throw new NotImplementedException();
  5071. }
  5072. public void set_erp_printwaybill_cn()
  5073. {
  5074. if (UrlPostParmsCheck("ctid"))
  5075. {
  5076. string ctid = GetPostString("ctid");
  5077. string cpCode = GetPostString("cpcode");
  5078. string cpName = GetPostString("cpname");
  5079. string tempUrl = GetPostString("tempurl");
  5080. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5081. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5082. //string res = taobaoHelper.test();
  5083. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5084. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5085. {
  5086. int sidx = res.IndexOf("errorMsg");
  5087. int eidx = res.IndexOf("}");
  5088. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5089. var res_objzxx = new
  5090. {
  5091. restype = 0,
  5092. data = msg
  5093. };
  5094. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5095. returnSuccess(ro_jsonzxx);
  5096. //returnErrorMsg(msg);
  5097. return;
  5098. }
  5099. int idx = res.IndexOf("waybillCode");
  5100. int idx2 = res.IndexOf("printData");
  5101. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5102. string eid = GetPostString("ctid");
  5103. CeErpTradeCell entity = null;
  5104. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5105. if (entity != null)
  5106. {
  5107. string osid = entity.OutSid;
  5108. entity.OutSid = osid + "," + outsid;
  5109. entity.FinishDeliveryTime = DateTime.Now;
  5110. entity.OrderState = 7;
  5111. entity.IsReturn = 0;
  5112. entity.Update();
  5113. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5114. exinfo.tid = entity.ctid;
  5115. exinfo.out_sid = outsid;
  5116. exinfo.company_code = cpCode;
  5117. exinfo.company_name = cpName;
  5118. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5119. exinfo.deliveryType = "发货成功";
  5120. exinfo.print_time = DateTime.Now;
  5121. exinfo.printUser = CurrentUser.UserName;
  5122. exinfo.Create();
  5123. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5124. }
  5125. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5126. var res_objz = new
  5127. {
  5128. restype = 1,
  5129. data = res
  5130. };
  5131. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5132. returnSuccess(ro_jsonz);
  5133. //ReturnSuccess(res);
  5134. }
  5135. }
  5136. ////打单,打印面单 获取面单号
  5137. //public void set_erp_printwaybill()
  5138. //{
  5139. // if (UrlPostParmsCheck("ctid"))
  5140. // {
  5141. // string ctid = GetPostString("ctid");
  5142. // string cpCode = GetPostString("cpcode");
  5143. // string tempUrl = GetPostString("tempurl");
  5144. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5145. // //string res = taobaoHelper.test();
  5146. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5147. // if (res.IndexOf("error_response") != -1)
  5148. // {
  5149. // int sidx = res.IndexOf("sub_msg");
  5150. // int eidx = res.IndexOf("request_id");
  5151. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5152. // returnErrorMsg(msg);
  5153. // return;
  5154. // }
  5155. // int idx = res.IndexOf("waybill_code");
  5156. // int idx2 = res.IndexOf("}]}");
  5157. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5158. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5159. // ReturnSuccess(res);
  5160. // }
  5161. //}
  5162. public void cancel_erp_aftersale()
  5163. {
  5164. if (UrlPostParmsCheck("ctid"))
  5165. {
  5166. string eid = GetPostString("ctid");
  5167. CeErpTradeCell entity = null;
  5168. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5169. if (entity != null)
  5170. {
  5171. //有过处理的售后,取消也不能删除 售 字,保留
  5172. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5173. {
  5174. entity.AfterSaleState = 4;
  5175. }
  5176. else
  5177. entity.AfterSaleState = 0;
  5178. entity.Update();
  5179. returnSuccessMsg("操作成功!");
  5180. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5181. return;
  5182. }
  5183. returnErrorMsg("找不到订单记录");
  5184. }
  5185. }
  5186. public void get_erp_aftersalelist()
  5187. {
  5188. DataStruct dStruct = GetPostStruct();
  5189. List<string> lw = new List<string>();
  5190. int st = GetInt("st");
  5191. string tid = GetPostString("ctid");
  5192. if (st == 3)
  5193. {
  5194. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}'", tid));
  5195. }
  5196. else
  5197. {
  5198. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5199. }
  5200. string shopname = GetPostString("shopname");
  5201. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5202. string buyernick = GetPostString("buyer_nick");
  5203. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5204. string sellermemo = GetPostString("seller_memo");
  5205. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5206. string orderState = GetPostString("orderState");
  5207. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5208. string afterState = GetPostString("afterstate");
  5209. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5210. string date1 = GetPostString("date1");
  5211. string date2 = GetPostString("date2");
  5212. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5213. if (dw.Length > 0) lw.Add(dw);
  5214. string price1 = GetPostString("price1");
  5215. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5216. string price2 = GetPostString("price2");
  5217. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5218. //lw.Add(string.Format("IsRefund!={0}", 1));
  5219. string reason = GetPostString("reason");
  5220. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5221. string method = GetPostString("method");
  5222. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5223. string handler = GetPostString("handler");
  5224. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5225. string handledate1 = GetPostString("handledate1");
  5226. string handledate2 = GetPostString("handledate2");
  5227. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5228. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5229. string finish1 = GetPostString("finishdate1");
  5230. string finish2 = GetPostString("finishdate2");
  5231. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5232. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5233. string afterdate1 = GetPostString("afterdate1");
  5234. string afterdate2 = GetPostString("afterdate2");
  5235. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5236. if (afterDate.Length > 0) lw.Add(afterDate);
  5237. string supplier = GetPostString("supplier");
  5238. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5239. string responsible = GetPostString("responsibleman");
  5240. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5241. string customer = GetPostString("customer");
  5242. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5243. string design = GetPostString("design");
  5244. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5245. string afterMemoType = GetPostString("aftermemotype");
  5246. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5247. string posCode = CurrentUser.UserPost.Post.Code;
  5248. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5249. //{
  5250. // string vstate = GetPostString("vstate");
  5251. // if (vstate.Length > 0)
  5252. // {
  5253. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5254. // }
  5255. // if (posCode == "Supplier")
  5256. // {
  5257. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5258. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5259. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5260. // }
  5261. // else
  5262. // {
  5263. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5264. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5265. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5266. // {
  5267. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5268. // }
  5269. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5270. // {
  5271. // int orgid = CurrentUser.UserPost.OrgID;
  5272. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5273. // }
  5274. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5275. // {
  5276. // string shopid = CurrentUser.User.pemShop;
  5277. // lw.Add(string.Format("shopId in ({0})", shopid));
  5278. // }
  5279. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5280. // //{
  5281. // // int org_id = CurrentUser.UserPost.OrgID;
  5282. // // lw.Add(string.Format("OrgID={0}", org_id));
  5283. // //}
  5284. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5285. // }
  5286. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5287. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5288. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5289. //}
  5290. if (st == 5)
  5291. {
  5292. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5293. {
  5294. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5295. {
  5296. string shopid = CurrentUser.User.pemShop;
  5297. lw.Add(string.Format("shopId in ({0})", shopid));
  5298. }
  5299. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5300. {
  5301. int mrOrgid = CurrentUser.UserPost.OrgID;
  5302. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5303. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5304. }
  5305. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5306. //{
  5307. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5308. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5309. //}
  5310. else
  5311. {
  5312. string userIdStr = "";
  5313. if (posCode == "CustomerService")
  5314. {
  5315. userIdStr = CurrentUser.UserID + "_k";
  5316. }
  5317. else if (posCode == "Designer" || posCode == "wxDesigner")
  5318. {
  5319. userIdStr = CurrentUser.UserID + "_s";
  5320. }
  5321. else if (posCode == "Place")
  5322. {
  5323. userIdStr = CurrentUser.UserID + "_x";
  5324. }
  5325. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5326. }
  5327. }
  5328. string placedate1 = GetPostString("placedate1");
  5329. string placedate2 = GetPostString("placedate2");
  5330. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5331. if (dwplace.Length > 0) lw.Add(dwplace);
  5332. string supState = GetPostString("supState");
  5333. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5334. string searchType = GetPostString("searchType");
  5335. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5336. {
  5337. lw.Add(string.Format("BackNum>1"));
  5338. }
  5339. lw.Add(string.Format("AfterSaleState>0"));
  5340. if (ex_psize > 0)
  5341. {
  5342. if (CurrentUser.UserPost.Post.Code == "Finance")
  5343. dStruct.Order = "pay_time desc";
  5344. else
  5345. dStruct.Order = "HandleTime desc";
  5346. }
  5347. else
  5348. dStruct.Order = "HandleTime desc";
  5349. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5350. DataTable dt = WebCache.GetData("view_test", dStruct);
  5351. writeGridDataTableJson(dStruct.TotalCount, dt);
  5352. }
  5353. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5354. //{
  5355. // lw.Add(string.Format("AfterSaleState=4"));
  5356. // string code = CurrentUser.UserPost.Post.Code;
  5357. // if (code == "CustomerService")
  5358. // {
  5359. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5360. // }
  5361. // else if (code == "Designer" || code == "DesignerMr")
  5362. // {
  5363. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5364. // }
  5365. // else if (code == "Place" || code == "PlaceMr")
  5366. // {
  5367. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5368. // }
  5369. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5370. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5371. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5372. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5373. //}
  5374. //else //处理中的售后,待处理和处理中合并
  5375. //{
  5376. // if (afterState.Length <= 0)
  5377. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5378. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5379. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5380. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5381. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5382. //}
  5383. }
  5384. public void get_erp_disagreeftersalelist()
  5385. {
  5386. DataStruct dStruct = GetPostStruct();
  5387. List<string> lw = new List<string>();
  5388. int st = 2;
  5389. string tid = GetPostString("ctid");
  5390. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5391. string shopname = GetPostString("shopname");
  5392. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5393. string buyernick = GetPostString("buyer_nick");
  5394. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5395. string sellermemo = GetPostString("seller_memo");
  5396. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5397. string orderState = GetPostString("orderState");
  5398. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5399. string afterState = GetPostString("afterstate");
  5400. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5401. string date1 = GetPostString("date1");
  5402. string date2 = GetPostString("date2");
  5403. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5404. if (dw.Length > 0) lw.Add(dw);
  5405. string price1 = GetPostString("price1");
  5406. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5407. string price2 = GetPostString("price2");
  5408. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5409. //lw.Add(string.Format("IsRefund!={0}", 1));
  5410. string reason = GetPostString("reason");
  5411. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5412. string method = GetPostString("method");
  5413. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5414. string handler = GetPostString("handler");
  5415. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5416. string handledate1 = GetPostString("handledate1");
  5417. string handledate2 = GetPostString("handledate2");
  5418. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5419. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5420. string afterdate1 = GetPostString("afterdate1");
  5421. string afterdate2 = GetPostString("afterdate2");
  5422. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5423. if (afterDate.Length > 0) lw.Add(afterDate);
  5424. string supplier = GetPostString("supplier");
  5425. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5426. string responsible = GetPostString("responsibleman");
  5427. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5428. string customer = GetPostString("customer");
  5429. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5430. string design = GetPostString("design");
  5431. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5432. string afterSaleMemo = GetPostString("afterSaleMemo");
  5433. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5434. string afterMemoType = GetPostString("aftermemotype");
  5435. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5436. string aftersakereason = GetPostString("aftersakereason");
  5437. if (aftersakereason.Length > 0)
  5438. {
  5439. if (aftersakereason == "1")
  5440. {
  5441. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5442. }
  5443. if (aftersakereason == "2")
  5444. {
  5445. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5446. }
  5447. }
  5448. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5449. string poscode = CurrentUser.UserPost.Post.Code;
  5450. if (poscode != "SysAdmin")
  5451. {
  5452. string shopid = CurrentUser.User.pemShop;
  5453. lw.Add(string.Format("shopId in ({0})", shopid));
  5454. }
  5455. string searchType = GetPostString("searchType");
  5456. if (searchType == "wait")
  5457. {
  5458. lw.Add(string.Format("HandleTime is null"));
  5459. }
  5460. if (searchType == "handling")
  5461. {
  5462. lw.Add(string.Format("HandleTime is not null "));
  5463. }
  5464. if (searchType == "back" || searchType == "puBack")
  5465. {
  5466. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5467. }
  5468. if (searchType == "reBack")
  5469. {
  5470. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5471. }
  5472. if (searchType == "moreBack")
  5473. {
  5474. lw.Add(string.Format("backNum > 1"));
  5475. }
  5476. lw.Add(string.Format("(AfterSaleState=5)"));
  5477. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5478. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5479. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5480. writeGridDataTableJson(dStruct.TotalCount, dt);
  5481. }
  5482. public void get_erp_handlingaftersalelist()
  5483. {
  5484. DataStruct dStruct = GetPostStruct();
  5485. List<string> lw = new List<string>();
  5486. int st = 2;
  5487. string tid = GetPostString("ctid");
  5488. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  5489. string shopname = GetPostString("shopname");
  5490. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5491. string buyernick = GetPostString("buyer_nick");
  5492. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5493. string sellermemo = GetPostString("seller_memo");
  5494. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5495. string orderState = GetPostString("orderState");
  5496. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5497. string afterState = GetPostString("afterstate");
  5498. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5499. string date1 = GetPostString("date1");
  5500. string date2 = GetPostString("date2");
  5501. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5502. if (dw.Length > 0) lw.Add(dw);
  5503. string price1 = GetPostString("price1");
  5504. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5505. string price2 = GetPostString("price2");
  5506. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5507. //lw.Add(string.Format("IsRefund!={0}", 1));
  5508. string reason = GetPostString("reason");
  5509. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5510. string method = GetPostString("method");
  5511. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5512. string handler = GetPostString("handler");
  5513. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5514. string handledate1 = GetPostString("handledate1");
  5515. string handledate2 = GetPostString("handledate2");
  5516. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5517. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5518. string afterdate1 = GetPostString("afterdate1");
  5519. string afterdate2 = GetPostString("afterdate2");
  5520. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5521. if (afterDate.Length > 0) lw.Add(afterDate);
  5522. string supplier = GetPostString("supplier");
  5523. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5524. string responsible = GetPostString("responsibleman");
  5525. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5526. string customer = GetPostString("customer");
  5527. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5528. string design = GetPostString("design");
  5529. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5530. string afterSaleMemo = GetPostString("afterSaleMemo");
  5531. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5532. string afterMemoType = GetPostString("aftermemotype");
  5533. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5534. string afterresult = GetPostString("afterresult");
  5535. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5536. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5537. string poscode = CurrentUser.UserPost.Post.Code;
  5538. if (poscode != "SysAdmin")
  5539. {
  5540. string shopid = CurrentUser.User.pemShop;
  5541. lw.Add(string.Format("shopId in ({0})", shopid));
  5542. }
  5543. string searchType = GetPostString("searchType");
  5544. if (searchType == "wait")
  5545. {
  5546. lw.Add(string.Format("HandleTime is null"));
  5547. }
  5548. if (searchType == "documentary")
  5549. {
  5550. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  5551. }
  5552. if (searchType == "handling")
  5553. {
  5554. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  5555. }
  5556. if (searchType == "back" || searchType == "puBack")
  5557. {
  5558. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5559. }
  5560. if (searchType == "reBack")
  5561. {
  5562. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5563. }
  5564. if (afterState.Length <= 0)
  5565. {
  5566. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5567. }
  5568. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5569. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5570. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5571. writeGridDataTableJson(dStruct.TotalCount, dt);
  5572. }
  5573. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  5574. //public void get_erp_back_handlingaftersalelist()
  5575. //{
  5576. // DataStruct dStruct = GetPostStruct();
  5577. // List<string> lw = new List<string>();
  5578. // string tid = GetPostString("ctid");
  5579. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  5580. // string shopname = GetPostString("shopname");
  5581. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5582. // string buyernick = GetPostString("buyer_nick");
  5583. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5584. // string sellermemo = GetPostString("seller_memo");
  5585. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5586. // string orderState = GetPostString("orderState");
  5587. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5588. // string afterState = GetPostString("afterstate");
  5589. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5590. // string date1 = GetPostString("date1");
  5591. // string date2 = GetPostString("date2");
  5592. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5593. // if (dw.Length > 0) lw.Add(dw);
  5594. // string price1 = GetPostString("price1");
  5595. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5596. // string price2 = GetPostString("price2");
  5597. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5598. // //lw.Add(string.Format("IsRefund!={0}", 1));
  5599. // string reason = GetPostString("reason");
  5600. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5601. // string method = GetPostString("method");
  5602. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5603. // string handler = GetPostString("handler");
  5604. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5605. // string handledate1 = GetPostString("handledate1");
  5606. // string handledate2 = GetPostString("handledate2");
  5607. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5608. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5609. // string afterdate1 = GetPostString("afterdate1");
  5610. // string afterdate2 = GetPostString("afterdate2");
  5611. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5612. // if (afterDate.Length > 0) lw.Add(afterDate);
  5613. // string supplier = GetPostString("supplier");
  5614. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5615. // string responsible = GetPostString("responsibleman");
  5616. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5617. // string customer = GetPostString("customer");
  5618. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5619. // string design = GetPostString("design");
  5620. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5621. // string afterMemoType = GetPostString("aftermemotype");
  5622. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5623. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  5624. // if (afterState.Length <= 0)
  5625. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5626. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  5627. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5628. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5629. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5630. //}
  5631. public void get_erp_aftersaleverifylist()
  5632. {
  5633. DataStruct dStruct = GetPostStruct();
  5634. List<string> lw = new List<string>();
  5635. string tid = GetPostString("ctid");
  5636. if (tid.Length > 0) lw.Add(string.Format("(tid like '%{0}%' or orderSn like '%{0}%')", tid));
  5637. string shopname = GetPostString("shopname");
  5638. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5639. string buyernick = GetPostString("buyer_nick");
  5640. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5641. string sellermemo = GetPostString("seller_memo");
  5642. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5643. string orderState = GetPostString("orderState");
  5644. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5645. //lw.Add(string.Format("IsRefund!={0}", 1));
  5646. string reason = GetPostString("reason");
  5647. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5648. string method = GetPostString("method");
  5649. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5650. string handler = GetPostString("handler");
  5651. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5652. string handledate1 = GetPostString("handledate1");
  5653. string handledate2 = GetPostString("handledate2");
  5654. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5655. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5656. string finish1 = GetPostString("finishdate1");
  5657. string finish2 = GetPostString("finishdate2");
  5658. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5659. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5660. string supplier = GetPostString("supplier");
  5661. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5662. string responsible = GetPostString("responsibleman");
  5663. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5664. string posCode = CurrentUser.UserPost.Post.Code;
  5665. string vstate = GetPostString("vstate");
  5666. if (vstate.Length > 0)
  5667. {
  5668. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5669. }
  5670. if (posCode == "Supplier")
  5671. {
  5672. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5673. lw.Add(string.Format("VerifyState = 0"));
  5674. lw.Add("type = 1");
  5675. lw.Add(string.Format("AfterSaleState={0}", 3));
  5676. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5677. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5678. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5679. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5680. writeGridDataTableJson(dStruct.TotalCount, dt);
  5681. }
  5682. else if (posCode == "logistics")
  5683. {
  5684. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  5685. lw.Add(string.Format("VerifyState = 0"));
  5686. lw.Add("type = 2");
  5687. lw.Add(string.Format("AfterSaleState={0}", 3));
  5688. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  5689. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5690. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5691. writeGridDataTableJson(dStruct.TotalCount, dt);
  5692. }
  5693. else
  5694. {
  5695. lw.Add(string.Format("(AfterSaleState = 3)"));
  5696. string reasonState = GetPostString("reasonState");
  5697. lw.Add("type = 0");
  5698. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  5699. || posCode == "Summarize" || posCode == "Finance")
  5700. {
  5701. if (reasonState == "2")
  5702. {
  5703. lw.Add("VerifyState = 3");
  5704. }
  5705. else if (reasonState == "1")
  5706. {
  5707. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  5708. }
  5709. else
  5710. {
  5711. lw.Add("VerifyState in (0,3)");
  5712. }
  5713. //不加条件,可以看全部
  5714. }
  5715. 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")
  5716. {
  5717. int orgid = CurrentUser.UserPost.OrgID;
  5718. string manageOrgId = CurrentUser.User.ManageOrgIds;
  5719. if (string.IsNullOrEmpty(manageOrgId))
  5720. {
  5721. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  5722. }
  5723. else
  5724. {
  5725. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  5726. }
  5727. if (reasonState == "1")
  5728. {
  5729. lw.Add("VerifyState = 3");
  5730. }
  5731. else if (reasonState == "2")
  5732. {
  5733. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  5734. }
  5735. else
  5736. {
  5737. }
  5738. }
  5739. else
  5740. {
  5741. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  5742. }
  5743. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5744. //{
  5745. // int org_id = CurrentUser.UserPost.OrgID;
  5746. // lw.Add(string.Format("OrgID={0}", org_id));
  5747. //}
  5748. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  5749. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5750. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5751. writeGridDataTableJson(dStruct.TotalCount, dt);
  5752. }
  5753. }
  5754. public void get_erp_finishaftersalelist()
  5755. {
  5756. DataStruct dStruct = GetPostStruct();
  5757. List<string> lw = new List<string>();
  5758. int st = 4;
  5759. string tid = GetPostString("ctid");
  5760. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  5761. string shopname = GetPostString("shopname");
  5762. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5763. //lw.Add(string.Format("IsRefund!={0}", 1));
  5764. string reason = GetPostString("reason");
  5765. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5766. string method = GetPostString("method");
  5767. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5768. string buyernick = GetPostString("buyer_nick");
  5769. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5770. string handler = GetPostString("handler");
  5771. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5772. string handledate1 = GetPostString("handledate1");
  5773. string handledate2 = GetPostString("handledate2");
  5774. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5775. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5776. string finish1 = GetPostString("finishdate1");
  5777. string finish2 = GetPostString("finishdate2");
  5778. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5779. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5780. string supplier = GetPostString("supplier");
  5781. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5782. string responsible = GetPostString("responsibleman");
  5783. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5784. string vstate = GetPostString("vstate");
  5785. if (vstate.Length > 0)
  5786. {
  5787. if ("3".Equals(vstate))
  5788. {
  5789. lw.Add(string.Format("IsTem=1"));
  5790. }
  5791. else
  5792. {
  5793. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5794. }
  5795. }
  5796. lw.Add(string.Format("AfterSaleState=4"));
  5797. string code = CurrentUser.UserPost.Post.Code;
  5798. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  5799. {
  5800. //不加条件,可以看全部
  5801. }
  5802. else if (code == "Supplier")
  5803. {
  5804. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5805. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5806. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5807. }
  5808. else if (code == "logistics")
  5809. {
  5810. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  5811. lw.Add("type = 2");
  5812. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5813. }
  5814. 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")
  5815. {
  5816. int orgid = CurrentUser.UserPost.OrgID;
  5817. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  5818. if (string.IsNullOrEmpty(manageOrgIds))
  5819. {
  5820. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  5821. }
  5822. else
  5823. {
  5824. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  5825. }
  5826. }
  5827. else
  5828. {
  5829. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  5830. }
  5831. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5832. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5833. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5834. writeGridDataTableJson(dStruct.TotalCount, dt);
  5835. }
  5836. public void handle_erp_aftersale()
  5837. {
  5838. if (UrlPostParmsCheck("ctid"))
  5839. {
  5840. string eid = GetPostString("ctid");
  5841. string responStr = GetPostString("AfterSaleResponsible");
  5842. if (responStr.Length <= 0)
  5843. {
  5844. returnErrorMsg("售后责任人不能为空");
  5845. return;
  5846. }
  5847. bool isDesign = false;
  5848. double designFree = 0.00;
  5849. int responsibleId = 0;
  5850. CeErpTradeCell entity = null;
  5851. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5852. if (entity != null)
  5853. {
  5854. int isNeedNewOrder = GetPostInt("IsNewOrder");
  5855. string afterMethod = GetPostString("AfterSaleMethod");
  5856. if (isNeedNewOrder == 1)
  5857. {
  5858. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  5859. bool ishav = true;
  5860. if (newentity == null)
  5861. {
  5862. newentity = entity.Clone() as CeErpTradeCell;
  5863. ishav = false;
  5864. newentity.ctid = "S_" + entity.ctid;
  5865. newentity.OrderState = 0;
  5866. }
  5867. //唯一标识
  5868. newentity.OrderSn = newentity.ctid;
  5869. /* string orderSn = dataHelper.getSaleOrderSn();
  5870. if (orderSn != "")
  5871. {
  5872. newentity.OrderSn = orderSn;
  5873. }*/
  5874. newentity.AfterSaleState = 0;
  5875. newentity.AfterSaleMethod = afterMethod;
  5876. if (!ishav)
  5877. {
  5878. string memo_str = newentity.seller_memo;
  5879. memo_str = memo_str.Replace("(", "(");
  5880. memo_str = memo_str.Replace(")", ")");
  5881. int sIndex = memo_str.IndexOf("(");
  5882. int eIndex = memo_str.IndexOf(")");
  5883. if (sIndex == -1 || eIndex == -1)
  5884. {
  5885. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  5886. return;
  5887. }
  5888. string first = memo_str.Substring(0, sIndex + 1);
  5889. string memoCtid = newentity.OrderSn;
  5890. //if (memoCtid.IndexOf("C") != -1)
  5891. //{
  5892. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  5893. //if (CIdx.IndexOf("+") != -1)
  5894. //{
  5895. //CIdx = "C" + CIdx.Split('+')[1];
  5896. //}
  5897. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  5898. //}
  5899. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  5900. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  5901. string newMemo = first + memoCtid + last;
  5902. newentity.seller_memo = newMemo;
  5903. newentity.FinishPlaceTime = null;
  5904. newentity.UnusualTag = 0;
  5905. newentity.UnusualCon = "";
  5906. newentity.UnusualTime = null;
  5907. newentity.AfterSaleMemo = "";
  5908. newentity.AfterSaleMethod = afterMethod;
  5909. newentity.AfterSalePreTime = null;
  5910. newentity.AfterSaleReason = "";
  5911. newentity.AfterSaleResponsible = "";
  5912. newentity.AfterSaleState = 0;
  5913. newentity.AfterSaleTime = null;
  5914. newentity.AfterSaleUserId = 0;
  5915. newentity.AfterSaleSupplierState = 0;
  5916. newentity.LastBillWaybillCode = "";
  5917. newentity.LastBillCpCode = "";
  5918. newentity.FinishAfterSaleTime = null;
  5919. newentity.HandleTime = null;
  5920. newentity.IsSF = 0;
  5921. newentity.IsOldCustomer = 0;
  5922. newentity.UrgencyTime = null;
  5923. newentity.ResponsibleUserId = "";
  5924. newentity.IsVerifyToSupplier = false;
  5925. newentity.payment = 0;
  5926. newentity.CheckMemo = "";
  5927. newentity.OutSid = "";
  5928. newentity.CheckOrderTime = null;
  5929. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  5930. }
  5931. newentity.isAfterSaleOrder = 1;
  5932. newentity.IsRefund = 0;
  5933. string receiveMobile = GetPostString("receiver_mobile");
  5934. if (receiveMobile.Length > 0)
  5935. {
  5936. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  5937. if (trade != null)
  5938. {
  5939. trade.receiver_name = GetPostString("receiver_name");
  5940. trade.receiver_mobile = receiveMobile;
  5941. trade.receiver_state = GetPostString("receiver_state");
  5942. trade.receiver_city = GetPostString("receiver_city");
  5943. trade.receiver_district = GetPostString("receiver_district");
  5944. trade.receiver_address = GetPostString("receiver_address");
  5945. newentity.IsOffLineOrder = 1;
  5946. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  5947. }
  5948. }
  5949. string st = GetPostString("ToState");
  5950. if (st.Length > 0)
  5951. {
  5952. if (newentity.OrderState <= 3)
  5953. {
  5954. newentity.WaitDesignTime = DateTime.Now;
  5955. newentity.StartDesignTime = null;
  5956. newentity.FinishDesignTime = null;
  5957. newentity.OrderState = 3;
  5958. if (st == "下单员")
  5959. {
  5960. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  5961. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  5962. {
  5963. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  5964. }
  5965. }
  5966. else
  5967. {
  5968. newentity.WaitDesignTime = DateTime.Now;
  5969. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  5970. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  5971. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  5972. {
  5973. DataRow user = dt1.Rows[0];
  5974. //找主管
  5975. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  5976. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  5977. if (dt != null && dt.Rows.Count > 0)
  5978. {
  5979. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  5980. newentity.DesignUserId = designMr;
  5981. string key = "aftersale_order_" + designMr;
  5982. if (RedisHelper.HasKey(key))
  5983. {
  5984. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5985. list.Add(newentity.ctid);
  5986. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5987. }
  5988. }
  5989. //账号正常
  5990. if (user["State"].ToString() == "0")
  5991. {
  5992. newentity.DesignUserId = entity.DesignUserId;
  5993. string key = "aftersale_order_" + entity.DesignUserId;
  5994. if (RedisHelper.HasKey(key))
  5995. {
  5996. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  5997. list.Add(newentity.ctid);
  5998. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  5999. }
  6000. }
  6001. }
  6002. }
  6003. }
  6004. if (entity.IsXianHuo == 1)
  6005. {
  6006. newentity.OrderState = 6;
  6007. entity.FinishPlaceTime = DateTime.Now;
  6008. }
  6009. }
  6010. if (ishav)
  6011. {
  6012. newentity.Update();
  6013. }
  6014. else
  6015. {
  6016. newentity.Create();
  6017. CeErpTradeCellExtend.createInfo(newentity.ctid, 30, 20);
  6018. }
  6019. if (st != "下单员")
  6020. {
  6021. designHelper.API_GetPrintData_CreateOrder(newentity);
  6022. }
  6023. }
  6024. //处理售后扩展
  6025. string resIdStr = GetPostString("ResponsibleUserId");
  6026. string refundFees = GetPostString("refundFrees");
  6027. int IsComplain = GetPostInt("isComplain");
  6028. int IsBad = GetPostInt("isBad");
  6029. string IsOriginal = GetPostString("isOriginal");
  6030. double diffResultPrice = GetPostDouble("diffResultPrice");
  6031. string textResult = GetPostString("textResult");
  6032. string supplierResponsible = GetPostString("supplierResponsible");
  6033. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6034. if (ceErpTradeAfterSaleExtend == null)
  6035. {
  6036. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6037. ceErpTradeAfterSaleExtend.tid = eid;
  6038. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6039. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6040. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6041. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6042. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6043. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6044. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6045. ceErpTradeAfterSaleExtend.Create();
  6046. }
  6047. else
  6048. {
  6049. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6050. {
  6051. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6052. }
  6053. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6054. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6055. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6056. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6057. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6058. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6059. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6060. ceErpTradeAfterSaleExtend.Update();
  6061. }
  6062. int gysid = GetPostInt("ResponsibleSupId");
  6063. entity.AfterSaleUserId = CurrentUser.UserID;
  6064. entity.ResponsibleUserId = resIdStr;
  6065. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6066. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6067. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6068. {
  6069. CeErpTradeResponsible.DelByTid(eid, -1);
  6070. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6071. int backNum = 0;
  6072. if (number != null)
  6073. {
  6074. backNum = number.BackNum;
  6075. }
  6076. char[] separator = { ',' };
  6077. string[] sArray = resIdStr.Split(separator);
  6078. string[] refundFreeList = { };
  6079. if (refundFees.Length > 0)
  6080. {
  6081. refundFreeList = refundFees.Split(separator);
  6082. }
  6083. int index = -1;
  6084. foreach (string i in sArray)
  6085. {
  6086. index++;
  6087. if (i.Length <= 0) continue;
  6088. char[] separator2 = { '_' };
  6089. string idstr = i.Split(separator2)[0];
  6090. string idtype = i.Split(separator2)[1];
  6091. double refudFree = 0;
  6092. if (refundFreeList.Length > 0)
  6093. {
  6094. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6095. }
  6096. if (idtype == "s")
  6097. {
  6098. isDesign = true;
  6099. designFree = refudFree;
  6100. }
  6101. int userId = Convert.ToInt32(idstr);
  6102. int type = 0;
  6103. if (idtype == "g")
  6104. {
  6105. type = 1;
  6106. }
  6107. if (idtype == "w")
  6108. {
  6109. type = 2;
  6110. }
  6111. if (idtype == "t")
  6112. {
  6113. type = 3;
  6114. }
  6115. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6116. if (ceErpTradeResponsible == null)
  6117. {
  6118. ceErpTradeResponsible = new CeErpTradeResponsible();
  6119. ceErpTradeResponsible.tid = eid;
  6120. ceErpTradeResponsible.UserId = userId;
  6121. ceErpTradeResponsible.createdTime = DateTime.Now;
  6122. ceErpTradeResponsible.type = type;
  6123. if (type == 1)
  6124. {
  6125. ceErpTradeResponsible.IsSup = 1;
  6126. }
  6127. if (type == 2)
  6128. {
  6129. ceErpTradeResponsible.IsFlow = 1;
  6130. }
  6131. }
  6132. ceErpTradeResponsible.RefundFee = refudFree;
  6133. ceErpTradeResponsible.VerifyState = 0;
  6134. if (userId == 2125 || idtype == "w")
  6135. {
  6136. ceErpTradeResponsible.VerifyState = 1;
  6137. }
  6138. if (idtype == "w" && userId == 101)
  6139. {
  6140. ceErpTradeResponsible.VerifyState = 0;
  6141. }
  6142. if (ceErpTradeResponsible.ID > 0)
  6143. {
  6144. ceErpTradeResponsible.Update();
  6145. }
  6146. else
  6147. {
  6148. ceErpTradeResponsible.Create();
  6149. }
  6150. if (isDesign)
  6151. {
  6152. responsibleId = ceErpTradeResponsible.ID;
  6153. }
  6154. }
  6155. CeErpTradeResponsible.NumByTid(backNum, eid);
  6156. }
  6157. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6158. if (ceErpTradeCellExtend != null)
  6159. {
  6160. ceErpTradeCellExtend.returnVisit = 0;
  6161. ceErpTradeCellExtend.Update();
  6162. }
  6163. if (entity.HandleTime != null)
  6164. {
  6165. if (entity.AfterSaleState == 1)
  6166. {
  6167. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6168. }
  6169. else
  6170. {
  6171. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6172. }
  6173. }
  6174. else
  6175. {
  6176. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6177. entity.HandleTime = DateTime.Now;
  6178. }
  6179. bool isCompale = false;
  6180. if (entity.AfterSaleState == 5)
  6181. {
  6182. isCompale = true;
  6183. entity.AfterSaleState = 3;
  6184. }
  6185. entity.AfterSaleSupplierState = 0;
  6186. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6187. {
  6188. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6189. }
  6190. string sImgs = GetPostString("img");
  6191. entity.AfterSaleSupplierImg = sImgs;
  6192. entity.supRefundType = GetPostString("supRefundType");
  6193. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6194. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6195. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6196. entity.AfterSaleMemoType = GetPostString("MemoType");
  6197. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6198. {
  6199. entity.AfterSaleSupplierState = 2;
  6200. }
  6201. string df = GetPostString("DeductFee");
  6202. if (df == "")
  6203. {
  6204. df = "0";
  6205. }
  6206. string rf = GetPostString("RefundFee");
  6207. if (rf == "")
  6208. {
  6209. rf = "0";
  6210. }
  6211. string pm = GetPostString("AfterSalePayment");
  6212. if (pm == "")
  6213. {
  6214. pm = "0";
  6215. }
  6216. entity.AfterSalePayment = Convert.ToDouble(pm);
  6217. entity.DeductFee = Convert.ToDouble(df);
  6218. entity.RefundFee = Convert.ToDouble(rf);
  6219. entity.Update();
  6220. string toState = GetPostString("ToState");
  6221. string original = GetPostString("isOriginal");
  6222. ApiVo apiVo = new ApiVo();
  6223. apiVo.orderNumber = entity.ctid;
  6224. apiVo.actionName = "afterDesign";
  6225. apiVo.orderRemarks = entity.AfterSaleMethod;
  6226. apiVo.reasonRemarks = entity.AfterSaleReason;
  6227. apiVo.isDesign = isDesign;
  6228. apiVo.designFree = designFree;
  6229. apiVo.responsibleId = responsibleId;
  6230. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6231. if (toState == "设计师")
  6232. {
  6233. apiVo.isOriginal = Convert.ToBoolean(original);
  6234. }
  6235. designHelper.API_WorkCore(apiVo);//afterDesign
  6236. CeErpMethod methodSql = new CeErpMethod();
  6237. methodSql.con = entity.AfterSaleMethod;
  6238. methodSql.addTime = DateTime.Now;
  6239. methodSql.Create();
  6240. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6241. CeErpMethod.ExecuteNonQuery(delsql);
  6242. if (isCompale)
  6243. {
  6244. aftersale_data_change(entity.ctid);
  6245. }
  6246. returnSuccessMsg("操作成功!");
  6247. return;
  6248. }
  6249. returnErrorMsg("找不到订单记录");
  6250. }
  6251. }
  6252. public void ins_erp_toresponsible()
  6253. {
  6254. if (UrlPostParmsCheck("ctid"))
  6255. {
  6256. string eid = GetPostString("ctid");
  6257. CeErpTradeCell entity = null;
  6258. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6259. if (entity != null)
  6260. {
  6261. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6262. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6263. {
  6264. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6265. return;
  6266. }
  6267. entity.AfterSalePreTime = DateTime.Now;
  6268. //预完成给售后主管审核客户问题直接完成
  6269. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null)
  6270. {
  6271. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) == 0)
  6272. {
  6273. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6274. }
  6275. }
  6276. entity.AfterSaleState = 2;
  6277. entity.Update();
  6278. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6279. aftersale_data_change(entity.ctid);
  6280. returnSuccessMsg("操作成功!");
  6281. return;
  6282. }
  6283. returnErrorMsg("找不到订单记录");
  6284. }
  6285. }
  6286. public void cancel_erp_aftersaleanddelnew()
  6287. {
  6288. if (UrlPostParmsCheck("ctid"))
  6289. {
  6290. string eid = GetPostString("ctid");
  6291. CeErpTradeCell entity = null;
  6292. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6293. if (entity != null)
  6294. {
  6295. entity.AfterSaleState = 0;
  6296. entity.AfterSaleReason = "";
  6297. entity.AfterSaleMethod = "";
  6298. entity.AfterSaleMemo = "";
  6299. entity.AfterSaleResponsible = "";
  6300. entity.ResponsibleUserId = "";
  6301. entity.DeductFee = 0;
  6302. entity.RefundFee = 0;
  6303. entity.IsArbitrate = 0;
  6304. CeErpTradeResponsible.DelByTid(eid, -1);
  6305. entity.Update();
  6306. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6307. if (after != null)
  6308. {
  6309. if (after.OrderState < 5)
  6310. CeErpTradeCell.DelByCtid("S_" + eid);
  6311. }
  6312. returnSuccessMsg("操作成功!");
  6313. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6314. return;
  6315. }
  6316. returnErrorMsg("找不到订单记录");
  6317. }
  6318. }
  6319. public void get_erp_aftersale_pregather()
  6320. {
  6321. List<string> lw = new List<string>();
  6322. int st = GetInt("st");
  6323. string tid = GetPostString("ctid");
  6324. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or orderSn = '{0}')", tid));
  6325. string shopname = GetPostString("shopname");
  6326. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6327. string buyernick = GetPostString("buyer_nick");
  6328. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6329. string sellermemo = GetPostString("seller_memo");
  6330. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6331. string orderState = GetPostString("orderState");
  6332. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6333. string reason = GetPostString("reason");
  6334. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6335. string method = GetPostString("method");
  6336. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6337. string handler = GetPostString("handler");
  6338. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6339. string handledate1 = GetPostString("handledate1");
  6340. string handledate2 = GetPostString("handledate2");
  6341. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6342. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6343. string supplier = GetPostString("supplier");
  6344. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6345. string responsible = GetPostString("responsibleman");
  6346. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6347. string customer = GetPostString("customer");
  6348. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6349. string design = GetPostString("design");
  6350. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6351. string afterMemoType = GetPostString("aftermemotype");
  6352. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6353. string afterSaleMemo = GetPostString("afterSaleMemo");
  6354. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6355. string afterresult = GetPostString("afterresult");
  6356. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6357. string poscode = CurrentUser.UserPost.Post.Code;
  6358. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6359. {
  6360. string shopid = CurrentUser.User.pemShop;
  6361. lw.Add(string.Format("shopId in ({0})", shopid));
  6362. }
  6363. var mainwhere = string.Join(" and ", lw.ToArray());
  6364. string ro_json = "";
  6365. string type = GetPostString("gather_type");
  6366. if (poscode == "AfterSale")
  6367. {
  6368. //处理中
  6369. if (type == "Handling")
  6370. {
  6371. 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) : ""));
  6372. DataTable dt = null;
  6373. try
  6374. {
  6375. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6376. }
  6377. catch (Exception e)
  6378. {
  6379. dt = new DataTable();
  6380. }
  6381. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt.Rows[0]["number"] }));
  6382. return;
  6383. }
  6384. if (type == "Wait")
  6385. {
  6386. //待处理
  6387. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6388. DataTable dt1 = null;
  6389. try
  6390. {
  6391. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6392. }
  6393. catch (Exception e)
  6394. {
  6395. dt1 = new DataTable();
  6396. }
  6397. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt1.Rows[0]["number"] }));
  6398. return;
  6399. }
  6400. if (type == "back")
  6401. {
  6402. //打回
  6403. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6404. DataTable dt2 = null;
  6405. try
  6406. {
  6407. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6408. }
  6409. catch (Exception e)
  6410. {
  6411. dt2 = new DataTable();
  6412. }
  6413. returnSuccess(JsonConvert.SerializeObject(new { back = dt2.Rows[0]["number"] }));
  6414. return;
  6415. }
  6416. if (type == "preCompletion")
  6417. {
  6418. //预完成
  6419. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6420. DataTable dt3 = null;
  6421. try
  6422. {
  6423. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6424. }
  6425. catch (Exception e)
  6426. {
  6427. dt3 = new DataTable();
  6428. }
  6429. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = dt3.Rows[0]["number"] }));
  6430. return;
  6431. }
  6432. if (type == "documentary")
  6433. {
  6434. //跟单中
  6435. 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) : ""));
  6436. DataTable dt4 = null;
  6437. try
  6438. {
  6439. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6440. }
  6441. catch (Exception e)
  6442. {
  6443. dt4 = new DataTable();
  6444. }
  6445. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt4.Rows[0]["number"] }));
  6446. return;
  6447. }
  6448. if (type == "reBack")
  6449. {
  6450. //被打回
  6451. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6452. DataTable dt1 = null;
  6453. try
  6454. {
  6455. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6456. }
  6457. catch (Exception e)
  6458. {
  6459. dt1 = new DataTable();
  6460. }
  6461. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6462. return;
  6463. }
  6464. }
  6465. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6466. {
  6467. if (type == "puBack")
  6468. {
  6469. //退回
  6470. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6471. DataTable dt = null;
  6472. try
  6473. {
  6474. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6475. }
  6476. catch (Exception e)
  6477. {
  6478. dt = new DataTable();
  6479. }
  6480. returnSuccess(JsonConvert.SerializeObject(new { puBack = dt.Rows[0]["number"] }));
  6481. return;
  6482. }
  6483. if (type == "reBack")
  6484. {
  6485. //打回
  6486. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6487. DataTable dt1 = null;
  6488. try
  6489. {
  6490. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6491. }
  6492. catch (Exception e)
  6493. {
  6494. dt1 = new DataTable();
  6495. }
  6496. returnSuccess(JsonConvert.SerializeObject(new { reBack = dt1.Rows[0]["number"] }));
  6497. return;
  6498. }
  6499. if (type == "examEd")
  6500. {
  6501. //已审核
  6502. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6503. DataTable dt2 = null;
  6504. try
  6505. {
  6506. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6507. }
  6508. catch (Exception e)
  6509. {
  6510. dt2 = new DataTable();
  6511. }
  6512. returnSuccess(JsonConvert.SerializeObject(new { examEd = dt2.Rows[0]["number"] }));
  6513. return;
  6514. }
  6515. if (type == "waitExam")
  6516. {
  6517. //待审核
  6518. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6519. DataTable dt3 = null;
  6520. try
  6521. {
  6522. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6523. }
  6524. catch (Exception e)
  6525. {
  6526. dt3 = new DataTable();
  6527. }
  6528. returnSuccess(JsonConvert.SerializeObject(new { waitExam = dt3.Rows[0]["number"] }));
  6529. return;
  6530. }
  6531. if (type == "Handling")
  6532. {
  6533. //处理中
  6534. 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) : ""));
  6535. DataTable dt4 = null;
  6536. try
  6537. {
  6538. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6539. }
  6540. catch (Exception e)
  6541. {
  6542. dt4 = new DataTable();
  6543. }
  6544. returnSuccess(JsonConvert.SerializeObject(new { Handling = dt4.Rows[0]["number"] }));
  6545. return;
  6546. }
  6547. if (type == "Wait")
  6548. {
  6549. //待处理
  6550. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6551. DataTable dt5 = null;
  6552. try
  6553. {
  6554. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  6555. }
  6556. catch (Exception e)
  6557. {
  6558. dt5 = new DataTable();
  6559. }
  6560. returnSuccess(JsonConvert.SerializeObject(new { Wait = dt5.Rows[0]["number"] }));
  6561. return;
  6562. }
  6563. if (type == "documentary")
  6564. {
  6565. //跟单中
  6566. 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) : ""));
  6567. DataTable dt6 = null;
  6568. try
  6569. {
  6570. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  6571. }
  6572. catch (Exception e)
  6573. {
  6574. dt6 = new DataTable();
  6575. }
  6576. returnSuccess(JsonConvert.SerializeObject(new { documentary = dt6.Rows[0]["number"] }));
  6577. return;
  6578. }
  6579. }
  6580. returnSuccess(ro_json);
  6581. }
  6582. public void end_erp_aftersale()
  6583. {
  6584. if (UrlPostParmsCheck("ctid"))
  6585. {
  6586. string eid = GetPostString("ctid");
  6587. CeErpTradeCell entity = null;
  6588. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6589. if (entity != null)
  6590. {
  6591. string stype = GetPostString("stype");
  6592. string typeStr = stype;
  6593. entity.AfterSaleState = 4;
  6594. entity.FinishAfterSaleTime = DateTime.Now;
  6595. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  6596. entity.Update();
  6597. ApiVo apiVo = new ApiVo();
  6598. apiVo.orderNumber = entity.ctid;
  6599. apiVo.actionName = "afterOver";
  6600. designHelper.API_WorkCore(apiVo); //afterOver
  6601. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  6602. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6603. CeErpSukuraData.createInfo(entity.ctid, 8);
  6604. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  6605. returnSuccessMsg("操作成功!");
  6606. return;
  6607. }
  6608. returnErrorMsg("找不到订单记录");
  6609. }
  6610. }
  6611. public void ins_erp_finishaftersale()
  6612. {
  6613. if (UrlPostParmsCheck("id"))
  6614. {
  6615. string eid = GetPostString("id");
  6616. CeErpTradeResponsible entity = null;
  6617. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6618. if (entity != null)
  6619. {
  6620. entity.VerifyState = 1;
  6621. entity.VerifyTime = DateTime.Now;
  6622. entity.Update();
  6623. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  6624. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  6625. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6626. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  6627. if (dt.Rows.Count <= 0)
  6628. {
  6629. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate() where ctid='" + entity.tid + "'";
  6630. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  6631. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6632. CeErpSukuraData.createInfo(entity.tid, 8);
  6633. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  6634. {
  6635. CeErpDesignerBill.Del(entity.tid);
  6636. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6637. }
  6638. }
  6639. returnSuccessMsg("操作成功!");
  6640. return;
  6641. }
  6642. returnErrorMsg("找不到订单记录");
  6643. }
  6644. }
  6645. public void upd_erp_arbitrateaftersale()
  6646. {
  6647. if (UrlPostParmsCheck("id"))
  6648. {
  6649. string eid = GetPostString("id");
  6650. CeErpTradeResponsible entity = null;
  6651. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  6652. if (entity != null)
  6653. {
  6654. entity.IsArbitrate = 1;
  6655. entity.ArbitradeMemo = GetPostString("reason");
  6656. entity.VerifyState = 2;
  6657. entity.Update();
  6658. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  6659. if (tradecell != null)
  6660. {
  6661. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  6662. tradecell.IsArbitrate = 1;
  6663. tradecell.Update();
  6664. }
  6665. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  6666. returnSuccessMsg("操作成功!");
  6667. return;
  6668. }
  6669. returnErrorMsg("找不到订单记录");
  6670. }
  6671. }
  6672. public void upd_erp_backaftersale()
  6673. {
  6674. if (UrlPostParmsCheck("tid"))
  6675. {
  6676. string eid = GetPostString("tid");
  6677. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6678. int backNum = 0;
  6679. if (number != null)
  6680. {
  6681. backNum = number.BackNum;
  6682. }
  6683. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  6684. CeErpTradeCell entity = null;
  6685. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6686. if (entity != null)
  6687. {
  6688. entity.AfterSaleBackReason = GetPostString("backreason");
  6689. entity.AfterSaleState = 1;
  6690. entity.AfterSaleSupplierState = 0;
  6691. entity.Update();
  6692. returnSuccessMsg("操作成功!");
  6693. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  6694. return;
  6695. }
  6696. returnErrorMsg("找不到订单记录");
  6697. }
  6698. }
  6699. public void get_erp_supplieraftersalelist()
  6700. {
  6701. DataStruct dStruct = GetPostStruct();
  6702. List<string> lw = new List<string>();
  6703. string tid = GetPostString("ctid");
  6704. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6705. string shopname = GetPostString("shopname");
  6706. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6707. string buyernick = GetPostString("buyer_nick");
  6708. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6709. string sellermemo = GetPostString("seller_memo");
  6710. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6711. string orderState = GetPostString("orderState");
  6712. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6713. string afterState = GetPostString("afterstate");
  6714. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6715. string date1 = GetPostString("date1");
  6716. string date2 = GetPostString("date2");
  6717. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6718. if (dw.Length > 0) lw.Add(dw);
  6719. string price1 = GetPostString("price1");
  6720. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6721. string price2 = GetPostString("price2");
  6722. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6723. string reason = GetPostString("reason");
  6724. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6725. string method = GetPostString("method");
  6726. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6727. string handledate1 = GetPostString("handledate1");
  6728. string handledate2 = GetPostString("handledate2");
  6729. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6730. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6731. string handler = GetPostString("handler");
  6732. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6733. string afterdate1 = GetPostString("afterdate1");
  6734. string afterdate2 = GetPostString("afterdate2");
  6735. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6736. if (afterDate.Length > 0) lw.Add(afterDate);
  6737. string customer = GetPostString("customer");
  6738. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6739. string design = GetPostString("design");
  6740. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6741. string afterMemoType = GetPostString("aftermemotype");
  6742. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6743. string vstate = GetPostString("vstate");
  6744. if (vstate.Length > 0)
  6745. {
  6746. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6747. }
  6748. lw.Add(string.Format("AfterSaleState>={0}", 2));
  6749. string supplier = GetPostString("supplier");
  6750. int supid = commonHelper.getSupplierIDByName(supplier);
  6751. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  6752. string posCode = CurrentUser.UserPost.Post.Code;
  6753. if (posCode == "Supplier")
  6754. {
  6755. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6756. }
  6757. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  6758. {
  6759. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  6760. }
  6761. else
  6762. {
  6763. lw.Add(string.Format("AfterSaleResSupId != 0"));
  6764. }
  6765. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6766. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6767. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6768. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6769. writeGridDataTableJson(dStruct.TotalCount, dt);
  6770. }
  6771. public void upd_erp_supverifyaftersale()
  6772. {
  6773. if (UrlPostParmsCheck("id"))
  6774. {
  6775. string id = GetPostString("id");
  6776. int st = GetPostInt("afterstate");
  6777. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6778. CeErpTradeCell entity = null;
  6779. if (ceErpTradeResponsible != null)
  6780. {
  6781. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6782. }
  6783. string afmemo = GetPostString("supmemo");
  6784. string image = GetPostString("image");
  6785. if (entity != null)
  6786. {
  6787. entity.AfterSaleSupplierState = st;
  6788. entity.AfterSaleSupplierMemo = afmemo;
  6789. entity.AfterSaleSupplierState = st;
  6790. if (st == 1)
  6791. {
  6792. ceErpTradeResponsible.VerifyState = 1;
  6793. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6794. ceErpTradeResponsible.Update();
  6795. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6796. if (isAll)
  6797. {
  6798. entity.AfterSaleState = 4;
  6799. entity.FinishAfterSaleTime = DateTime.Now;
  6800. }
  6801. }
  6802. else
  6803. {
  6804. CeErpTradeResponsible.dateByTid(entity.ctid);
  6805. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6806. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6807. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6808. if (num <= 1)
  6809. {
  6810. entity.AfterSaleState = 1;
  6811. }
  6812. else
  6813. {
  6814. entity.AfterSaleState = 5;
  6815. }
  6816. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6817. if (ceErpTradeAfterSaleExtend != null)
  6818. {
  6819. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6820. if (entity.AfterSaleState == 1)
  6821. {
  6822. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6823. }
  6824. else
  6825. {
  6826. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6827. }
  6828. ceErpTradeAfterSaleExtend.Update();
  6829. }
  6830. else
  6831. {
  6832. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6833. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6834. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6835. if (entity.AfterSaleState == 1)
  6836. {
  6837. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6838. }
  6839. else
  6840. {
  6841. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6842. }
  6843. ceErpTradeAfterSaleExtend.Create();
  6844. }
  6845. }
  6846. if (entity.AfterSaleState == 4)
  6847. {
  6848. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  6849. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  6850. {
  6851. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  6852. }
  6853. ApiVo apiVo = new ApiVo();
  6854. apiVo.orderNumber = entity.ctid;
  6855. apiVo.actionName = "afterOver";
  6856. designHelper.API_WorkCore(apiVo); //afterOver
  6857. }
  6858. entity.Update();
  6859. returnSuccessMsg("操作成功!");
  6860. CeErpSukuraData.createInfo(entity.ctid, 8);
  6861. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6862. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6863. return;
  6864. }
  6865. returnErrorMsg("找不到订单记录");
  6866. }
  6867. }
  6868. public void upd_erp_masteraftersale()
  6869. {
  6870. if (UrlPostParmsCheck("id"))
  6871. {
  6872. string id = GetPostString("id");
  6873. int st = GetPostInt("afterstate");
  6874. string afmemo = GetPostString("supmemo");
  6875. string image = GetPostString("image");
  6876. string textResult = GetPostString("textResult");
  6877. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6878. if (ceErpTradeResponsible != null)
  6879. {
  6880. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  6881. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6882. ceErpTradeResponsible.Update();
  6883. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6884. if (entity != null)
  6885. {
  6886. entity.AfterSaleSupplierState = st;
  6887. entity.AfterSaleSupplierMemo = afmemo;
  6888. if (st == 1)
  6889. {
  6890. }
  6891. else
  6892. {
  6893. CeErpTradeResponsible.dateByTid(entity.ctid);
  6894. //退回到售后
  6895. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  6896. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6897. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6898. if (num <= 1)
  6899. {
  6900. entity.AfterSaleState = 1;
  6901. }
  6902. else
  6903. {
  6904. entity.AfterSaleState = 5;
  6905. }
  6906. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6907. if (ceErpTradeAfterSaleExtend != null)
  6908. {
  6909. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6910. if (entity.AfterSaleState == 1)
  6911. {
  6912. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6913. }
  6914. else
  6915. {
  6916. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6917. }
  6918. ceErpTradeAfterSaleExtend.Update();
  6919. }
  6920. else
  6921. {
  6922. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6923. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6924. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6925. if (entity.AfterSaleState == 1)
  6926. {
  6927. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  6928. }
  6929. else
  6930. {
  6931. ceErpTradeAfterSaleExtend.DisagreeTime = null;
  6932. }
  6933. ceErpTradeAfterSaleExtend.Create();
  6934. }
  6935. }
  6936. entity.Update();
  6937. returnSuccessMsg("操作成功!");
  6938. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  6939. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  6940. return;
  6941. }
  6942. }
  6943. returnErrorMsg("找不到订单记录");
  6944. }
  6945. }
  6946. public void upd_erp_personaftersale()
  6947. {
  6948. if (UrlPostParmsCheck("id"))
  6949. {
  6950. string id = GetPostString("id");
  6951. int st = GetPostInt("afterstate");
  6952. string afmemo = GetPostString("supmemo");
  6953. string image = GetPostString("image");
  6954. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  6955. if (ceErpTradeResponsible != null)
  6956. {
  6957. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  6958. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  6959. ceErpTradeResponsible.Update();
  6960. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  6961. if (entity != null)
  6962. {
  6963. entity.AfterSaleSupplierMemo = afmemo;
  6964. entity.AfterSaleSupplierState = st;
  6965. if (st == 1)
  6966. {
  6967. bool isAll = commonHelper.tradeResponsibleAll(entity);
  6968. if (isAll)
  6969. {
  6970. entity.AfterSaleState = 4;
  6971. entity.FinishAfterSaleTime = DateTime.Now;
  6972. }
  6973. }
  6974. else
  6975. {
  6976. CeErpTradeResponsible.dateByTid(entity.ctid);
  6977. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6978. if (ceErpTradeAfterSaleExtend != null)
  6979. {
  6980. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6981. ceErpTradeAfterSaleExtend.Update();
  6982. }
  6983. else
  6984. {
  6985. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6986. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  6987. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  6988. ceErpTradeAfterSaleExtend.Create();
  6989. }
  6990. //退回到主管
  6991. //entity.AfterSaleState = 2;
  6992. }
  6993. if (entity.AfterSaleState == 4)
  6994. {
  6995. ApiVo apiVo = new ApiVo();
  6996. apiVo.orderNumber = entity.ctid;
  6997. apiVo.actionName = "afterOver";
  6998. designHelper.API_WorkCore(apiVo); //afterOver
  6999. }
  7000. entity.Update();
  7001. returnSuccessMsg("操作成功!");
  7002. CeErpSukuraData.createInfo(entity.ctid, 8);
  7003. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7004. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7005. return;
  7006. }
  7007. }
  7008. returnErrorMsg("找不到订单记录");
  7009. }
  7010. }
  7011. public void set_erp_supplierrefundtag()
  7012. {
  7013. if (UrlPostParmsCheck("ctid"))
  7014. {
  7015. string eid = GetPostString("ctid");
  7016. CeErpTradeCell entity = null;
  7017. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7018. if (entity != null)
  7019. {
  7020. entity.IsSupplierRefund = GetPostInt("tag");
  7021. entity.Update();
  7022. returnSuccessMsg("操作成功!");
  7023. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7024. return;
  7025. }
  7026. returnErrorMsg("找不到订单记录");
  7027. }
  7028. }
  7029. public void get_erp_refundlist()
  7030. {
  7031. DataStruct dStruct = GetPostStruct();
  7032. List<string> lw = new List<string>();
  7033. string tid = GetPostString("tid");
  7034. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7035. //string rid = GetPostString("refund_id");
  7036. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7037. string shopname = GetPostString("shopname");
  7038. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7039. string buyernick = GetPostString("buyer_nick");
  7040. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7041. string customer = GetPostString("customer");
  7042. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7043. string design = GetPostString("design");
  7044. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7045. string sellermemo = GetPostString("seller_memo");
  7046. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7047. //string date1 = GetPostString("date1");
  7048. //string date2 = GetPostString("date2");
  7049. //string dateType = GetPostString("dateType");
  7050. //if (dateType.Length > 0)
  7051. //{
  7052. // if (dateType == "1001") dateType = "0";
  7053. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7054. // if (searchDT.Count == 2)
  7055. // {
  7056. // date1 = searchDT[0].ToString();
  7057. // date2 = searchDT[1].ToString();
  7058. // }
  7059. //}
  7060. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7061. //if (dw.Length > 0) lw.Add(dw);
  7062. string redate1 = GetPostString("refunddate1");
  7063. string redate2 = GetPostString("refunddate2");
  7064. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7065. if (dwdate.Length > 0) lw.Add(dwdate);
  7066. string price1 = GetPostString("price1");
  7067. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7068. string price2 = GetPostString("price2");
  7069. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7070. string ispartrefund = GetPostString("ispartrefund");
  7071. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7072. string refundState = GetPostString("refundvstate");
  7073. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7074. int st = GetInt("st");
  7075. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7076. {
  7077. string responsible = GetPostString("responsibleman");
  7078. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7079. lw.Add(string.Format("RefundState>={0}", st));
  7080. string code = CurrentUser.UserPost.Post.Code;
  7081. if (code == "CustomerService")
  7082. {
  7083. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7084. }
  7085. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7086. {
  7087. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7088. }
  7089. else if (code == "Place" || code == "PlaceMr")
  7090. {
  7091. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7092. }
  7093. dStruct.Order = "RefundState asc,created desc";
  7094. }
  7095. else if (st == 10)
  7096. {
  7097. string responsible = GetPostString("responsibleman");
  7098. if (responsible == "空白")
  7099. {
  7100. lw.Add(string.Format("ResponsibleUserName = ''"));
  7101. }
  7102. else if (responsible.Length > 0)
  7103. {
  7104. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7105. }
  7106. lw.Add(string.Format("RefundState>=0"));
  7107. dStruct.Order = "created desc";
  7108. }
  7109. else
  7110. {
  7111. string responsible = GetPostString("responsibleman");
  7112. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7113. lw.Add(string.Format("RefundState={0}", st));
  7114. dStruct.Order = "created desc";
  7115. }
  7116. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7117. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7118. dt.Columns.Add("refund_fees");
  7119. foreach (DataRow dr in dt.Rows)
  7120. {
  7121. String status = dr["status"].ToString();
  7122. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7123. {
  7124. dr["refund_fees"] = dr["refund_fee"];
  7125. }
  7126. else
  7127. {
  7128. dr["refund_fees"] = "0.0";
  7129. }
  7130. }
  7131. writeGridDataTableJson(dStruct.TotalCount, dt);
  7132. }
  7133. public void handle_erp_refundtag()
  7134. {
  7135. if (UrlPostParmsCheck("refund_id"))
  7136. {
  7137. string eid = GetPostString("refund_id");
  7138. string respMan = GetPostString("ResponsibleName");
  7139. if (respMan.Length <= 0)
  7140. {
  7141. returnErrorMsg("责任人不能为空");
  7142. return;
  7143. }
  7144. CeErpTradeRefund entity = null;
  7145. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7146. if (entity != null)
  7147. {
  7148. entity.ResponsibleUserName = respMan;
  7149. string userid = GetPostString("ResponsibleUserId");
  7150. if (userid.Length > 0)
  7151. {
  7152. entity.ResponsibleUserId = userid;
  7153. }
  7154. entity.Memo = GetPostString("Memo");
  7155. if (respMan.IndexOf("客服") != -1 ||
  7156. respMan.IndexOf("设计师") != -1 ||
  7157. respMan.IndexOf("下单员") != -1)
  7158. {
  7159. entity.RefundState = 2;
  7160. }
  7161. else
  7162. {
  7163. entity.RefundState = 3;
  7164. }
  7165. entity.modified = DateTime.Now;
  7166. entity.Update();
  7167. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7168. returnSuccessMsg("操作成功!");
  7169. return;
  7170. }
  7171. returnErrorMsg("找不到订单记录");
  7172. }
  7173. }
  7174. public void upd_erp_refundverify()
  7175. {
  7176. if (UrlPostParmsCheck("refund_id"))
  7177. {
  7178. string eid = GetPostString("refund_id");
  7179. CeErpTradeRefund entity = null;
  7180. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7181. if (entity != null)
  7182. {
  7183. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7184. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7185. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7186. {
  7187. entity.RefundState = 2;
  7188. }
  7189. else
  7190. {
  7191. entity.RefundState = 3;
  7192. }
  7193. entity.Update();
  7194. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7195. returnSuccessMsg("操作成功!");
  7196. return;
  7197. }
  7198. returnErrorMsg("找不到订单记录");
  7199. }
  7200. }
  7201. public void upd_erp_refundapprove()
  7202. {
  7203. if (UrlPostParmsCheck("refund_id"))
  7204. {
  7205. string eid = GetPostString("refund_id");
  7206. CeErpTradeRefund entity = null;
  7207. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7208. if (entity != null)
  7209. {
  7210. int apr = GetPostInt("approve");
  7211. if (apr == 0)
  7212. {
  7213. entity.RefundState = 1;
  7214. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7215. }
  7216. else if (apr == 1)
  7217. {
  7218. entity.RefundState = 3;
  7219. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7220. }
  7221. entity.modified = DateTime.Now;
  7222. entity.Update();
  7223. returnSuccessMsg("操作成功!");
  7224. return;
  7225. }
  7226. returnErrorMsg("找不到订单记录");
  7227. }
  7228. }
  7229. public void get_erp_billlist()
  7230. {
  7231. DataStruct dStruct = GetPostStruct();
  7232. List<string> lw = new List<string>();
  7233. string title = GetPostString("title");
  7234. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7235. string tid = GetPostString("tid");
  7236. string tids = GetPostString("tids");
  7237. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7238. if (tids.Length > 0)
  7239. {
  7240. tids = "'" + tids + "'";
  7241. tids = tids.Replace(",", "','");
  7242. lw.Add(string.Format("tid in ({0})", tids));
  7243. }
  7244. string shopname = GetPostString("shopname");
  7245. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7246. string buyernick = GetPostString("buyer_nick");
  7247. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7248. string customer = GetPostString("customer");
  7249. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7250. string date1 = GetPostString("date1");
  7251. string date2 = GetPostString("date2");
  7252. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7253. if (dw.Length > 0) lw.Add(dw);
  7254. string price1 = GetPostString("price1");
  7255. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7256. string price2 = GetPostString("price2");
  7257. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7258. string returndate1 = GetPostString("returndate1");
  7259. string returndate2 = GetPostString("returndate2");
  7260. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7261. if (dw1.Length > 0) lw.Add(dw1);
  7262. string billtype = GetPostString("billtype");
  7263. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7264. string billstate = GetPostString("billstate");
  7265. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7266. string usershop = CurrentUser.User.pemShop;
  7267. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7268. dStruct.Order = "createTime desc";
  7269. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7270. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7271. //foreach (DataRow dr in dt.Rows)
  7272. //{
  7273. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7274. //}
  7275. writeGridDataTableJson(dStruct.TotalCount, dt);
  7276. }
  7277. public void modify_erp_billinfo()
  7278. {
  7279. if (UrlPostParmsCheck("ID"))
  7280. {
  7281. string eid = GetPostString("ID");
  7282. CeErpBill bill_entity = null;
  7283. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7284. if (bill_entity != null)
  7285. {
  7286. bill_entity.tid = GetPostString("tid");
  7287. bill_entity.title = GetPostString("title");
  7288. bill_entity.tax = GetPostString("tax");
  7289. bill_entity.bank = GetPostString("bank");
  7290. bill_entity.bankac = GetPostString("bankac");
  7291. bill_entity.address = GetPostString("address");
  7292. bill_entity.phone = GetPostString("phone");
  7293. bill_entity.price = GetPostString("price");
  7294. bill_entity.productId = GetPostInt("ProductName");
  7295. bill_entity.num = GetPostInt("num");
  7296. bill_entity.unit = GetPostString("unit");
  7297. bill_entity.type = GetPostString("type");
  7298. bill_entity.sendType = GetPostString("SendType");
  7299. bill_entity.email = GetPostString("email");
  7300. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7301. bill_entity.shopName = GetPostString("ShopName");
  7302. bill_entity.applymemo = GetPostString("applymemo");
  7303. bill_entity.modifyTime = DateTime.Now;
  7304. bill_entity.createTime = DateTime.Now;
  7305. bill_entity.state = 0;
  7306. bill_entity.Update();
  7307. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7308. returnSuccessMsg("发票修改成功!");
  7309. return;
  7310. }
  7311. returnErrorMsg("找不到对应记录");
  7312. }
  7313. }
  7314. public void set_erp_invoicing()
  7315. {
  7316. if (UrlPostParmsCheck("id"))
  7317. {
  7318. try
  7319. {
  7320. string eid = GetPostString("id");
  7321. CeErpBill bill_entity = null;
  7322. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7323. if (bill_entity != null)
  7324. {
  7325. int ComId = GetPostInt("ComId");
  7326. //string memo = GetPostString("Memo");
  7327. int allInfo = GetPostInt("allinfo");
  7328. string clert = CurrentUser.User.Name;
  7329. //string detailValue = GetPostString("detailvalue");
  7330. string billId = bill_entity.billOrderId;
  7331. string[] billIdList = billId.Split(',');
  7332. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7333. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7334. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7335. {
  7336. billCount += 1;
  7337. }
  7338. if (billId.Length <= 0 || billIdList.Length != billCount)
  7339. {
  7340. bill_entity.billOrderId = "";
  7341. string prebill = "ltb";
  7342. for (int idx = 1; idx <= billCount; idx++)
  7343. {
  7344. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7345. string billoid = prebill + idx + dtstr;
  7346. bill_entity.billOrderId += billoid;
  7347. if (idx < billCount)
  7348. {
  7349. bill_entity.billOrderId += ",";
  7350. }
  7351. }
  7352. }
  7353. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7354. if (bill_entity.state == 5)
  7355. {
  7356. string errMsg = bill_entity.failerror;
  7357. string[] errlist = errMsg.Split('|');
  7358. string[] errTags = new string[errlist.Length];
  7359. for (int itag = 0; itag < errlist.Length; itag++)
  7360. {
  7361. if (errlist[itag].Length <= 0) continue;
  7362. errTags[itag] = errlist[itag].Split('&')[0];
  7363. }
  7364. for (int iii = 0; iii < errTags.Length; iii++)
  7365. {
  7366. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7367. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7368. if (billOrderList.Length >= erroBillOrderTag)
  7369. {
  7370. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7371. if (needModifyBillId.Length <= 19)
  7372. {
  7373. needModifyBillId = needModifyBillId + "1";
  7374. }
  7375. else
  7376. {
  7377. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7378. last = last + 1;
  7379. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7380. }
  7381. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7382. }
  7383. }
  7384. }
  7385. bool isHaveBillSucces = false;
  7386. string totalRes = "";
  7387. bill_entity.failerror = "";
  7388. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7389. {
  7390. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7391. totalRes += res;
  7392. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7393. {
  7394. isHaveBillSucces = true;
  7395. bill_entity.comId = ComId;
  7396. bill_entity.state = 1;
  7397. bill_entity.executeTime = DateTime.Now;
  7398. bill_entity.executeUser = clert;
  7399. }
  7400. else
  7401. {
  7402. bill_entity.state = 5;
  7403. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7404. }
  7405. }
  7406. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7407. bill_entity.Update();
  7408. if (isHaveBillSucces)
  7409. {
  7410. StringBuilder sql = new StringBuilder();
  7411. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  7412. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7413. }
  7414. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  7415. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  7416. {
  7417. returnErrorMsg("开票失败");
  7418. }
  7419. else
  7420. returnSuccessMsg("发票开具中,稍后刷新查看!");
  7421. return;
  7422. }
  7423. returnErrorMsg("找不到对应记录");
  7424. }
  7425. catch (Exception ex)
  7426. {
  7427. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  7428. returnErrorMsg("操作失败");
  7429. }
  7430. }
  7431. }
  7432. public void get_erp_invoicing_back()
  7433. {
  7434. if (UrlPostParmsCheck("id"))
  7435. {
  7436. try
  7437. {
  7438. string id = GetPostString("id");
  7439. CeErpBill entiy = CeErpBill.Get(id);
  7440. if (entiy != null)
  7441. {
  7442. if (entiy.state == 0)
  7443. {
  7444. returnErrorMsg("发票还未开具");
  7445. return;
  7446. }
  7447. string[] billOrderList = entiy.billOrderId.Split(',');
  7448. int iTag = 0;
  7449. entiy.fplsh = "";
  7450. entiy.fpdm = "";
  7451. entiy.fphm = "";
  7452. foreach (string billOrderId in billOrderList)
  7453. {
  7454. iTag++;
  7455. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7456. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7457. {
  7458. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7459. try
  7460. {
  7461. Invoicing_get_response_Obj iObj = null;
  7462. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7463. if (iObj != null)
  7464. {
  7465. entiy.state = 2;
  7466. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7467. entiy.fpdm += iObj.list[0].c_fpdm;
  7468. entiy.fphm += iObj.list[0].c_fphm;
  7469. if (iTag < billOrderList.Length)
  7470. {
  7471. entiy.fplsh += ",";
  7472. entiy.fpdm += ",";
  7473. entiy.fphm += ",";
  7474. }
  7475. entiy.Update();
  7476. }
  7477. StringBuilder sql = new StringBuilder();
  7478. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7479. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7480. returnSuccessMsg("开票成功");
  7481. }
  7482. catch (Exception ex)
  7483. {
  7484. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  7485. }
  7486. return;
  7487. }
  7488. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  7489. {
  7490. var res_obj = new
  7491. {
  7492. data = "开票中"
  7493. };
  7494. string ro_json = JsonConvert.SerializeObject(res_obj);
  7495. returnSuccess(ro_json);
  7496. return;
  7497. }
  7498. else
  7499. {
  7500. int eidx = res.IndexOf("c_resultmsg");
  7501. int lidx = res.IndexOf("c_status");
  7502. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  7503. entiy.state = 5;
  7504. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7505. entiy.Update();
  7506. returnErrorMsg("开票失败");
  7507. return;
  7508. }
  7509. }
  7510. }
  7511. }
  7512. catch (Exception ex)
  7513. {
  7514. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  7515. }
  7516. return;
  7517. }
  7518. }
  7519. public void get_erp_invoicing()
  7520. {
  7521. if (UrlPostParmsCheck("id"))
  7522. {
  7523. try
  7524. {
  7525. string id = GetPostString("id");
  7526. CeErpBill entiy = CeErpBill.Get(id);
  7527. if (entiy != null)
  7528. {
  7529. if (entiy.state == 0)
  7530. {
  7531. returnErrorMsg("发票还未开具");
  7532. return;
  7533. }
  7534. if (entiy.sendType == "纸质发票")
  7535. {
  7536. if (entiy.img.Length <= 0)
  7537. {
  7538. returnErrorMsg("查无纸质发票");
  7539. return;
  7540. }
  7541. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  7542. returnSuccess(returnres);
  7543. return;
  7544. }
  7545. string[] billOrderList = entiy.billOrderId.Split(',');
  7546. int iTag = 0;
  7547. string fpUrl = "";
  7548. entiy.fplsh = "";
  7549. entiy.fpdm = "";
  7550. entiy.fphm = "";
  7551. foreach (string billOrderId in billOrderList)
  7552. {
  7553. iTag++;
  7554. string res = taobaoHelper.get_invoicing(id, billOrderId);
  7555. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  7556. {
  7557. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  7558. Invoicing_get_response_Obj iObj = null;
  7559. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  7560. if (iObj != null)
  7561. {
  7562. //entiy.state = 2;
  7563. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  7564. entiy.fpdm += iObj.list[0].c_fpdm;
  7565. entiy.fphm += iObj.list[0].c_fphm;
  7566. if (iTag < billOrderList.Length)
  7567. {
  7568. entiy.fplsh += ",";
  7569. entiy.fpdm += ",";
  7570. entiy.fphm += ",";
  7571. }
  7572. entiy.Update();
  7573. fpUrl += iObj.list[0].c_url + ",";
  7574. }
  7575. //returnSuccess(res);
  7576. StringBuilder sql = new StringBuilder();
  7577. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  7578. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  7579. }
  7580. else
  7581. {
  7582. int eidx = res.IndexOf("c_resultmsg");
  7583. //int lidx = res.IndexOf("c_status");
  7584. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  7585. //开票失败
  7586. entiy.state = 5;
  7587. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  7588. entiy.Update();
  7589. returnErrorMsg("开票失败");
  7590. return;
  7591. }
  7592. }
  7593. var returnObj = new
  7594. {
  7595. data = fpUrl
  7596. };
  7597. string ro_json = JsonConvert.SerializeObject(returnObj);
  7598. returnSuccess(ro_json);
  7599. }
  7600. }
  7601. catch (Exception ex)
  7602. {
  7603. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  7604. }
  7605. return;
  7606. }
  7607. }
  7608. public void save_erp_billimg()
  7609. {
  7610. if (UrlPostParmsCheck("id"))
  7611. {
  7612. string eid = GetPostString("id");
  7613. CeErpBill bill_entity = null;
  7614. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7615. if (bill_entity != null)
  7616. {
  7617. bill_entity.img = GetPostString("img");
  7618. bill_entity.executeTime = DateTime.Now;
  7619. bill_entity.state = 2;
  7620. bill_entity.Update();
  7621. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  7622. returnSuccessMsg("保存成功");
  7623. }
  7624. return;
  7625. }
  7626. }
  7627. public void upd_erp_billreturnback()
  7628. {
  7629. if (UrlPostParmsCheck("id"))
  7630. {
  7631. int eid = GetPostInt("id");
  7632. CeErpBill bill_entity = null;
  7633. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7634. if (bill_entity != null)
  7635. {
  7636. bill_entity.state = 3;
  7637. bill_entity.returnReason = GetPostString("reason");
  7638. bill_entity.Update();
  7639. returnSuccessMsg("驳回成功!");
  7640. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  7641. }
  7642. return;
  7643. }
  7644. }
  7645. public void cancel_erp_bill()
  7646. {
  7647. if (UrlPostParmsCheck("id"))
  7648. {
  7649. int eid = GetPostInt("id");
  7650. int detailValue = GetPostInt("detailvalue");
  7651. CeErpBill bill_entity = null;
  7652. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  7653. string cres = "";
  7654. string gres = "";
  7655. if (bill_entity != null)
  7656. {
  7657. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7658. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  7659. {
  7660. int iTag = 0;
  7661. bill_entity.fplsh = "";
  7662. bill_entity.fpdm = "";
  7663. bill_entity.fphm = "";
  7664. foreach (string billOrderId in billOrderList)
  7665. {
  7666. iTag++;
  7667. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  7668. if (gres.IndexOf("success") != -1)
  7669. {
  7670. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  7671. Invoicing_get_response_Obj iObj = null;
  7672. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  7673. if (iObj != null)
  7674. {
  7675. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  7676. bill_entity.fpdm += iObj.list[0].c_fpdm;
  7677. bill_entity.fphm += iObj.list[0].c_fphm;
  7678. if (iTag < billOrderList.Length)
  7679. {
  7680. bill_entity.fplsh += ",";
  7681. bill_entity.fpdm += ",";
  7682. bill_entity.fphm += ",";
  7683. }
  7684. bill_entity.Update();
  7685. }
  7686. }
  7687. else
  7688. {
  7689. returnErrorMsg(gres);
  7690. return;
  7691. }
  7692. }
  7693. }
  7694. if (bill_entity.sendType == "纸质发票")
  7695. {
  7696. //作废
  7697. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  7698. //if (DateTime.Now.Month == extime.Month)
  7699. //{
  7700. //cres = taobaoHelper.cancel_invoicing(eid);
  7701. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  7702. //{
  7703. bill_entity.state = 4;//已作废
  7704. bill_entity.Update();
  7705. returnSuccessMsg("发票已作废");
  7706. return;
  7707. //}
  7708. //else
  7709. //{
  7710. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  7711. // bill_entity.Update();
  7712. // returnErrorMsg(cres);
  7713. // return;
  7714. //}
  7715. //}
  7716. //else
  7717. //{
  7718. // returnErrorMsg("纸质发票只能作废本月的发票");
  7719. // return;
  7720. //}
  7721. }
  7722. //红冲
  7723. int redTag = 0;
  7724. string[] fpdmList = bill_entity.fpdm.Split(',');
  7725. string[] fphmList = bill_entity.fphm.Split(',');
  7726. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  7727. {
  7728. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  7729. return;
  7730. }
  7731. foreach (string billOrderId in billOrderList)
  7732. {
  7733. redTag++;
  7734. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  7735. cres += onecres;
  7736. cres += ",";
  7737. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  7738. {
  7739. bill_entity.state = 4;//已作废
  7740. //bill_entity.Update();
  7741. //returnSuccessMsg("发票已红冲");
  7742. }
  7743. else if (onecres.IndexOf("重复冲红") != -1)
  7744. {
  7745. bill_entity.state = 4;//已作废
  7746. //bill_entity.Update();
  7747. //returnSuccessMsg("发票已红冲");
  7748. }
  7749. else
  7750. {
  7751. string errmsg = commonHelper.KeepChinese(onecres);
  7752. bill_entity.failerror += redTag + "&" + errmsg + "|";
  7753. }
  7754. }
  7755. bill_entity.Update();
  7756. if (cres.IndexOf("失败") != -1)
  7757. returnErrorMsg("红冲失败");
  7758. else
  7759. returnSuccessMsg("发票已红冲");
  7760. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  7761. return;
  7762. }
  7763. return;
  7764. }
  7765. }
  7766. public void del_erp_billorder()
  7767. {
  7768. if (UrlPostParmsCheck("id"))
  7769. {
  7770. string eid = GetPostString("id");
  7771. CeErpBill.Del(eid);
  7772. CeErpBill bill = CeErpBill.Get(eid);
  7773. if (bill != null)
  7774. {
  7775. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  7776. }
  7777. returnSuccessMsg("删除成功");
  7778. }
  7779. }
  7780. public void finish_erp_bill()
  7781. {
  7782. if (UrlPostParmsCheck("ids"))
  7783. {
  7784. string eids = GetPostString("ids");
  7785. string[] list = eids.Split(',');
  7786. foreach (string eid in list)
  7787. {
  7788. CeErpBill bill = CeErpBill.Get(eid);
  7789. if (bill != null)
  7790. {
  7791. bill.state = 2;
  7792. bill.Update();
  7793. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  7794. }
  7795. }
  7796. returnSuccessMsg("操作成功");
  7797. }
  7798. }
  7799. public void get_erp_returncash()
  7800. {
  7801. DataStruct dStruct = GetPostStruct();
  7802. List<string> lw = new List<string>();
  7803. string tid = GetPostString("tid");
  7804. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7805. string shopname = GetPostString("shopname");
  7806. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7807. string buyernick = GetPostString("buyer_nick");
  7808. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7809. string customer = GetPostString("customer");
  7810. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  7811. string returndate1 = GetPostString("returndate1");
  7812. string returndate2 = GetPostString("returndate2");
  7813. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  7814. if (dw.Length > 0) lw.Add(dw);
  7815. string finishDate1 = GetPostString("finishdate1");
  7816. string finishDate2 = GetPostString("finishdate2");
  7817. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  7818. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7819. string returntype = GetPostString("returntype");
  7820. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  7821. string returnvstate = GetPostString("returnvstate");
  7822. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  7823. dStruct.Order = "created desc";
  7824. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7825. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  7826. writeGridDataTableJson(dStruct.TotalCount, dt);
  7827. }
  7828. public void get_erp_staygoods()
  7829. {
  7830. DataStruct dStruct = GetPostStruct();
  7831. List<string> lw = new List<string>();
  7832. string tid = GetPostString("tid");
  7833. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7834. string shopname = GetPostString("shopname");
  7835. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  7836. string wangwang = GetPostString("wangwang");
  7837. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  7838. string customer = GetPostString("customer");
  7839. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  7840. string returndate1 = GetPostString("returndate1");
  7841. string returndate2 = GetPostString("returndate2");
  7842. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  7843. if (dw.Length > 0) lw.Add(dw);
  7844. string finishDate1 = GetPostString("finishdate1");
  7845. string finishDate2 = GetPostString("finishdate2");
  7846. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  7847. if (dw_finish.Length > 0) lw.Add(dw_finish);
  7848. string returnvstate = GetPostString("returnvstate");
  7849. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  7850. string persuadetype = GetPostString("persuadetype");
  7851. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  7852. string customerOrg = GetPostString("customerOrg");
  7853. if (customerOrg.Length > 0)
  7854. {
  7855. lw.Add(string.Format("OrgID = {0}", customerOrg));
  7856. }
  7857. dStruct.Order = "creata_time desc";
  7858. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7859. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  7860. writeGridDataTableJson(dStruct.TotalCount, dt);
  7861. }
  7862. public void upd_erp_staygoods()
  7863. {
  7864. if (UrlPostParmsCheck("id"))
  7865. {
  7866. int eid = GetPostInt("id");
  7867. CeErpStayGoods entity = null;
  7868. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7869. if (entity != null)
  7870. {
  7871. entity.audit_type = 1;
  7872. entity.audit_time = DateTime.Now;
  7873. entity.audit_u_id = CurrentUser.UserID;
  7874. entity.audit_u_name = CurrentUser.UserName;
  7875. entity.Update();
  7876. returnSuccessMsg("审核成功!");
  7877. return;
  7878. }
  7879. returnErrorMsg("找不到订单记录");
  7880. }
  7881. }
  7882. public void upd_erp_stayGoodsback()
  7883. {
  7884. if (UrlPostParmsCheck("id"))
  7885. {
  7886. int eid = GetPostInt("id");
  7887. CeErpStayGoods entity = null;
  7888. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  7889. if (entity != null)
  7890. {
  7891. entity.audit_text = GetPostString("reason");
  7892. entity.audit_type = 2;
  7893. entity.audit_time = DateTime.Now;
  7894. entity.audit_u_id = CurrentUser.UserID;
  7895. entity.audit_u_name = CurrentUser.UserName;
  7896. entity.Update();
  7897. returnSuccessMsg("退回成功!");
  7898. return;
  7899. }
  7900. returnErrorMsg("找不到订单记录");
  7901. }
  7902. }
  7903. public void upd_erp_returncashverify()
  7904. {
  7905. if (UrlPostParmsCheck("ID"))
  7906. {
  7907. int eid = GetPostInt("ID");
  7908. CeErpReturnCash entity = null;
  7909. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7910. if (entity != null)
  7911. {
  7912. entity.cashstate = 1;
  7913. entity.verifytime = DateTime.Now;
  7914. entity.verifyuserid = CurrentUser.UserID;
  7915. entity.Update();
  7916. returnSuccessMsg("审核成功!");
  7917. return;
  7918. }
  7919. returnErrorMsg("找不到订单记录");
  7920. }
  7921. }
  7922. public void upd_all_erp_returncashverify()
  7923. {
  7924. if (UrlPostParmsCheck("ID"))
  7925. {
  7926. String[] list = GetPostString("ID").Split(',');
  7927. CeErpReturnCash entity = null;
  7928. for (int i = 0; i < list.Length; i++)
  7929. {
  7930. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  7931. if (entity != null)
  7932. {
  7933. if (entity.cashstate == 1)
  7934. {
  7935. returnErrorMsg("已审核过的订单不需要在审核!");
  7936. return;
  7937. }
  7938. entity.cashstate = 1;
  7939. entity.verifytime = DateTime.Now;
  7940. entity.verifyuserid = CurrentUser.UserID;
  7941. entity.Update();
  7942. }
  7943. }
  7944. returnSuccessMsg("审核成功!");
  7945. return;
  7946. }
  7947. }
  7948. public void upd_erp_returncashback()
  7949. {
  7950. if (UrlPostParmsCheck("ID"))
  7951. {
  7952. int eid = GetPostInt("ID");
  7953. CeErpReturnCash entity = null;
  7954. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7955. if (entity != null)
  7956. {
  7957. entity.backreason = GetPostString("reason");
  7958. entity.cashstate = 2;
  7959. entity.verifytime = DateTime.Now;
  7960. entity.verifyuserid = CurrentUser.UserID;
  7961. entity.Update();
  7962. returnSuccessMsg("退回成功!");
  7963. return;
  7964. }
  7965. returnErrorMsg("找不到订单记录");
  7966. }
  7967. }
  7968. public void upd_erp_returnprice()
  7969. {
  7970. if (UrlPostParmsCheck("ID"))
  7971. {
  7972. int eid = GetPostInt("ID");
  7973. CeErpReturnCash entity = null;
  7974. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  7975. if (entity != null)
  7976. {
  7977. if (entity.cashstate == 1)
  7978. {
  7979. returnErrorMsg("审核通过了不能改");
  7980. return;
  7981. }
  7982. entity.returnprice = GetPostDouble("returnprice");
  7983. entity.Update();
  7984. returnSuccessMsg("修改成功!");
  7985. return;
  7986. }
  7987. returnErrorMsg("找不到订单记录");
  7988. }
  7989. }
  7990. public void del_erp_returncash()
  7991. {
  7992. if (UrlPostParmsCheck("ID"))
  7993. {
  7994. int eid = GetPostInt("ID");
  7995. CeErpReturnCash.Del(eid);
  7996. returnSuccessMsg("操作成功");
  7997. return;
  7998. }
  7999. }
  8000. public void test_for_do_sql()
  8001. {
  8002. string sql = GetPostString("sqlstr");
  8003. if (sql.Length > 0)
  8004. {
  8005. try
  8006. {
  8007. DbHelper.DbConn.ExecuteNonQuery(sql);
  8008. var res_obj = new
  8009. {
  8010. data = "成功",
  8011. };
  8012. string ro_json = JsonConvert.SerializeObject(res_obj);
  8013. returnSuccess(ro_json);
  8014. }
  8015. catch (Exception ex)
  8016. {
  8017. var res_obj = new
  8018. {
  8019. data = ex.Message,
  8020. };
  8021. string ro_json = JsonConvert.SerializeObject(res_obj);
  8022. returnSuccess(ro_json);
  8023. }
  8024. }
  8025. }
  8026. public void get_user_info()
  8027. {
  8028. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8029. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8030. }
  8031. public void get_total_data()
  8032. {
  8033. int userId = CurrentUser.UserID;
  8034. string sql = "";
  8035. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8036. {
  8037. 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);
  8038. }
  8039. else
  8040. {
  8041. 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 " +
  8042. "(select ID from CE_ErpUser where ID = {0}) d " +
  8043. "left join " +
  8044. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8045. ") a on d.ID = a.id left join " +
  8046. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8047. ") b on a.id = b.id1 left join" +
  8048. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8049. ") c on a.id = c.id2;", userId);
  8050. }
  8051. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8052. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8053. }
  8054. public void get_date_area_total_data2()
  8055. {
  8056. int userId = CurrentUser.UserID;
  8057. string date_type = GetPostString("timetype");
  8058. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8059. string sql = "";
  8060. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8061. {
  8062. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8063. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8064. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8065. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8066. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8067. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8068. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8069. ") a on e.ID = a.id left join " +
  8070. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8071. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8072. ") b on a.id = b.id1 " +
  8073. "left join " +
  8074. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8075. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8076. ") c on a.id = c.id2 " +
  8077. "left join " +
  8078. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8079. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8080. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8081. }
  8082. else
  8083. {
  8084. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8085. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8086. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8087. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8088. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8089. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8090. ") a on e.ID = a.id left join " +
  8091. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8092. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8093. ") c on a.id = c.id2 " +
  8094. "left join " +
  8095. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8096. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8097. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8098. }
  8099. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8100. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8101. }
  8102. public void get_date_area_total_data()
  8103. {
  8104. int userId = CurrentUser.UserID;
  8105. string date_type = GetPostString("timetype");
  8106. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8107. string date1 = searchDT[0].ToString();
  8108. string date2 = searchDT[1].ToString();
  8109. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8110. {
  8111. SqlParameter[] sqlParameter ={
  8112. new SqlParameter("@userId", SqlDbType.Int,4),
  8113. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8114. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8115. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8116. };
  8117. sqlParameter[0].Value = userId;
  8118. sqlParameter[1].Value = date1;
  8119. sqlParameter[2].Value = date2;
  8120. sqlParameter[3].Direction = ParameterDirection.Output;
  8121. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8122. string res = sqlParameter[3].Value.ToString();
  8123. var res_obj = new
  8124. {
  8125. data = res
  8126. };
  8127. string ro_json = JsonConvert.SerializeObject(res_obj);
  8128. returnSuccess(ro_json);
  8129. }
  8130. else
  8131. {
  8132. SqlParameter[] sqlParameter ={
  8133. new SqlParameter("@userId", SqlDbType.Int,4),
  8134. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8135. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8136. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8137. };
  8138. sqlParameter[0].Value = userId;
  8139. sqlParameter[1].Value = date1;
  8140. sqlParameter[2].Value = date2;
  8141. sqlParameter[3].Direction = ParameterDirection.Output;
  8142. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8143. string res = sqlParameter[3].Value.ToString();
  8144. var res_obj = new
  8145. {
  8146. data = res
  8147. };
  8148. string ro_json = JsonConvert.SerializeObject(res_obj);
  8149. returnSuccess(ro_json);
  8150. }
  8151. //writeGridDataViewJson(dt.Rows.Count, dv);
  8152. }
  8153. public void get_order_list()
  8154. {
  8155. string strFields = GetPostString("paraFields");
  8156. string strOrder = GetPostString("paraOrder");
  8157. string strWhere = GetPostString("paraWhere");
  8158. string strPageSize = GetPostString("paraPageSize");
  8159. DataStruct dStruct = GetPostStruct();
  8160. dStruct.PageSize = int.Parse(strPageSize);
  8161. dStruct.Fileds = strFields;
  8162. dStruct.Order = strOrder;
  8163. dStruct.MainWhere = strWhere;
  8164. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8165. writeGridDataTableJson(dStruct.TotalCount, dt);
  8166. }
  8167. ////获取待开始订单列表
  8168. //public void get_wait_design_order_list()
  8169. //{
  8170. // string date_type = GetPostString("date_type");
  8171. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8172. // DataStruct dStruct = GetPostStruct();
  8173. // dStruct.PageSize = 1000;
  8174. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8175. // List<string> lw = new List<string>();
  8176. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8177. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8178. // dStruct.Order = "WaitDesignTime asc";
  8179. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8180. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8181. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8182. //}
  8183. //获取完成单量排名
  8184. public void get_finish_order_count_ranking()
  8185. {
  8186. /* string date_type = GetPostString("date_type");
  8187. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8188. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8189. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8190. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8191. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8192. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8193. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8194. writeGridDataTableJson(0, new DataTable());
  8195. }
  8196. public void get_finish_order_amount_ranking()
  8197. {
  8198. /*string date_type = GetPostString("date_type");
  8199. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8200. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8201. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8202. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8203. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8204. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8205. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8206. writeGridDataTableJson(0, new DataTable());
  8207. }
  8208. public void get_finish_refund_count_ranking()
  8209. {
  8210. string date_type = GetPostString("date_type");
  8211. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8212. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8213. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8214. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8215. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8216. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8217. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8218. writeGridDataTableJson(dt.Rows.Count, dt);
  8219. }
  8220. public void get_finish_refund_amount_ranking()
  8221. {
  8222. string date_type = GetPostString("date_type");
  8223. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8224. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8225. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8226. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8227. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8228. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8229. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8230. writeGridDataTableJson(dt.Rows.Count, dt);
  8231. }
  8232. public void set_erp_finishorder_director()
  8233. {
  8234. if (UrlPostParmsCheck("ctid"))
  8235. {
  8236. string eid = GetPostString("ctid");
  8237. CeErpTradeCell entity = null;
  8238. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8239. if (entity != null)
  8240. {
  8241. entity.OrderState = 8;
  8242. entity.Update();
  8243. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8244. returnSuccessMsg("操作成功!");
  8245. return;
  8246. }
  8247. returnErrorMsg("找不到记录");
  8248. }
  8249. }
  8250. public void get_erp_placeregistlist()
  8251. {
  8252. DataStruct dStruct = GetPostStruct();
  8253. List<string> lw = new List<string>();
  8254. string outsid = GetPostString("outsid");
  8255. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8256. string memo = GetPostString("memo");
  8257. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8258. string filename = GetPostString("filename");
  8259. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8260. string islate = GetPostString("islate");
  8261. if (islate.Length > 0)
  8262. {
  8263. if (islate == "1")
  8264. lw.Add(string.Format("OutLate>0"));
  8265. else
  8266. lw.Add(string.Format("OutLate=0"));
  8267. }
  8268. string placedate1 = GetPostString("placedate1");
  8269. string placedate2 = GetPostString("placedate2");
  8270. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8271. if (dw.Length > 0) lw.Add(dw);
  8272. string deliveryDate1 = GetPostString("deliverydate1");
  8273. string deliveryDate2 = GetPostString("deliverydate2");
  8274. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8275. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8276. dStruct.Order = "ID desc";
  8277. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8278. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8279. writeGridDataTableJson(dStruct.TotalCount, dt);
  8280. }
  8281. public void ins_erp_placeregist()
  8282. {
  8283. if (UrlPostParmsCheck("id"))
  8284. {
  8285. string eid = GetPostString("id");
  8286. CeErpPlaceRegister entity = null;
  8287. if (eid == "0")//新增
  8288. {
  8289. entity = new CeErpPlaceRegister();
  8290. string xdTime = GetPostString("placeTime");
  8291. if (xdTime.Length > 0)
  8292. {
  8293. entity.PlactTime = Convert.ToDateTime(xdTime);
  8294. }
  8295. string fhTime = GetPostString("deliveryTime");
  8296. if (fhTime.Length > 0)
  8297. {
  8298. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8299. }
  8300. string preTime = GetPostString("preOutTime");
  8301. if (preTime.Length > 0)
  8302. {
  8303. entity.PreOutTime = Convert.ToDateTime(preTime);
  8304. }
  8305. entity.DeliveryCount = GetPostInt("deliveryCount");
  8306. entity.ReceiveCount = GetPostInt("receiveCount");
  8307. entity.OutSid = GetPostString("outSid");
  8308. entity.FileName = GetPostString("fileName");
  8309. entity.Memo = GetPostString("memo");
  8310. entity.AddUserId = CurrentUser.UserID;
  8311. entity.CreateTime = DateTime.Now;
  8312. entity.Img = GetPostString("img");
  8313. entity.Supplier = GetPostInt("supplier");
  8314. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8315. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8316. {
  8317. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8318. DateTime dt2 = (DateTime)entity.PreOutTime;
  8319. TimeSpan span = dt1.Subtract(dt2);
  8320. if (span.Days > 0)
  8321. {
  8322. entity.OutLate = span.Days;
  8323. }
  8324. }
  8325. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8326. entity.Create();
  8327. returnSuccessMsg("添加成功!");
  8328. return;
  8329. }
  8330. else //修改
  8331. {
  8332. entity = CeErpPlaceRegister.Get(eid);
  8333. if (entity != null)
  8334. {
  8335. string xdTime = GetPostString("placeTime");
  8336. if (xdTime.Length > 0)
  8337. {
  8338. entity.PlactTime = Convert.ToDateTime(xdTime);
  8339. }
  8340. string fhTime = GetPostString("deliveryTime");
  8341. if (fhTime.Length > 0)
  8342. {
  8343. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8344. }
  8345. string preTime = GetPostString("preOutTime");
  8346. if (preTime.Length > 0)
  8347. {
  8348. entity.PreOutTime = Convert.ToDateTime(preTime);
  8349. }
  8350. entity.DeliveryCount = GetPostInt("deliveryCount");
  8351. entity.ReceiveCount = GetPostInt("receiveCount");
  8352. if (entity.DeliveryCount == entity.ReceiveCount)
  8353. {
  8354. entity.CurState = "已完成";
  8355. }
  8356. else
  8357. {
  8358. entity.CurState = "未完成";
  8359. }
  8360. entity.OutSid = GetPostString("outSid");
  8361. entity.FileName = GetPostString("fileName");
  8362. entity.Memo = GetPostString("memo");
  8363. entity.Img = GetPostString("img");
  8364. entity.Supplier = GetPostInt("supplier");
  8365. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8366. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8367. {
  8368. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8369. DateTime dt2 = (DateTime)entity.PreOutTime;
  8370. TimeSpan span = dt1.Subtract(dt2);
  8371. if (span.Days > 0)
  8372. {
  8373. entity.OutLate = span.Days;
  8374. }
  8375. }
  8376. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8377. entity.Update();
  8378. returnSuccessMsg("修改成功");
  8379. return;
  8380. }
  8381. returnErrorMsg("找不到对应的记录");
  8382. return;
  8383. }
  8384. }
  8385. returnErrorMsg("缺少必要参数");
  8386. }
  8387. public void del_erp_placeregist()
  8388. {
  8389. string eid = GetPostString("id");
  8390. CeErpPlaceRegister.Del(eid);
  8391. returnSuccessMsg("删除成功!");
  8392. return;
  8393. }
  8394. public void ins_erp_placeregistbyorder()
  8395. {
  8396. string ctid = GetPostString("ctid");
  8397. if (ctid.Length > 0)
  8398. {
  8399. StringBuilder sql = new StringBuilder();
  8400. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8401. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8402. if (dt.Rows.Count > 0)
  8403. {
  8404. foreach (DataRow dr in dt.Rows)
  8405. {
  8406. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8407. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8408. entity.AddUserId = CurrentUser.UserID;
  8409. entity.tid = dr["tid"].ToString();
  8410. entity.Did = Convert.ToString(dr["ctid"]);
  8411. entity.splitTag = dr["SplitTag"].ToString();
  8412. string sellmemo = Convert.ToString(dr["seller_memo"]);
  8413. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  8414. if (pre_ctid.Length > 0)
  8415. {
  8416. sellmemo = sellmemo.Replace(pre_ctid, "");
  8417. }
  8418. sellmemo = sellmemo.Replace("[", "");
  8419. sellmemo = sellmemo.Replace("]", "");
  8420. entity.FileName = sellmemo;
  8421. string count = dr["ProductCount"].ToString();
  8422. int usecount = commonHelper.getIntCountFromString(count);
  8423. entity.DeliveryCount = usecount;
  8424. entity.CurState = "未完成";
  8425. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  8426. {
  8427. entity.Supplier = 24;//dl手提袋定制
  8428. }
  8429. else
  8430. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  8431. entity.CreateTime = DateTime.Now;
  8432. entity.Create();
  8433. }
  8434. returnSuccessMsg("操作成功");
  8435. return;
  8436. }
  8437. returnErrorMsg("没有找到对应订单");
  8438. return;
  8439. }
  8440. returnErrorMsg("缺少订单编号");
  8441. return;
  8442. }
  8443. public void get_erp_persuadelist()
  8444. {
  8445. DataStruct dStruct = GetPostStruct();
  8446. List<string> lw = new List<string>();
  8447. string ctid = GetPostString("ctid");
  8448. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  8449. string shopname = GetPostString("shopname");
  8450. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8451. string buyernick = GetPostString("buyer_nick");
  8452. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8453. string customer = GetPostString("customer");
  8454. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8455. string returndate1 = GetPostString("returndate1");
  8456. string returndate2 = GetPostString("returndate2");
  8457. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8458. if (dw.Length > 0) lw.Add(dw);
  8459. string finishDate1 = GetPostString("finishdate1");
  8460. string finishDate2 = GetPostString("finishdate2");
  8461. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8462. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8463. string persuadetype = GetPostString("persuadetype");
  8464. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  8465. string returnvstate = GetPostString("returnvstate");
  8466. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  8467. dStruct.Order = "created desc";
  8468. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8469. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  8470. writeGridDataTableJson(dStruct.TotalCount, dt);
  8471. }
  8472. public void upd_erp_returnpersuadeback()
  8473. {
  8474. if (UrlPostParmsCheck("ID"))
  8475. {
  8476. int eid = GetPostInt("ID");
  8477. CeErpPersuade entity = null;
  8478. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8479. if (entity != null)
  8480. {
  8481. entity.backreason = GetPostString("reason");
  8482. entity.pstate = 2;
  8483. entity.verifytime = DateTime.Now;
  8484. entity.verifyuserid = CurrentUser.UserID;
  8485. entity.Update();
  8486. returnSuccessMsg("退回成功!");
  8487. return;
  8488. }
  8489. returnErrorMsg("找不到订单记录");
  8490. }
  8491. }
  8492. public void upd_erp_returnpersuadeverify()
  8493. {
  8494. if (UrlPostParmsCheck("ID"))
  8495. {
  8496. if (CurrentUser.UserPost.Post.Code != "Summarize")
  8497. {
  8498. returnErrorMsg("暂无权限审核");
  8499. return;
  8500. }
  8501. int eid = GetPostInt("ID");
  8502. CeErpPersuade entity = null;
  8503. if (eid != 0) entity = CeErpPersuade.Get(eid);
  8504. if (entity != null)
  8505. {
  8506. entity.pstate = 1;
  8507. entity.verifytime = DateTime.Now;
  8508. entity.verifyuserid = CurrentUser.UserID;
  8509. entity.Update();
  8510. returnSuccessMsg("审核成功!");
  8511. return;
  8512. }
  8513. returnErrorMsg("找不到订单记录");
  8514. }
  8515. }
  8516. public void del_erp_persuade()
  8517. {
  8518. if (UrlPostParmsCheck("ID"))
  8519. {
  8520. int eid = GetPostInt("ID");
  8521. CeErpPersuade.Del(eid);
  8522. returnSuccessMsg("操作成功");
  8523. return;
  8524. }
  8525. }
  8526. public void get_erp_oldcustoupload()
  8527. {
  8528. DataStruct dStruct = GetPostStruct();
  8529. List<string> lw = new List<string>();
  8530. string buyernick = GetPostString("buyer_nick");
  8531. if (buyernick.Length > 0)
  8532. {
  8533. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8534. }
  8535. else
  8536. return;
  8537. dStruct.Order = "pay_time desc";
  8538. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8539. DataTable dt = null;
  8540. dt = WebCache.GetData("view_erptradecell", dStruct);
  8541. writeGridDataTableJson(dStruct.TotalCount, dt);
  8542. }
  8543. public void get_erp_checkorderlist()
  8544. {
  8545. DataStruct dStruct = GetPostStruct();
  8546. List<string> lw = new List<string>();
  8547. string tid = GetPostString("ctid");
  8548. if (tid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", tid));
  8549. string shopname = GetPostString("shopname");
  8550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8551. string buyernick = GetPostString("buyer_nick");
  8552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  8553. string customer = GetPostString("customer");
  8554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  8555. string design = GetPostString("design");
  8556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  8557. string orderState = GetPostString("orderState");
  8558. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  8559. string address = GetPostString("address");
  8560. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  8561. string sellermemo = GetPostString("seller_memo");
  8562. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  8563. string supplier = GetPostString("supplier");
  8564. if (CurrentUser.UserPost.Post.Code == "Supplier")
  8565. {
  8566. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  8567. }
  8568. else
  8569. {
  8570. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  8571. }
  8572. string checkst = GetPostString("checkstate");
  8573. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  8574. string date1 = GetPostString("date1");
  8575. string date2 = GetPostString("date2");
  8576. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  8577. if (dw.Length > 0) lw.Add(dw);
  8578. string placedate1 = GetPostString("placedate1");
  8579. string placedate2 = GetPostString("placedate2");
  8580. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  8581. if (fdw.Length > 0) lw.Add(fdw);
  8582. string price1 = GetPostString("price1");
  8583. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  8584. string price2 = GetPostString("price2");
  8585. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  8586. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  8587. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  8588. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8589. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  8590. writeGridDataTableJson(dStruct.TotalCount, dt);
  8591. }
  8592. public void ins_erp_startCheck()
  8593. {
  8594. if (UrlPostParmsCheck("ctid"))
  8595. {
  8596. string eid = GetPostString("ctid");
  8597. CeErpTradeCell entity = null;
  8598. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8599. if (entity != null)
  8600. {
  8601. entity.MemoOpt = 4;
  8602. entity.Update();
  8603. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  8604. CeErpSukuraData.createInfo(entity.ctid, 6);
  8605. returnSuccessMsg("操作成功!");
  8606. return;
  8607. }
  8608. returnErrorMsg("找不到记录");
  8609. }
  8610. }
  8611. public void upd_erp_sendXlw()
  8612. {
  8613. if (UrlPostParmsCheck("ctid"))
  8614. {
  8615. string eid = GetPostString("ctid");
  8616. CeErpTradeCell entity = null;
  8617. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8618. if (entity != null)
  8619. {
  8620. if (entity.IsSendGift == 1)
  8621. {
  8622. returnErrorMsg("请勿重复标记");
  8623. return;
  8624. }
  8625. entity.IsSendGift = 1;
  8626. entity.Update();
  8627. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  8628. returnSuccessMsg("操作成功!");
  8629. return;
  8630. }
  8631. returnErrorMsg("找不到记录");
  8632. }
  8633. }
  8634. public void cancel_sendXlw()
  8635. {
  8636. if (UrlPostParmsCheck("ctid"))
  8637. {
  8638. string eid = GetPostString("ctid");
  8639. CeErpTradeCell entity = null;
  8640. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8641. if (entity != null)
  8642. {
  8643. if (entity.IsSendGift == 0)
  8644. {
  8645. returnErrorMsg("未标记小礼物");
  8646. return;
  8647. }
  8648. entity.IsSendGift = 0;
  8649. entity.Update();
  8650. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  8651. returnSuccessMsg("操作成功!");
  8652. return;
  8653. }
  8654. returnErrorMsg("找不到记录");
  8655. }
  8656. }
  8657. public void get_erp_designbill()
  8658. {
  8659. DataStruct dStruct = GetPostStruct();
  8660. List<string> lw = new List<string>();
  8661. int isMy = GetInt("my");
  8662. if (isMy == 1)
  8663. {
  8664. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  8665. }
  8666. string tid = GetPostString("tid");
  8667. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8668. string userName = GetPostString("design");
  8669. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  8670. string price1 = GetPostString("price1");
  8671. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  8672. string price2 = GetPostString("price2");
  8673. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  8674. string rePrice1 = GetPostString("rePrice1");
  8675. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  8676. string rePrice2 = GetPostString("rePrice2");
  8677. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  8678. string designerType = GetPostString("designerType");
  8679. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  8680. string orderState = GetPostString("orderState");
  8681. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  8682. string endTime1 = GetPostString("endTime1");
  8683. string endTime2 = GetPostString("endTime2");
  8684. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  8685. if (dw.Length > 0) lw.Add(dw);
  8686. string isDk = GetPostString("isDk");
  8687. if (isDk == "1")
  8688. {
  8689. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  8690. }
  8691. else if (isDk == "0")
  8692. {
  8693. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  8694. }
  8695. dStruct.Order = "oid, create_time desc";
  8696. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8697. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  8698. writeGridDataTableJson(dStruct.TotalCount, dt);
  8699. }
  8700. public void upd_erp_designerbill()
  8701. {
  8702. if (UrlPostParmsCheck("ID"))
  8703. {
  8704. string eid = GetPostString("ID");
  8705. CeErpDesignerBill entity = null;
  8706. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8707. if (entity != null)
  8708. {
  8709. if (GetPostDouble("designerpirce") > 0)
  8710. {
  8711. entity.realPrice = GetPostDouble("designerpirce");
  8712. entity.update_time = DateTime.Now;
  8713. entity.update_u_id = CurrentUser.UserID;
  8714. entity.update_u_name = CurrentUser.UserName;
  8715. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  8716. entity.Update();
  8717. returnSuccessMsg("操作成功!");
  8718. return;
  8719. }
  8720. else
  8721. {
  8722. entity.price = GetPostDouble("price");
  8723. entity.update_time = DateTime.Now;
  8724. entity.update_u_id = CurrentUser.UserID;
  8725. entity.update_u_name = CurrentUser.UserName;
  8726. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  8727. entity.Update();
  8728. returnSuccessMsg("操作成功!");
  8729. return;
  8730. }
  8731. }
  8732. returnErrorMsg("找不到记录");
  8733. }
  8734. }
  8735. public void audit_erp_designerbill()
  8736. {
  8737. if (UrlPostParmsCheck("ID"))
  8738. {
  8739. string eid = GetPostString("ID");
  8740. CeErpDesignerBill entity = null;
  8741. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  8742. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  8743. if (entity != null)
  8744. {
  8745. entity.realPrice = GetPostDouble("designerpirce");
  8746. entity.update_time = DateTime.Now;
  8747. entity.update_u_id = CurrentUser.UserID;
  8748. entity.update_u_name = CurrentUser.UserName;
  8749. entity.isAudit = 1;
  8750. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8751. entity.Update();
  8752. if (orderEntity != null)
  8753. {
  8754. orderEntity.IsReadTag = 3;
  8755. orderEntity.Update();
  8756. }
  8757. returnSuccessMsg("操作成功!");
  8758. return;
  8759. }
  8760. returnErrorMsg("找不到记录");
  8761. }
  8762. }
  8763. public void all_audit_erp_designerbill()
  8764. {
  8765. if (UrlPostParmsCheck("idList"))
  8766. {
  8767. string[] list = GetPostString("idList").Split(',');
  8768. CeErpDesignerBill entity = null;
  8769. for (int i = 0; i < list.Length; i++)
  8770. {
  8771. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  8772. if (entity == null) return;
  8773. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  8774. if (orderEntity == null) return;
  8775. if (entity.realPrice == 0) entity.realPrice = entity.price;
  8776. entity.update_time = DateTime.Now;
  8777. entity.update_u_id = CurrentUser.UserID;
  8778. entity.update_u_name = CurrentUser.UserName;
  8779. entity.isAudit = 1;
  8780. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  8781. entity.Update();
  8782. orderEntity.IsReadTag = 3;
  8783. orderEntity.Update();
  8784. }
  8785. returnSuccessMsg("操作成功!");
  8786. return;
  8787. }
  8788. }
  8789. public void get_erp_sameorders()
  8790. {
  8791. if (UrlPostParmsCheck("ctid"))
  8792. {
  8793. string eid = GetPostString("ctid");
  8794. CeErpTradeCell entity = null;
  8795. entity = CeErpTradeCell.GetByCtid(eid);
  8796. if (entity != null)
  8797. {
  8798. StringBuilder sql = new StringBuilder();
  8799. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  8800. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8801. var res = new
  8802. {
  8803. data = dt.Rows.Count
  8804. };
  8805. string ro_jsond = JsonConvert.SerializeObject(res);
  8806. returnSuccess(ro_jsond);
  8807. return;
  8808. }
  8809. returnErrorMsg("未找到订单");
  8810. return;
  8811. }
  8812. returnErrorMsg("缺少必要的参数");
  8813. }
  8814. public void get_erp_islasthavesameorder()
  8815. {
  8816. if (UrlPostParmsCheck("ctid"))
  8817. {
  8818. string eid = GetPostString("ctid");
  8819. string[] ctidList = eid.Split(',');
  8820. StringBuilder sql = new StringBuilder();
  8821. string tisCtid = "";
  8822. foreach (string ctid in ctidList)
  8823. {
  8824. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  8825. if (entity != null)
  8826. {
  8827. sql = new StringBuilder();
  8828. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  8829. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8830. if (dth.Rows.Count > 0)
  8831. {
  8832. tisCtid += entity.ctid;
  8833. tisCtid += ",";
  8834. }
  8835. }
  8836. }
  8837. if (tisCtid.Length > 0)
  8838. {
  8839. var res = new
  8840. {
  8841. data = tisCtid
  8842. };
  8843. string ro_jsond = JsonConvert.SerializeObject(res);
  8844. returnSuccess(ro_jsond);
  8845. }
  8846. else
  8847. {
  8848. var res = new
  8849. {
  8850. data = ""
  8851. };
  8852. string ro_jsond = JsonConvert.SerializeObject(res);
  8853. returnSuccess(ro_jsond);
  8854. }
  8855. return;
  8856. }
  8857. returnErrorMsg("缺少必要的参数");
  8858. }
  8859. public void file_client_down_url()
  8860. {
  8861. if (!UrlPostParmsCheck("userId"))
  8862. {
  8863. returnErrorMsg("缺少必要的参数");
  8864. }
  8865. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  8866. }
  8867. public void checkout_form_data()
  8868. {
  8869. if (!UrlPostParmsCheck("tid"))
  8870. {
  8871. returnErrorMsg("缺少必要的参数");
  8872. }
  8873. string tid = GetPostString("tid");
  8874. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  8875. if (ceErpOrderFormData != null)
  8876. {
  8877. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  8878. returnSuccess(ro_jsond);
  8879. return;
  8880. }
  8881. returnErrorMsg("尚未有文件!");
  8882. }
  8883. public void back_supplier_audit()
  8884. {
  8885. int userId = CurrentUser.UserID;
  8886. StringBuilder sql = new StringBuilder();
  8887. 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);
  8888. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8889. if (dt.Rows.Count > 0)
  8890. {
  8891. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8892. }
  8893. else
  8894. {
  8895. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8896. }
  8897. }
  8898. public void back_supplier_query()
  8899. {
  8900. string eid = GetPostString("ctid");
  8901. if (eid != "")
  8902. {
  8903. StringBuilder sql = new StringBuilder();
  8904. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  8905. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8906. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8907. }
  8908. else
  8909. {
  8910. returnErrorMsg("找不到订单记录");
  8911. return;
  8912. }
  8913. }
  8914. public void verified_to_order()
  8915. {
  8916. int userId = CurrentUser.UserID;
  8917. StringBuilder sql = new StringBuilder();
  8918. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  8919. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8920. if (dt.Rows.Count > 0)
  8921. {
  8922. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8923. }
  8924. else
  8925. {
  8926. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8927. }
  8928. }
  8929. public void upd_supplier_audit()
  8930. {
  8931. if (UrlPostParmsCheck("ctid"))
  8932. {
  8933. string eid = GetPostString("ctid");
  8934. string reason = GetPostString("returnreason");
  8935. CeErpTradeCell entity = null;
  8936. CeWithdraw withdraw = null;
  8937. withdraw = CeWithdraw.GetByTid(eid);
  8938. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8939. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  8940. {
  8941. if (withdraw != null)
  8942. {
  8943. if (!withdraw.userid.Equals(CurrentUser.UserID))
  8944. {
  8945. returnSuccessMsg("您没有权限操作!");
  8946. return;
  8947. }
  8948. else
  8949. {
  8950. if (reason.Equals("1"))
  8951. {
  8952. if (entity.OrderState == -1)
  8953. {
  8954. if (entity.FinishPlaceTime == null)
  8955. {
  8956. entity.OrderState = 2;
  8957. }
  8958. else
  8959. {
  8960. entity.OrderState = 6;
  8961. }
  8962. }
  8963. entity.Update();
  8964. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  8965. if (withdraw != null)
  8966. {
  8967. withdraw.status = int.Parse(reason);
  8968. withdraw.Update();
  8969. }
  8970. returnSuccessMsg("操作成功!");
  8971. return;
  8972. }
  8973. else
  8974. {
  8975. withdraw.status = int.Parse(reason);
  8976. withdraw.acknowledgingtime = DateTime.Now;
  8977. withdraw.Update();
  8978. returnSuccessMsg("查看详细请点击线下订单查询");
  8979. return;
  8980. }
  8981. }
  8982. }
  8983. // 第一个字符是 'N'
  8984. }
  8985. if (eid[0] != 'N')
  8986. {
  8987. }
  8988. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  8989. {
  8990. entity.IsVerifyToSupplier = false;
  8991. entity.IsReturn = 1;
  8992. entity.ReturnTime = DateTime.Now;
  8993. entity.ReturnReason = reason;
  8994. if (entity.OrderState == 6)
  8995. {
  8996. entity.OrderState = 5;
  8997. }
  8998. entity.Update();
  8999. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9000. if (withdraw != null)
  9001. {
  9002. withdraw.status = int.Parse(reason);
  9003. withdraw.Update();
  9004. }
  9005. returnSuccessMsg("操作成功!");
  9006. return;
  9007. }
  9008. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9009. {
  9010. ;
  9011. if (withdraw != null)
  9012. {
  9013. withdraw.status = int.Parse(reason);
  9014. withdraw.acknowledgingtime = DateTime.Now;
  9015. withdraw.Update();
  9016. returnSuccessMsg("供应商取消撤回!");
  9017. return;
  9018. }
  9019. }
  9020. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9021. {
  9022. if (entity.OrderState == -1)
  9023. {
  9024. if (entity.FinishPlaceTime == null)
  9025. {
  9026. entity.OrderState = 2;
  9027. }
  9028. else
  9029. {
  9030. entity.OrderState = 3;
  9031. }
  9032. commonHelper.getCytPrice(entity);
  9033. }
  9034. entity.Update();
  9035. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9036. if (withdraw != null)
  9037. {
  9038. withdraw.status = int.Parse(reason);
  9039. withdraw.Update();
  9040. }
  9041. returnSuccessMsg("操作成功!");
  9042. return;
  9043. }
  9044. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9045. {
  9046. if (withdraw == null)
  9047. {
  9048. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9049. return;
  9050. }
  9051. }
  9052. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9053. {
  9054. if (withdraw != null)
  9055. {
  9056. withdraw.status = int.Parse(reason);
  9057. withdraw.acknowledgingtime = DateTime.Now;
  9058. withdraw.Update();
  9059. returnSuccessMsg("查看详细请点击线下订单查询");
  9060. return;
  9061. }
  9062. }
  9063. return;
  9064. }
  9065. }
  9066. //校验报价
  9067. public void refund_order_tip()
  9068. {
  9069. int userid = CurrentUser.UserID;
  9070. int sectionId = CurrentUser.UserPost.OrgID;
  9071. StringBuilder sql = new StringBuilder();
  9072. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9073. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9074. List<string> ids = new List<string>();
  9075. if (dth.Rows.Count > 0)
  9076. {
  9077. foreach (DataRow dr in dth.Rows)
  9078. {
  9079. ids.Add(dr["ID"].ToString());
  9080. }
  9081. try
  9082. {
  9083. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9084. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9085. }
  9086. catch (Exception ex)
  9087. {
  9088. }
  9089. }
  9090. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9091. }
  9092. public void refund_order_Design()
  9093. {
  9094. int userid = CurrentUser.UserID;
  9095. int sectionId = CurrentUser.UserPost.OrgID;
  9096. StringBuilder sql = new StringBuilder();
  9097. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9098. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9099. List<string> ids = new List<string>();
  9100. if (dth.Rows.Count > 0)
  9101. {
  9102. foreach (DataRow dr in dth.Rows)
  9103. {
  9104. ids.Add(dr["ID"].ToString());
  9105. }
  9106. try
  9107. {
  9108. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9109. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9110. }
  9111. catch (Exception ex)
  9112. {
  9113. }
  9114. }
  9115. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9116. }
  9117. public void change_order_info()
  9118. {
  9119. int userid = CurrentUser.UserID;
  9120. StringBuilder sql = new StringBuilder();
  9121. 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);
  9122. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9123. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9124. }
  9125. public void change_win_mome()
  9126. {
  9127. if (UrlPostParmsCheck("id,ctid"))
  9128. {
  9129. string id = GetPostString("id");
  9130. string ctid = GetPostString("ctid");
  9131. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9132. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9133. if (ce == null || ceErpMessageTip == null)
  9134. {
  9135. returnSuccessMsg("未找到对应的订单!");
  9136. return;
  9137. }
  9138. int type = GetPostInt("type");
  9139. string content = GetPostString("content");
  9140. if (type == 0)
  9141. {
  9142. content = content.Replace("(", "(");
  9143. content = content.Replace(")", ")");
  9144. string check = MidStrEx(content, "(", ")").Trim();
  9145. if (string.IsNullOrEmpty(check))
  9146. {
  9147. returnSuccessMsg("文件名格式不正确");
  9148. return;
  9149. }
  9150. }
  9151. ce.seller_memo = content;
  9152. ce.Update();
  9153. ceErpMessageTip.isVisit = true;
  9154. ceErpMessageTip.Update();
  9155. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9156. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9157. ApiVo apiVo = new ApiVo();
  9158. apiVo.orderNumber = ce.ctid;
  9159. apiVo.actionName = "demandDesign";
  9160. apiVo.orderRemarks = content;
  9161. apiVo.demandExamine = type + 1;
  9162. designHelper.API_WorkCore(apiVo);//demandDesign
  9163. returnSuccessMsg("修改成功!");
  9164. }
  9165. }
  9166. public static string MidStrEx(string sourse, string startstr, string endstr)
  9167. {
  9168. string result = string.Empty;
  9169. int startindex, endindex;
  9170. try
  9171. {
  9172. startindex = sourse.IndexOf(startstr);
  9173. if (startindex == -1)
  9174. return result;
  9175. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9176. endindex = tmpstr.IndexOf(endstr);
  9177. if (endindex == -1)
  9178. return result;
  9179. result = tmpstr.Remove(endindex);
  9180. }
  9181. catch (Exception ex)
  9182. {
  9183. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9184. }
  9185. return result;
  9186. }
  9187. public void refund_order_list()
  9188. {
  9189. int userid = CurrentUser.UserID;
  9190. int sectionId = CurrentUser.UserPost.OrgID;
  9191. StringBuilder sql = new StringBuilder();
  9192. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9193. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9194. DataStruct dStruct = GetPostStruct();
  9195. DataTable dt = null;
  9196. List<string> ids = new List<string>();
  9197. List<string> tids = new List<string>();
  9198. if (dth.Rows.Count > 0)
  9199. {
  9200. foreach (DataRow dr in dth.Rows)
  9201. {
  9202. tids.Add("'" + dr["tid"].ToString() + "'");
  9203. ids.Add(dr["id"].ToString());
  9204. }
  9205. try
  9206. {
  9207. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9208. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9209. List<string> lw = new List<string>();
  9210. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9211. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9212. dt = WebCache.GetData("view_orderlist", dStruct);
  9213. }
  9214. catch (Exception ex)
  9215. {
  9216. }
  9217. }
  9218. writeGridDataTableJson(dStruct.TotalCount, dt);
  9219. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9220. }
  9221. //新增
  9222. public void order_batch_downloads()
  9223. {
  9224. string ceid = GetPostString("tid");
  9225. String[] tid = ceid.Split(',');
  9226. order_batch_caiyingtong(tid);
  9227. /* (string success, string errors) = UploadFiles(tid);
  9228. returnSuccessMsg(success + errors);*/
  9229. return;
  9230. }
  9231. //报价接口
  9232. public void Get_To_Quote()
  9233. {
  9234. string ceid = GetPostString("ctid");
  9235. if (ceid != null)
  9236. {
  9237. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9238. if (entity != null)
  9239. {
  9240. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9241. double price = 0;
  9242. if (cp == null)
  9243. {
  9244. JObject jsonObject12 = new JObject
  9245. {
  9246. { "UserId", "77886" },
  9247. { "Pwd", "lt666888" },
  9248. { "Filename", entity.seller_memo }
  9249. };
  9250. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9251. JObject jsonObjects1 = JObject.Parse(response1);
  9252. string ms1g = (string)jsonObjects1["msg"];
  9253. if (ms1g == "报价成功")
  9254. {
  9255. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9256. string data = (string)jsonObject1["price"];
  9257. 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 + "');";
  9258. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9259. returnSuccessMsg("获取报价成功:" + data);
  9260. price = Convert.ToDouble(data);
  9261. }
  9262. else
  9263. {
  9264. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9265. return;
  9266. }
  9267. }
  9268. String[] beizhu = entity.seller_memo.Split('-');
  9269. String chanp = "";
  9270. if (beizhu.Length > 0)
  9271. {
  9272. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9273. }
  9274. else
  9275. {
  9276. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9277. }
  9278. JObject jsonObject = new JObject
  9279. {
  9280. { "UserId", "77886" },
  9281. { "Pwd", "lt666888" },
  9282. { "Filename", chanp }
  9283. };
  9284. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9285. JObject jsonObjects = JObject.Parse(response);
  9286. string msg = (string)jsonObjects["msg"];
  9287. if (msg == "报价成功")
  9288. {
  9289. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9290. string data = (string)jsonObject1["price"];
  9291. 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 + "');";
  9292. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9293. returnSuccessMsg("获取报价成功:" + data);
  9294. price = Convert.ToDouble(data);
  9295. }
  9296. else
  9297. {
  9298. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9299. return;
  9300. }
  9301. if (price > 0)
  9302. {
  9303. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9304. if (ceErpTradeCellExtend == null)
  9305. {
  9306. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9307. ceErpTradeCellExtend.ctid = entity.ctid;
  9308. ceErpTradeCellExtend.payment_cyt = price;
  9309. ceErpTradeCellExtend.Create();
  9310. }
  9311. else
  9312. {
  9313. ceErpTradeCellExtend.payment_cyt = price;
  9314. ceErpTradeCellExtend.Update();
  9315. }
  9316. }
  9317. return;
  9318. }
  9319. }
  9320. else
  9321. {
  9322. returnErrorMsg("请至少选择一条数据");
  9323. return;
  9324. }
  9325. }
  9326. //新增
  9327. public void order_To_Supplier()
  9328. {
  9329. string ceid = GetPostString("tid");
  9330. String[] tid = ceid.Split(',');
  9331. if (tid.Length > 0)
  9332. {
  9333. try
  9334. {
  9335. for (int i = 0; i < tid.Length; i++)
  9336. {
  9337. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9338. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9339. entity.SupplierId = suid;
  9340. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9341. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9342. entity.Update();
  9343. }
  9344. }
  9345. catch (Exception ex)
  9346. {
  9347. returnErrorMsg("自动匹配供应商失败");
  9348. return;
  9349. }
  9350. }
  9351. else
  9352. {
  9353. returnErrorMsg("请至少选择一条数据");
  9354. return;
  9355. }
  9356. returnSuccessMsg("自动匹配供应商成功");
  9357. return;
  9358. }
  9359. public (string, string) UploadFiles(string[] urls)
  9360. {
  9361. string success = "";
  9362. string errors = "";
  9363. int userid = CurrentUser.UserID;
  9364. foreach (string url in urls)
  9365. {
  9366. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9367. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9368. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9369. {
  9370. JObject jsonObject = new JObject
  9371. {
  9372. { "Userid", "77886" },
  9373. { "pwd", "cyt86435015" },
  9374. { "content", base64FileContent },
  9375. { "ext", Path.GetExtension(fileName) }
  9376. };
  9377. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9378. JObject jsonObjects = JObject.Parse(response);
  9379. string msg = (string)jsonObjects["msg"];
  9380. if (msg.Equals("上传成功"))
  9381. {
  9382. success += url + " 上传成功";
  9383. }
  9384. else
  9385. {
  9386. errors += url + " 上传失败";
  9387. }
  9388. }
  9389. else
  9390. {
  9391. errors += url + " 格式出现问题";
  9392. }
  9393. }
  9394. if (urls.Length == 0)
  9395. {
  9396. return (success, errors);
  9397. }
  9398. return (success, errors);
  9399. }
  9400. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  9401. {
  9402. return true; //总是接受
  9403. }
  9404. public static string HttpPost(string url, string param = null)
  9405. {
  9406. HttpWebRequest request;
  9407. //如果是发送HTTPS请求
  9408. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  9409. {
  9410. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  9411. request = WebRequest.Create(url) as HttpWebRequest;
  9412. request.ProtocolVersion = HttpVersion.Version10;
  9413. }
  9414. else
  9415. {
  9416. request = WebRequest.Create(url) as HttpWebRequest;
  9417. }
  9418. request.Method = "POST";
  9419. request.ContentType = "application/json";
  9420. request.Accept = "*/*";
  9421. request.Timeout = 120000;
  9422. request.AllowAutoRedirect = false;
  9423. StreamWriter requestStream = null;
  9424. WebResponse response = null;
  9425. string responseStr = null;
  9426. try
  9427. {
  9428. requestStream = new StreamWriter(request.GetRequestStream());
  9429. requestStream.Write(param);
  9430. requestStream.Close();
  9431. response = request.GetResponse();
  9432. if (response != null)
  9433. {
  9434. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  9435. responseStr = reader.ReadToEnd();
  9436. reader.Close();
  9437. }
  9438. }
  9439. catch (Exception ex)
  9440. {
  9441. return ex.Message;
  9442. }
  9443. finally
  9444. {
  9445. request = null;
  9446. requestStream = null;
  9447. response = null;
  9448. }
  9449. return responseStr;
  9450. }
  9451. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  9452. {
  9453. string base64FileContent;
  9454. string fileName;
  9455. using (WebClient webClient = new WebClient())
  9456. {
  9457. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  9458. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  9459. {
  9460. using (Stream stream = response.GetResponseStream())
  9461. {
  9462. using (MemoryStream memoryStream = new MemoryStream())
  9463. {
  9464. stream.CopyTo(memoryStream);
  9465. byte[] fileBytes = memoryStream.ToArray();
  9466. base64FileContent = Convert.ToBase64String(fileBytes);
  9467. fileName = response.Headers["Content-Disposition"];
  9468. if (!string.IsNullOrEmpty(fileName))
  9469. {
  9470. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  9471. if (index >= 0)
  9472. {
  9473. fileName = fileName.Substring(index + 9).Trim('\"');
  9474. }
  9475. }
  9476. else
  9477. {
  9478. fileName = Path.GetFileName(downloadUrl);
  9479. }
  9480. }
  9481. }
  9482. }
  9483. }
  9484. return (fileName, base64FileContent);
  9485. }
  9486. //新增
  9487. public void order_batch_caiyingtong(string[] downloadUrls)
  9488. {
  9489. try
  9490. {
  9491. //遍历文件
  9492. DataStruct dStruct = GetPostStruct();
  9493. DataTable dt = null;
  9494. int userid = CurrentUser.UserID;
  9495. List<string> ids = new List<string>();//失败组
  9496. List<string> tids = new List<string>();
  9497. using (WebClient webClient = new WebClient())
  9498. {
  9499. foreach (var url in downloadUrls)
  9500. {
  9501. try
  9502. {
  9503. tids.Add("'" + url + "'");
  9504. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  9505. if (entity != null)
  9506. {
  9507. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9508. if (cp == null)
  9509. {
  9510. JObject jsonObject = new JObject
  9511. {
  9512. { "Userid", "77886" },
  9513. { "pwd", "lt666888" },
  9514. { "Filename",entity.seller_memo }
  9515. };
  9516. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9517. JObject jsonObjects = JObject.Parse(response);
  9518. string msg = (string)jsonObjects["msg"];
  9519. if (msg == "报价成功")
  9520. {
  9521. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9522. DownloadAndConvertToBase64(url1);
  9523. }
  9524. else
  9525. {
  9526. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9527. }
  9528. }
  9529. else
  9530. {
  9531. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9532. JObject jsonObject = new JObject
  9533. {
  9534. { "Userid", "77886" },
  9535. { "pwd", "lt666888" },
  9536. { "Filename",chanp }
  9537. };
  9538. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9539. JObject jsonObjects = JObject.Parse(response);
  9540. string msg = (string)jsonObjects["msg"];
  9541. if (msg == "报价成功")
  9542. {
  9543. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  9544. DownloadAndConvertToBase64(url1);
  9545. }
  9546. else
  9547. {
  9548. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  9549. }
  9550. }
  9551. }
  9552. // 上传文件到FTP
  9553. }
  9554. catch (Exception ex)
  9555. {
  9556. Console.WriteLine($"An error occurred: {ex.Message}");
  9557. }
  9558. }
  9559. List<string> lw = new List<string>();
  9560. lw.Add(string.Format("( OrderState < 6 )"));
  9561. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  9562. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9563. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  9564. if (dt.Rows.Count > 0)
  9565. {
  9566. foreach (DataRow dr in dt.Rows)
  9567. {
  9568. ids.Add(dr["ctid"].ToString());
  9569. }
  9570. }
  9571. String ErrorMsgs = "";
  9572. foreach (String id in ids)
  9573. {
  9574. ErrorMsgs += id + ",";
  9575. }
  9576. if (ErrorMsgs.Length > 1)
  9577. {
  9578. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  9579. }
  9580. if (ErrorMsgs.Length < 1)
  9581. {
  9582. ErrorMsgs = "上传成功";
  9583. returnSuccessMsg(ErrorMsgs);
  9584. }
  9585. else
  9586. {
  9587. returnErrorMsg("以下订单" + ErrorMsgs);
  9588. }
  9589. }
  9590. // 删除文件夹及其内容
  9591. /* Directory.Delete(localDirectory, true);*/
  9592. }
  9593. catch { }
  9594. }
  9595. public void get_center_data()
  9596. {
  9597. int userId = CurrentUser.UserID;
  9598. string postCode = CurrentUser.UserPost.Post.Code;
  9599. List<string> lw = new List<string>();
  9600. List<string> ww = new List<string>();
  9601. DateTime currentTime = DateTime.Now;
  9602. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9603. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9604. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9605. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9606. string sql = " SELECT ";
  9607. string startTime = "2023-10-01 11:22:31";
  9608. //设计
  9609. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9610. {
  9611. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9612. 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));
  9613. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9614. 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));
  9615. }
  9616. //客服
  9617. else if (postCode == "CustomerService" || postCode == "Director")
  9618. {
  9619. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  9620. 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));
  9621. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9622. 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));
  9623. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9624. 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));
  9625. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  9626. 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));
  9627. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9628. 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));
  9629. }
  9630. //售后
  9631. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9632. {
  9633. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9634. 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));
  9635. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  9636. 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));
  9637. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9638. 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));
  9639. }
  9640. //下单部
  9641. else if (postCode == "Place" || postCode == "PlaceMr")
  9642. {
  9643. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  9644. 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));
  9645. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  9646. 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));
  9647. }
  9648. //车间
  9649. else if (postCode == "Supplier")
  9650. {
  9651. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  9652. 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));
  9653. }
  9654. DataTable dt = new DataTable();
  9655. if (lw.Count > 0)
  9656. {
  9657. sql += string.Join(" , ", lw);
  9658. sql += " FROM ";
  9659. sql += string.Join(" , ", ww);
  9660. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  9661. }
  9662. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9663. }
  9664. public void get_center_data_list()
  9665. {
  9666. int userId = CurrentUser.UserID;
  9667. string postCode = CurrentUser.UserPost.Post.Code;
  9668. string shopIds = CurrentUser.User.pemShop;
  9669. DataStruct dStruct = GetPostStruct();
  9670. List<string> lw = new List<string>();
  9671. DateTime currentTime = DateTime.Now;
  9672. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  9673. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9674. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  9675. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  9676. string startTime = "2023-10-01 11:22:31";
  9677. int order_type = GetPostInt("order_type");
  9678. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  9679. {
  9680. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  9681. if (order_type == 0)
  9682. {
  9683. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9684. }
  9685. else if (order_type == 3)
  9686. {
  9687. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  9688. }
  9689. else
  9690. {
  9691. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9692. }
  9693. }
  9694. //客服
  9695. if (postCode == "CustomerService" || postCode == "Director")
  9696. {
  9697. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  9698. if (order_type == 0)
  9699. {
  9700. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  9701. }
  9702. else if (order_type == 1)
  9703. {
  9704. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9705. }
  9706. else if (order_type == 2)
  9707. {
  9708. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9709. }
  9710. else if (order_type == 3)
  9711. {
  9712. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  9713. }
  9714. else if (order_type == 4)
  9715. {
  9716. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9717. }
  9718. else
  9719. {
  9720. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9721. }
  9722. }
  9723. //售后
  9724. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  9725. {
  9726. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9727. if (shopIds != "")
  9728. {
  9729. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9730. }
  9731. if (order_type == 2)
  9732. {
  9733. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9734. }
  9735. else if (order_type == 4)
  9736. {
  9737. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  9738. }
  9739. else if (order_type == 5)
  9740. {
  9741. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  9742. }
  9743. else
  9744. {
  9745. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9746. }
  9747. }
  9748. //下单部
  9749. if (postCode == "Place" || postCode == "PlaceMr")
  9750. {
  9751. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9752. if (shopIds != "")
  9753. {
  9754. lw.Add(string.Format("ShopId in ({0})", shopIds));
  9755. }
  9756. else if (order_type == 1)
  9757. {
  9758. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  9759. }
  9760. else if (order_type == 2)
  9761. {
  9762. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  9763. }
  9764. else
  9765. {
  9766. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9767. }
  9768. }
  9769. //车间
  9770. if (postCode == "Supplier")
  9771. {
  9772. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  9773. if (order_type == 5)
  9774. {
  9775. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  9776. }
  9777. else
  9778. {
  9779. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  9780. }
  9781. }
  9782. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9783. dStruct.Fileds = "tid,ctid";
  9784. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  9785. writeGridDataTableJson(dStruct.TotalCount, dt);
  9786. }
  9787. public void aftersale_audit_master()
  9788. {
  9789. if (UrlPostParmsCheck("ctid"))
  9790. {
  9791. string ctid = GetPostString("ctid");
  9792. if (ctid.Length > 0)
  9793. {
  9794. bool result = aftersale_data_change(ctid);
  9795. if (result)
  9796. {
  9797. returnSuccessMsg("修改成功!");
  9798. return;
  9799. }
  9800. }
  9801. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9802. }
  9803. }
  9804. public void aftersale_batch_audit_master()
  9805. {
  9806. if (UrlPostParmsCheck("ctids"))
  9807. {
  9808. string ctids = GetPostString("ctids");
  9809. if (ctids.Length > 0)
  9810. {
  9811. List<string> list = new List<string>();
  9812. string[] ctid_list = ctids.Split(',');
  9813. foreach (var item in ctid_list)
  9814. {
  9815. bool result = aftersale_data_change(item);
  9816. if (!result)
  9817. {
  9818. list.Add(item);
  9819. }
  9820. }
  9821. if (list.Count > 0)
  9822. {
  9823. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  9824. return;
  9825. }
  9826. returnSuccessMsg("修改成功!");
  9827. return;
  9828. }
  9829. returnErrorMsg("找不到指定售后单对应的原始订单!");
  9830. }
  9831. }
  9832. public bool aftersale_data_change(string ctid)
  9833. {
  9834. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  9835. if (ceErpTradeCell != null)
  9836. {
  9837. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  9838. ceErpTradeCell.AfterSaleSupplierState = 0;
  9839. StringBuilder sql = new StringBuilder();
  9840. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  9841. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9842. 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 == "不理赔")
  9843. {
  9844. CeErpTradeResponsible.DelByTid(ctid, 1);
  9845. ceErpTradeCell.AfterSaleSupplierState = 1;
  9846. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9847. ceErpTradeCell.AfterSaleState = 4;
  9848. }
  9849. else
  9850. {
  9851. ceErpTradeCell.AfterSaleState = 3;
  9852. }
  9853. bool needCyt = false;
  9854. if (dt != null)
  9855. {
  9856. if (dt.Rows.Count == 1)
  9857. {
  9858. bool isEnd = false;
  9859. foreach (DataRow dr in dt.Rows)
  9860. {
  9861. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9862. {
  9863. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9864. isEnd = true;
  9865. }
  9866. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  9867. {
  9868. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9869. isEnd = true;
  9870. }
  9871. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9872. {
  9873. needCyt = true;
  9874. }
  9875. }
  9876. if (isEnd)
  9877. {
  9878. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9879. ceErpTradeCell.AfterSaleState = 4;
  9880. ceErpTradeCell.AfterSaleSupplierState = 1;
  9881. }
  9882. }
  9883. else
  9884. {
  9885. bool isAll = true;
  9886. foreach (DataRow dr in dt.Rows)
  9887. {
  9888. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  9889. {
  9890. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9891. continue;
  9892. }
  9893. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  9894. {
  9895. string path = "";
  9896. int OrgID = 0;
  9897. if (!Convert.IsDBNull(dr["OrgPath"]))
  9898. {
  9899. path = dr["OrgPath"].ToString();
  9900. }
  9901. if (!Convert.IsDBNull(dr["OrgID"]))
  9902. {
  9903. OrgID = Convert.ToInt32(dr["OrgID"]);
  9904. }
  9905. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  9906. {
  9907. CeErpTradeResponsible.DelById(dr["ID"], 1);
  9908. continue;
  9909. }
  9910. }
  9911. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  9912. {
  9913. needCyt = true;
  9914. }
  9915. isAll = false;
  9916. }
  9917. if (isAll)
  9918. {
  9919. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  9920. ceErpTradeCell.AfterSaleState = 4;
  9921. ceErpTradeCell.AfterSaleSupplierState = 1;
  9922. }
  9923. }
  9924. }
  9925. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  9926. {
  9927. commonHelper.sendCytAfterSale(ceErpTradeCell);
  9928. }
  9929. if (ceErpTradeCell.AfterSaleState == 4)
  9930. {
  9931. ApiVo apiVo = new ApiVo();
  9932. apiVo.orderNumber = ceErpTradeCell.ctid;
  9933. apiVo.actionName = "afterOver";
  9934. designHelper.API_WorkCore(apiVo); //afterOver
  9935. }
  9936. ceErpTradeCell.Update();
  9937. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  9938. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  9939. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  9940. return true;
  9941. }
  9942. return false;
  9943. }
  9944. public void get_erp_wechatorder()
  9945. {
  9946. DataStruct dStruct = GetPostStruct();
  9947. List<string> lw = new List<string>();
  9948. string tid = GetPostString("tid");
  9949. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9950. string shopname = GetPostString("shopname");
  9951. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9952. string buyernick = GetPostString("buyer_nick");
  9953. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9954. string customer = GetPostString("customer");
  9955. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9956. string returndate1 = GetPostString("returndate1");
  9957. string returndate2 = GetPostString("returndate2");
  9958. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9959. if (dw.Length > 0) lw.Add(dw);
  9960. string finishDate1 = GetPostString("finishdate1");
  9961. string finishDate2 = GetPostString("finishdate2");
  9962. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9963. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9964. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9965. dStruct.Order = "created desc";
  9966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9967. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  9968. writeGridDataTableJson(dStruct.TotalCount, dt);
  9969. }
  9970. public void get_erp_wechatlist_sumprice()
  9971. {
  9972. DataStruct dStruct = GetPostStruct();
  9973. List<string> lw = new List<string>();
  9974. string tid = GetPostString("tid");
  9975. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9976. string shopname = GetPostString("shopname");
  9977. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9978. string buyernick = GetPostString("buyer_nick");
  9979. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9980. string customer = GetPostString("customer");
  9981. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9982. string returndate1 = GetPostString("returndate1");
  9983. string returndate2 = GetPostString("returndate2");
  9984. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9985. if (dw.Length > 0) lw.Add(dw);
  9986. string finishDate1 = GetPostString("finishdate1");
  9987. string finishDate2 = GetPostString("finishdate2");
  9988. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9989. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9990. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  9991. string mainWhere = string.Join(" and ", lw.ToArray());
  9992. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  9993. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  9994. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  9995. decimal total = 0;
  9996. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  9997. {
  9998. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  9999. }
  10000. var res = new
  10001. {
  10002. data = total
  10003. };
  10004. string ro_jsond = JsonConvert.SerializeObject(res);
  10005. returnSuccess(ro_jsond);
  10006. return;
  10007. }
  10008. public void get_erp_qr_waitdeliverylist()
  10009. {
  10010. DataStruct dStruct = GetPostStruct();
  10011. List<string> lw = new List<string>();
  10012. string tid = GetPostString("ctid");
  10013. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10014. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10015. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10016. var res_objz = new
  10017. {
  10018. restype = 1,
  10019. data = dt
  10020. };
  10021. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10022. returnSuccess(ro_jsonz);
  10023. }
  10024. public void get_erp_yield_list()
  10025. {
  10026. DataStruct dStruct = GetPostStruct();
  10027. List<string> lw = new List<string>();
  10028. string tid = GetPostString("ctid");
  10029. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10030. string shopname = GetPostString("shopname");
  10031. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10032. string buyernick = GetPostString("buyer_nick");
  10033. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10034. //if (tid.Length == 0 && buyernick.Length == 0)
  10035. //{
  10036. // lw.Add(string.Format("IsRefund<={0}", 1));
  10037. //}
  10038. string customer = GetPostString("customer");
  10039. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10040. string design = GetPostString("design");
  10041. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10042. string orderState = GetPostString("orderState");
  10043. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10044. string address = GetPostString("address");
  10045. 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));
  10046. string sellermemo = GetPostString("seller_memo");
  10047. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10048. string supplier = GetPostString("supplier");
  10049. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10050. string OrderArea = GetPostString("order_area");
  10051. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10052. string placedate1 = GetPostString("placedate1");
  10053. string placedate2 = GetPostString("placedate2");
  10054. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10055. if (fdw.Length > 0) lw.Add(fdw);
  10056. string price1 = GetPostString("price1");
  10057. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10058. string price2 = GetPostString("price2");
  10059. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10060. string unusualCon = GetPostString("unusualcon");
  10061. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10062. string posTag = CurrentUser.UserPost.Post.Code;
  10063. if (posTag == "Supplier")
  10064. {
  10065. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10066. }
  10067. lw.Add(string.Format("OrderState = 6 "));
  10068. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10069. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10070. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10071. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10072. writeGridDataTableJson(dStruct.TotalCount, dt);
  10073. }
  10074. public void change_erp_sup_state()
  10075. {
  10076. if (UrlPostParmsCheck("ctid"))
  10077. {
  10078. string ctid = GetPostString("ctid");
  10079. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10080. if (ceErpTradeCell != null)
  10081. {
  10082. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10083. if (ceErpTradeCellExtend == null)
  10084. {
  10085. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10086. ceErpTradeCellExtend.ctid = ctid;
  10087. ceErpTradeCellExtend.SupState = 1;
  10088. ceErpTradeCellExtend.Create();
  10089. }
  10090. else
  10091. {
  10092. ceErpTradeCellExtend.SupState = 1;
  10093. ceErpTradeCellExtend.Update();
  10094. }
  10095. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10096. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10097. return;
  10098. }
  10099. returnErrorMsg("找不到订单");
  10100. }
  10101. }
  10102. public void supplier_all_downs()
  10103. {
  10104. if (UrlPostParmsCheck("tids"))
  10105. {
  10106. string tids = GetPostString("tids");
  10107. if (tids != null && tids.Length > 0)
  10108. {
  10109. StringBuilder sql = new StringBuilder();
  10110. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6 where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10111. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10112. sql = new StringBuilder();
  10113. 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, "下载设计文件");
  10114. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10115. string[] list = tids.Split(',');
  10116. foreach (string ctid in list)
  10117. {
  10118. CeErpSukuraData.createInfo(ctid, 3);
  10119. }
  10120. designHelper.api_approveDesign(tids); //approveDesign
  10121. returnSuccessMsg("下载成功!");
  10122. return;
  10123. }
  10124. returnErrorMsg("下载订单更新失败");
  10125. }
  10126. }
  10127. public void uploaderFileSuccess()
  10128. {
  10129. if (UrlPostParmsCheck("fileName"))
  10130. {
  10131. string fileName = GetPostString("fileName");
  10132. ApiVo apiVo = new ApiVo();
  10133. apiVo.orderNumber = fileName;
  10134. apiVo.actionName = "finishDesign";
  10135. designHelper.API_WorkCore(apiVo);//finishDesign
  10136. returnSuccessMsg("");
  10137. }
  10138. }
  10139. public void get_sample2_order()
  10140. {
  10141. if (UrlPostParmsCheck("ctid"))
  10142. {
  10143. string ctid = GetPostString("ctid");
  10144. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10145. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10146. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10147. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10148. double total = 0.0;
  10149. double order_price = 0.0;
  10150. if (dt_bu.Rows.Count > 0)
  10151. {
  10152. foreach (DataRow dr in dt_bu.Rows)
  10153. {
  10154. total += Convert.ToDouble(dr["payment"]);
  10155. }
  10156. }
  10157. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10158. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10159. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10160. string tid = ctid.Replace("S_", "");
  10161. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10162. double paymant = 0.0;
  10163. if (entity != null)
  10164. {
  10165. paymant = entity.payment;
  10166. }
  10167. string return_reason = "";
  10168. if (dt_after != null && dt_after.Rows.Count > 0)
  10169. {
  10170. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10171. }
  10172. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10173. }
  10174. }
  10175. public void get_erp_design_status()
  10176. {
  10177. string designName = GetPostString("designName");
  10178. DataStruct dStruct = GetPostStruct();
  10179. if (designName.Length > 0)
  10180. {
  10181. 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";
  10182. sql_user += " and Name like '%" + designName + "%'";
  10183. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10184. List<string> ids_list = new List<string>();
  10185. if (user_table.Rows.Count > 0)
  10186. {
  10187. foreach (DataRow item in user_table.Rows)
  10188. {
  10189. ids_list.Add(item["id"].ToString());
  10190. string ids_s = item["TeamIds"].ToString();
  10191. if (ids_s.Length > 0)
  10192. {
  10193. ids_list.AddRange(ids_s.Split(','));
  10194. }
  10195. }
  10196. }
  10197. HashSet<string> set = new HashSet<string>(ids_list);
  10198. ids_list = set.ToList();
  10199. if (ids_list.Count > 0)
  10200. {
  10201. 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));
  10202. dStruct.MainWhere = sql;
  10203. DataTable dt = null;
  10204. dt = WebCache.GetData("view_ErpUser", dStruct);
  10205. writeGridDataTableJson(dStruct.TotalCount, dt);
  10206. }
  10207. }
  10208. }
  10209. public void change_erp_order_price()
  10210. {
  10211. string ctid = GetPostString("ctid");
  10212. double price = GetPostDouble("price");
  10213. if (ctid.Length > 0)
  10214. {
  10215. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10216. if (ceErpTradeCellExtend == null)
  10217. {
  10218. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10219. ceErpTradeCellExtend.ctid = ctid;
  10220. ceErpTradeCellExtend.payment_cyt = price;
  10221. ceErpTradeCellExtend.Create();
  10222. }
  10223. else
  10224. {
  10225. ceErpTradeCellExtend.payment_cyt = price;
  10226. ceErpTradeCellExtend.Update();
  10227. }
  10228. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10229. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10230. {
  10231. ceErpDataSendOrderInfo.isSync = false;
  10232. ceErpDataSendOrderInfo.Update();
  10233. }
  10234. if (ceErpDataSendOrderInfo == null)
  10235. {
  10236. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10237. ceErpDataSendOrderInfo.isSync = false;
  10238. ceErpDataSendOrderInfo.ctid = ctid;
  10239. ceErpDataSendOrderInfo.Create();
  10240. }
  10241. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10242. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10243. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10244. if (dth != null && dth.Rows.Count > 0)
  10245. {
  10246. dataSendOrderBean dataSendOrderBean = null;
  10247. foreach (DataRow item in dth.Rows)
  10248. {
  10249. try
  10250. {
  10251. dataSendOrderBean = new dataSendOrderBean();
  10252. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10253. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10254. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10255. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10256. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10257. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10258. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10259. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10260. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10261. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10262. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10263. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10264. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10265. if (result != null)
  10266. {
  10267. if ("0".Equals(result.errcode))
  10268. {
  10269. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10270. }
  10271. else
  10272. {
  10273. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10274. }
  10275. }
  10276. }
  10277. catch (Exception ex)
  10278. {
  10279. }
  10280. }
  10281. }
  10282. returnSuccessMsg("修改成功!");
  10283. return;
  10284. }
  10285. returnErrorMsg("找不到订单");
  10286. }
  10287. public void find_he_together()
  10288. {
  10289. string ctid = GetPostString("ctid");
  10290. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10291. List<string> list = new List<string>();
  10292. if (ceErpTradeCell != null)
  10293. {
  10294. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10295. {
  10296. 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);
  10297. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10298. if (table != null && table.Rows.Count > 0)
  10299. {
  10300. foreach (TableRow row in table.Rows)
  10301. {
  10302. }
  10303. }
  10304. }
  10305. }
  10306. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10307. }
  10308. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10309. {
  10310. //chy----19
  10311. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10312. //GD-CYT-----64
  10313. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10314. //ZHX----3
  10315. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10316. //JK----97
  10317. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10318. //ZT----70
  10319. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10320. //LHCY-----98
  10321. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10322. //XD-----90
  10323. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10324. //CYCY-----14
  10325. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10326. };
  10327. //其他改名
  10328. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10329. {
  10330. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10331. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10332. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10333. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10334. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10335. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10336. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10337. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10338. };
  10339. //不统计
  10340. List<int> no_suppliers = new List<int>()
  10341. {
  10342. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10343. };
  10344. //配件单
  10345. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10346. {
  10347. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10348. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10349. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10350. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10351. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10352. {"旗杆",new List<string>(){ "班旗" } },
  10353. {"牙签",new List<string>(){ "不干胶" } }
  10354. };
  10355. public void get_place_order_data()
  10356. {
  10357. string date1 = GetPostString("date1");
  10358. string date2 = GetPostString("date2");
  10359. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10360. DateTime start = DateTime.Parse(starttime);
  10361. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10362. DateTime end = DateTime.Parse(endtime);
  10363. if (date1 != null && date1.Length > 0)
  10364. {
  10365. DateTime dateTime = DateTime.Parse(date1);
  10366. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10367. start = DateTime.Parse(starttime);
  10368. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10369. end = DateTime.Parse(endtime);
  10370. }
  10371. if (date2 != null && date2.Length > 0)
  10372. {
  10373. DateTime dateTime = DateTime.Parse(date2);
  10374. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10375. end = DateTime.Parse(endtime);
  10376. }
  10377. 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);
  10378. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10379. //不干胶-----1,卡片-----29
  10380. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10381. foreach (DataRow row in data.Rows)
  10382. {
  10383. int productId = Convert.ToInt32(row["ProductId"]);
  10384. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10385. if (no_suppliers.Contains(supplierId))
  10386. {
  10387. continue;
  10388. }
  10389. string seller_memo = row["seller_memo"].ToString();
  10390. bool ispj = false;//是否配件单
  10391. bool isfirst = true;//第一个配
  10392. maps.Keys.ForEach(key =>
  10393. {
  10394. //备注包含配件
  10395. if (seller_memo.Contains(key) && isfirst)
  10396. {
  10397. List<string> list = maps[key];
  10398. ispj = true;
  10399. isfirst = false;
  10400. for (int i = 0; i < list.Count; i++)
  10401. {
  10402. if (seller_memo.Contains(list[i]))
  10403. {
  10404. ispj = false;
  10405. break;
  10406. }
  10407. }
  10408. }
  10409. });
  10410. if (ispj)
  10411. {
  10412. continue;
  10413. }
  10414. seller_memo = seller_memo.Replace("UV", "uv");
  10415. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  10416. //吊牌归到卡片
  10417. seller_memo = seller_memo.Replace("吊牌", "卡片");
  10418. seller_memo = seller_memo.Replace("卡套", "卡片");
  10419. seller_memo = seller_memo.Replace("封套", "卡片");
  10420. seller_memo = seller_memo.Replace("吸管套", "卡片");
  10421. seller_memo = seller_memo.Replace("腰封", "卡片");
  10422. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  10423. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  10424. seller_memo = seller_memo.Replace("横幅", "条幅");
  10425. seller_memo = seller_memo.Replace("锦旗", "条幅");
  10426. string map_key = "";
  10427. string type = "";
  10428. if (supplierMap.ContainsKey(supplierId))
  10429. {
  10430. foreach (var kvp in supplierMap[supplierId])
  10431. {
  10432. if (seller_memo.Contains(kvp.Key))
  10433. {
  10434. map_key = kvp.Value;
  10435. type = kvp.Value;
  10436. break;
  10437. }
  10438. }
  10439. }
  10440. if (map_key == "")
  10441. {
  10442. type = "其他";
  10443. map_key = "其他";
  10444. }
  10445. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  10446. {
  10447. map_key = suppliers[supplierId];
  10448. }
  10449. if (supplierId == 70)
  10450. {
  10451. supplierId = 70;
  10452. }
  10453. map_key += "_" + row["SupplierName"].ToString();
  10454. Dictionary<string, int> map = null;
  10455. if (other_map.ContainsKey(map_key))
  10456. {
  10457. other_map.TryGetValue(map_key, out map);
  10458. }
  10459. else
  10460. {
  10461. map = new Dictionary<string, int>();
  10462. map.Add("dayDev", 0);//当天出货
  10463. map.Add("dayTotal", 0);//下单总数
  10464. map.Add("payTotal", 0);//500以上
  10465. map.Add("today", 0);//当天出货数量
  10466. map.Add("unusua", 0);//异常数
  10467. other_map.Add(map_key, map);
  10468. other_map.TryGetValue(map_key, out map);
  10469. }
  10470. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10471. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  10472. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  10473. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  10474. {
  10475. map["dayTotal"]++;
  10476. if (supplierId == 97)
  10477. {
  10478. supplierId = 97;
  10479. }
  10480. }
  10481. if (Convert.ToDecimal(row["payment"]) >= 500)
  10482. {
  10483. map["payTotal"]++;
  10484. }
  10485. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  10486. {
  10487. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  10488. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  10489. {
  10490. map["today"]++;
  10491. }
  10492. }
  10493. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  10494. {
  10495. map["unusua"]++;
  10496. }
  10497. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  10498. //GD-CYT-----64
  10499. DateTime two = palceTimeStart.AddHours(14);
  10500. DateTime three = palceTimeStart.AddHours(15);
  10501. DateTime four = palceTimeStart.AddHours(16);
  10502. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  10503. {
  10504. //下午四点前 500-1000
  10505. string count = row["ProductCount"].ToString();
  10506. if (count != null && count.Length > 0)
  10507. {
  10508. int productCount = commonHelper.getPlaceProductCount(count);
  10509. if (productCount >= 500 && productCount <= 1000)
  10510. {
  10511. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  10512. {
  10513. map["dayDev"]++;
  10514. }
  10515. }
  10516. }
  10517. }
  10518. //UV
  10519. else if ("uv".Equals(type))
  10520. {
  10521. //ZT----70
  10522. //ZHX----3
  10523. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  10524. {
  10525. map["dayDev"]++;
  10526. }
  10527. //JK----97
  10528. //HZX----105
  10529. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  10530. {
  10531. map["dayDev"]++;
  10532. if (supplierId == 97)
  10533. {
  10534. supplierId = 97;
  10535. Debug.WriteLine(map["dayTotal"].ToString() + "-" + map["dayDev"].ToString());
  10536. }
  10537. }
  10538. }
  10539. //帆布---52|条幅---27
  10540. else if ("帆布".Equals(type) || "条幅".Equals(type))
  10541. {
  10542. //LHCY-----98
  10543. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  10544. {
  10545. map["dayDev"]++;
  10546. }
  10547. }
  10548. //条幅
  10549. else if ("条幅".Equals(type))
  10550. {
  10551. //XD-----90
  10552. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  10553. {
  10554. map["dayDev"]++;
  10555. }
  10556. }
  10557. //桌布
  10558. else if ("桌布".Equals(type))
  10559. {
  10560. //XD-----90
  10561. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  10562. {
  10563. map["dayDev"]++;
  10564. }
  10565. }
  10566. //DL---10
  10567. //AYTW---119
  10568. //FS-CYT-DY ----80
  10569. //JK----97
  10570. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  10571. {
  10572. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  10573. {
  10574. map["dayDev"]++;
  10575. }
  10576. }
  10577. }
  10578. DataTable dt = new DataTable();
  10579. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  10580. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  10581. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  10582. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  10583. dt.Columns.Add(new DataColumn("today", typeof(string)));
  10584. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  10585. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  10586. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  10587. other_map.Keys.ForEach(key =>
  10588. {
  10589. DataRow dr = dt.NewRow();
  10590. Dictionary<string, int> map = other_map[key];
  10591. string[] key_list = key.Split('_');
  10592. dr[0] = key_list[0];
  10593. dr[1] = key_list[1];
  10594. if (key_list.Length > 2)
  10595. {
  10596. dr[1] += "(" + key_list[2] + ")";
  10597. }
  10598. dr[2] = map["dayTotal"];
  10599. dr[3] = map["payTotal"];
  10600. dr[4] = map["today"];
  10601. dr[5] = map["unusua"];
  10602. dr[6] = map["dayDev"];
  10603. double rate = 0.00;
  10604. if (map["dayDev"] > 0)
  10605. {
  10606. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  10607. }
  10608. dr[7] = rate.ToString();
  10609. dt.Rows.Add(dr);
  10610. });
  10611. DataView dv = new DataView(dt);
  10612. dv.Sort = "SupplierName";
  10613. //dv.Sort = "AllOrder desc";
  10614. DataTable dtNew = dv.ToTable();
  10615. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  10616. }
  10617. public void check_order_desing_info()
  10618. {
  10619. string ctid = GetPostString("ctid");
  10620. if (!string.IsNullOrEmpty(ctid))
  10621. {
  10622. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10623. if (ceErpTradeCell != null)
  10624. {
  10625. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  10626. returnSuccess(JsonConvert.SerializeObject(new { response }));
  10627. return;
  10628. }
  10629. returnErrorMsg("找不到订单");
  10630. return;
  10631. }
  10632. returnErrorMsg("找不到订单");
  10633. }
  10634. public void get_timeout_detail()
  10635. {
  10636. string poscode = CurrentUser.UserPost.Post.Code;
  10637. DataStruct dStruct = GetPostStruct();
  10638. List<string> lw = new List<string>();
  10639. string id = GetPostString("id");
  10640. string pay_date1 = GetPostString("pay_date1");
  10641. string pay_date2 = GetPostString("pay_date2");
  10642. int type = GetPostInt("type");
  10643. if (type == 0)
  10644. {
  10645. if (pay_date1.Length > 0)
  10646. {
  10647. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  10648. }
  10649. if (pay_date2.Length > 0)
  10650. {
  10651. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  10652. }
  10653. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  10654. }
  10655. if (type == 1)
  10656. {
  10657. if (pay_date1.Length > 0)
  10658. {
  10659. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  10660. }
  10661. if (pay_date2.Length > 0)
  10662. {
  10663. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  10664. }
  10665. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  10666. }
  10667. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10668. DataTable dt = null;
  10669. dt = WebCache.GetData("view_orderlist", dStruct);
  10670. writeGridDataTableJson(dStruct.TotalCount, dt);
  10671. }
  10672. public void saveUrgentChargePrice()
  10673. {
  10674. string ctid = GetPostString("ctid");
  10675. if (!string.IsNullOrEmpty(ctid))
  10676. {
  10677. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10678. if (ceErpTradeCell != null)
  10679. {
  10680. double price = GetPostDouble("price");
  10681. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  10682. if (ceErpTradeCellExtend == null)
  10683. {
  10684. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10685. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  10686. }
  10687. ceErpTradeCellExtend.urgentCharge = price;
  10688. if (ceErpTradeCellExtend.ID > 0)
  10689. {
  10690. ceErpTradeCellExtend.Update();
  10691. }
  10692. else
  10693. {
  10694. ceErpTradeCellExtend.Save();
  10695. }
  10696. returnSuccessMsg("修改成功!");
  10697. return;
  10698. }
  10699. returnErrorMsg("找不到订单");
  10700. return;
  10701. }
  10702. returnErrorMsg("找不到订单");
  10703. }
  10704. public void finish_erp_order()
  10705. {
  10706. string ctid = GetPostString("ctid");
  10707. if (!string.IsNullOrEmpty(ctid))
  10708. {
  10709. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  10710. {
  10711. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10712. if (ceErpTradeCell != null)
  10713. {
  10714. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  10715. ceErpTradeCell.Update();
  10716. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  10717. returnSuccessMsg("修改成功!");
  10718. return;
  10719. }
  10720. }
  10721. }
  10722. returnErrorMsg("找不到订单");
  10723. }
  10724. public void get_trade_order_list()
  10725. {
  10726. string tid = GetPostString("tid");
  10727. if (!string.IsNullOrEmpty(tid))
  10728. {
  10729. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  10730. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10731. writeGridDataTableJson(data.Rows.Count, data);
  10732. return;
  10733. }
  10734. returnErrorMsg("找不到订单");
  10735. }
  10736. public void save_cell_spu()
  10737. {
  10738. string ctid = GetPostString("ctid");
  10739. string spu_id = GetPostString("spu_id");
  10740. if (!string.IsNullOrEmpty(ctid))
  10741. {
  10742. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10743. if (ceErpTradeCellExtend == null)
  10744. {
  10745. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10746. ceErpTradeCellExtend.ctid = ctid;
  10747. }
  10748. ceErpTradeCellExtend.spu_id = spu_id;
  10749. if (ceErpTradeCellExtend.ID == 0)
  10750. {
  10751. ceErpTradeCellExtend.Create();
  10752. }
  10753. else
  10754. {
  10755. ceErpTradeCellExtend.Update();
  10756. }
  10757. returnSuccessMsg("修改成功!");
  10758. return;
  10759. }
  10760. returnErrorMsg("找不到订单");
  10761. }
  10762. public void change_express_info()
  10763. {
  10764. string ctid = GetPostString("ctid");
  10765. string transNo = GetPostString("transNo");
  10766. string transCom = GetPostString("transCom");
  10767. if (!string.IsNullOrEmpty(ctid))
  10768. {
  10769. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10770. if (ceErpTradeCellExtend == null)
  10771. {
  10772. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10773. ceErpTradeCellExtend.ctid = ctid;
  10774. }
  10775. ceErpTradeCellExtend.modExpressNo = transNo;
  10776. ceErpTradeCellExtend.modExpressCom = transCom;
  10777. ceErpTradeCellExtend.readMod = 2;
  10778. if (ceErpTradeCellExtend.ID == 0)
  10779. {
  10780. ceErpTradeCellExtend.Create();
  10781. }
  10782. else
  10783. {
  10784. ceErpTradeCellExtend.Update();
  10785. }
  10786. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  10787. returnSuccessMsg("修改成功!");
  10788. return;
  10789. }
  10790. returnErrorMsg("找不到订单");
  10791. }
  10792. public void get_change_express_list()
  10793. {
  10794. DataStruct dStruct = GetPostStruct();
  10795. List<string> lw = new List<string>();
  10796. int st = 2;
  10797. string tid = GetPostString("ctid");
  10798. if (tid.Length > 0) lw.Add(string.Format("(ctid = '{0}' or tid = '{0}' or orderSn = '{0}')", tid));
  10799. string shopname = GetPostString("shopname");
  10800. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10801. string buyernick = GetPostString("buyer_nick");
  10802. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10803. string sellermemo = GetPostString("seller_memo");
  10804. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10805. string supplier = GetPostString("supplier");
  10806. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10807. string customer = GetPostString("customer");
  10808. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10809. string design = GetPostString("design");
  10810. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10811. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  10812. string poscode = CurrentUser.UserPost.Post.Code;
  10813. if (poscode != "SysAdmin")
  10814. {
  10815. string shopid = CurrentUser.User.pemShop;
  10816. lw.Add(string.Format("shopId in ({0})", shopid));
  10817. }
  10818. lw.Add("readMod = 2");
  10819. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10820. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10821. writeGridDataTableJson(dStruct.TotalCount, dt);
  10822. }
  10823. public void deal_express_complete()
  10824. {
  10825. string ctid = GetPostString("ctid");
  10826. if (!string.IsNullOrEmpty(ctid))
  10827. {
  10828. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10829. if (ceErpTradeCellExtend == null)
  10830. {
  10831. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10832. ceErpTradeCellExtend.ctid = ctid;
  10833. }
  10834. ceErpTradeCellExtend.readMod = 1;
  10835. if (ceErpTradeCellExtend.ID == 0)
  10836. {
  10837. ceErpTradeCellExtend.Create();
  10838. }
  10839. else
  10840. {
  10841. ceErpTradeCellExtend.Update();
  10842. }
  10843. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  10844. returnSuccessMsg("修改成功!");
  10845. return;
  10846. }
  10847. returnErrorMsg("找不到订单");
  10848. }
  10849. public void aftersale_return_visit()
  10850. {
  10851. string ctid = GetPostString("ctid");
  10852. if (!string.IsNullOrEmpty(ctid))
  10853. {
  10854. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10855. if (ceErpTradeCellExtend == null)
  10856. {
  10857. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10858. ceErpTradeCellExtend.ctid = ctid;
  10859. }
  10860. ceErpTradeCellExtend.returnVisit = 1;
  10861. if (ceErpTradeCellExtend.ID == 0)
  10862. {
  10863. ceErpTradeCellExtend.Create();
  10864. }
  10865. else
  10866. {
  10867. ceErpTradeCellExtend.Update();
  10868. }
  10869. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  10870. if (ceErpTradeAfterSaleExtend != null)
  10871. {
  10872. ceErpTradeAfterSaleExtend.TextResult = "";
  10873. ceErpTradeAfterSaleExtend.Update();
  10874. }
  10875. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  10876. returnSuccessMsg("修改成功!");
  10877. return;
  10878. }
  10879. returnErrorMsg("找不到订单");
  10880. }
  10881. public void orderPlaceInfo()
  10882. {
  10883. string ctids = GetPostString("ctids");
  10884. string[] list = ctids.Split(',');
  10885. foreach (string ctid in list)
  10886. {
  10887. CeErpSukuraData.createInfo(ctid, 3);
  10888. }
  10889. designHelper.api_approveDesign(ctids); //approveDesign
  10890. returnSuccessMsg("");
  10891. }
  10892. }
  10893. }