sync.order.cs 604 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088
  1. using BizCom;
  2. using Newtonsoft.Json;
  3. using Newtonsoft.Json.Linq;
  4. using NHibernate.Linq;
  5. using NHibernate.Mapping;
  6. using NPOI.OpenXmlFormats.Dml.Diagram;
  7. using NPOI.OpenXmlFormats.Shared;
  8. using NPOI.SS.Formula.Eval;
  9. using NPOI.SS.Formula.Functions;
  10. using NPOI.SS.Formula.Udf;
  11. using SiteCore.Redis;
  12. using SiteCore.taobao;
  13. using SiteCore.taoObj;
  14. using SQLData;
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.ComponentModel.Design;
  19. using System.Data;
  20. using System.Data.SqlClient;
  21. using System.Data.SqlTypes;
  22. using System.Diagnostics;
  23. using System.Drawing;
  24. using System.Drawing.Drawing2D;
  25. using System.IO;
  26. using System.Linq;
  27. using System.Net;
  28. using System.Net.Security;
  29. using System.Reflection.Emit;
  30. using System.Security.Cryptography;
  31. using System.Security.Cryptography.X509Certificates;
  32. using System.Security.Policy;
  33. using System.Text;
  34. using System.Text.RegularExpressions;
  35. using System.Threading;
  36. using System.Web.UI;
  37. using System.Web;
  38. using System.Web.UI.WebControls;
  39. using Utils;
  40. using Utils.Serialization;
  41. using static NHibernate.Linq.Visitors.LeftJoinDetector;
  42. using static SiteCore.taoObj.Api_trade_info;
  43. using static SiteCore.taoObj.Api_waybill_code_response_Obj;
  44. using static SiteCore.taoObj.work_core_vo;
  45. using static System.Net.Mime.MediaTypeNames;
  46. namespace SiteCore.Handler
  47. {
  48. public partial class sync
  49. {
  50. public void get_erp_orderlist()
  51. {
  52. string poscode = CurrentUser.UserPost.Post.Code;
  53. DataStruct dStruct = GetPostStruct();
  54. //apiHelper.Api_SyncOrderByTime("598825");
  55. //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
  56. //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
  57. //apiHelper.API_LogisticsOnlineSend("2460807662231834875", "yujia", "YTO-GDCYT", "YT7524607355919");
  58. //banniuApiHelper.sendLogisticsInfo(null);
  59. //commonHelper.setOrderDummyDelivery("4055992920657411904");
  60. //commonHelper.checkOrderListDesignInfo("1111122222333338841");
  61. //CeErpTradeCell entity = CeErpTradeCell.GetByCtid("2484048723252587257");
  62. //int sid = commonHelper.autoDistributeToSupplier(entity);
  63. // string a = apiHelper.API_GetPrintData("YT8951457355085");
  64. //tmcHelper.Api_TmcTradeMsg("{\"content\":{\"businessType\":\"GUARANTEE\",\"buyerMemo\":\"\",\"consolidateType\":\"\",\"createTime\":1744213772000,\"deliveryType\":\"OFFLINE\",\"discountFee\":0.0,\"flag\":\"NONE\",\"latestDeliveryTime\":1744818568000,\"lines\":[{\"mark2\":[],\"num\":1,\"outerId\":\"\",\"payment\":270.0,\"picUrl\":\"https://img.alicdn.com/bao/uploaded/i2/2214103531955/O1CN01DdUiJW1QJRIWIiuyV_!!0-item_pic.jpg\",\"platServiceFee\":0.0,\"price\":30.0,\"refOlId\":\"4295347347682697938\",\"refSkuId\":\"0\",\"refSpuId\":\"795632307774\",\"refundStatus\":\"NO_REFUND\",\"sellPrice\":30.0,\"singleFee\":270.0,\"spuOuterId\":\"\",\"standards\":\"\",\"status\":\"NOT_SHIPPED\",\"title\":\"【优惠价】纸质书签定制古风可手写硬卡纸制作来图定做创意卡片打印logo高档异形卡书法古典标签小卡印刷中国风文创设计\",\"totalFee\":270.0,\"totalPrice\":30.0,\"totalSellPrice\":30.0}],\"logisticsOrderNo\":\"\",\"mark2\":[],\"modifyTime\":1744213828000,\"openBuyerId\":\"AAHnRHraABkUZRPgSx30RW3E\",\"openBuyerNick\":\"s**\",\"openSellerNick\":\"福同鑫旗舰店\",\"orderSource\":\"SYNC\",\"orderTime\":1744212346000,\"payTime\":1744213768000,\"payment\":270.0,\"platServiceFee\":0.0,\"posCode\":\"futongxin\",\"posId\":613307,\"postFee\":240.0,\"props\":{\"payType\":\"ALI_PAY\",\"govSubsidyAmount\":0},\"receivedPayment\":0.0,\"receiverCity\":\"成都市\",\"receiverCountry\":\"中国\",\"receiverDistrict\":\"成华区\",\"receiverId\":\"d3709f8bce7faa8f6cc4587ff26feb66$\",\"receiverState\":\"四川省\",\"receiverTown\":\"猛追湾街道\",\"refOid\":\"4295347347682697938\",\"refType\":\"TMALL\",\"refundStatus\":\"NO_REFUND\",\"sellerMemo\":\"40x110mm-1000张-卡片-300克铜板纸-双面印刷覆哑膜直角裁切-summer67821-条条-打孔配流苏\",\"serviceFee\":0.0,\"status\":\"NOT_SHIPPED\",\"totalFee\":270.0,\"totalPrice\":30.0,\"totalSellPrice\":30.0,\"type\":\"SALE\"}}");
  65. //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}}");
  66. List<string> lw = new List<string>();
  67. string tid = GetPostString("ctid");
  68. string date1 = GetPostString("date1");
  69. //12-1 修改
  70. string urgent = GetPostString("urgent");
  71. string back = GetPostString("back");
  72. string offlineSearch = GetPostString("offlineSearch");
  73. int paramsCount = 0;
  74. if (!string.IsNullOrWhiteSpace(urgent))
  75. {
  76. if (urgent.Equals("true"))
  77. {
  78. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  79. }
  80. }
  81. if (!string.IsNullOrWhiteSpace(back))
  82. {
  83. if (back.Equals("true"))
  84. {
  85. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  86. }
  87. }
  88. if (!string.IsNullOrWhiteSpace(offlineSearch))
  89. {
  90. if (offlineSearch.Equals("true"))
  91. {
  92. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  93. }
  94. }
  95. //end
  96. string date2 = GetPostString("date2");
  97. string buyernick = GetPostString("buyer_nick");
  98. if (poscode == "wxDesigner" || poscode == "Designer" || poscode == "DesignerMr" || poscode == "wxDesignerMr")
  99. {
  100. if (tid.Length <= 0 && buyernick.Length <= 0)
  101. {
  102. return;
  103. }
  104. }
  105. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  106. {
  107. if (tid.Length > 0)
  108. {
  109. string select_tid = getTidByCtid(tid);
  110. lw.Add(string.Format("tid='{0}'", select_tid));
  111. }
  112. if (buyernick.Length > 0)
  113. {
  114. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  115. }
  116. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  117. if (dw.Length > 0)
  118. {
  119. lw.Add(dw);
  120. }
  121. if (poscode != "wxDesigner" && poscode != "Designer" && poscode != "DesignerMr" && poscode != "wxDesignerMr" && poscode != "SysAdmin")
  122. {
  123. string usershop = CurrentUser.User.pemShop;
  124. lw.Add(string.Format("ShopId in ({0})", usershop));
  125. }
  126. }
  127. else
  128. {
  129. if (ex_psize == 0)
  130. {
  131. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  132. }
  133. if (PKey != "admin")
  134. {
  135. string usershop = CurrentUser.User.pemShop;
  136. lw.Add(string.Format("ShopId in ({0})", usershop));
  137. paramsCount++;
  138. }
  139. }
  140. string uploaddate1 = GetPostString("uploaddate1");
  141. string uploaddate2 = GetPostString("uploaddate2");
  142. string update = GetDateMinuteWhere("FinishDesignTime", uploaddate1, uploaddate2);
  143. if (update.Length > 0) lw.Add(update);
  144. string deliverydate1 = GetPostString("deliverydate1");
  145. string deliverydate2 = GetPostString("deliverydate2");
  146. string deliverydate = GetDateMinuteWhere("FinishDeliveryTime", deliverydate1, deliverydate2);
  147. if (deliverydate.Length > 0)
  148. {
  149. lw.Add(string.Format("( delivery_time BETWEEN '{0}' AND '{1}' ) ", deliverydate1, deliverydate2));
  150. };
  151. string shopname = GetPostString("shopname");
  152. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  153. string addwechat = GetPostString("addwechat");
  154. if (addwechat.Length > 0)
  155. {
  156. int addWt = Convert.ToInt32(addwechat);
  157. if (addWt == 1) lw.Add(string.Format("IsAddWechat>={0}", addWt));
  158. else lw.Add(string.Format("IsAddWechat={0}", addWt));
  159. }
  160. string customer = GetPostString("customer");
  161. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  162. string design = GetPostString("design");
  163. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  164. string orderState = GetPostString("orderState");
  165. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  166. string address = GetPostString("address");
  167. 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));
  168. string sellermemo = GetPostString("seller_memo");
  169. if (sellermemo.Length > 0)
  170. {
  171. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  172. }
  173. string backReason = GetPostString("backReason");
  174. if (backReason.Length > 0)
  175. {
  176. lw.Add(string.Format("ReturnReason like '%{0}%'", backReason));
  177. }
  178. string apdate1 = GetPostString("apdate1");
  179. string apdate2 = GetPostString("apdate2");
  180. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  181. if (dwap.Length > 0) lw.Add(dwap);
  182. string price1 = GetPostString("price1");
  183. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  184. string price2 = GetPostString("price2");
  185. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  186. string isoldcustomer = GetPostString("isoldcus");
  187. string finishdate1 = GetPostString("finishdate1");
  188. string finishdate2 = GetPostString("finishdate2");
  189. string finishdate = GetDateMinuteWhere("end_time", finishdate1, finishdate2);
  190. bool isFinish = false;
  191. if (finishdate.Length > 0)
  192. {
  193. lw.Add(finishdate);
  194. isFinish = true;
  195. paramsCount++;
  196. }
  197. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  198. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  199. if (ex_psize > 0)
  200. {
  201. int UserID = CurrentUser.UserID;
  202. if (UserID == 220 || UserID == 222 || UserID == 654 || UserID == 655 || UserID == 497 ||
  203. UserID == 221 || UserID == 498 || UserID == 217 || UserID == 218) //这几个人只能到处现货礼物
  204. {
  205. lw.Add(string.Format("seller_memo like '%{0}%'", "礼物"));
  206. }
  207. dStruct.Order = "pay_time desc";
  208. }
  209. string isNew = GetPostString("isNew");
  210. if (isNew == "true")
  211. {
  212. lw.Add(string.Format("IsNew = {0}", 1));
  213. }
  214. string overtime = GetPostString("overtime");
  215. if (overtime == "1")
  216. {
  217. lw.Add(string.Format("StartDesignTime IS NOT NULL and FinishDesignTime IS NULL and datediff(hh,StartDesignTime,getdate())>=48"));
  218. }
  219. String usePost = CurrentUser.UserPost.Post.Code;
  220. if (usePost.Equals("Operation") == true)
  221. {
  222. dStruct.Order = "IsSendGift desc,isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  223. }
  224. else
  225. {
  226. dStruct.Order = "isRefund desc,IsUrgency desc,IsReturn desc,pay_time desc";
  227. }
  228. //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";
  229. if (dStruct.PageSize == 100000)
  230. {
  231. dStruct.Order = "";
  232. }
  233. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  234. DataTable dt = null;
  235. string tablename = "view_orderlist";
  236. if (isFinish)
  237. {
  238. tablename = "view_orderlist_end";
  239. }
  240. dt = WebCache.GetData(tablename, dStruct);
  241. if (dt != null && dt.Rows.Count > 0)
  242. {
  243. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  244. foreach (DataRow dr in dt.Rows)
  245. {
  246. try
  247. {
  248. if (dr["refund_fees"] != null)
  249. {
  250. decimal total_fee = decimal.Parse(dr["total_fee"].ToString()); //原订单总金额
  251. decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额
  252. decimal payment = decimal.Parse(dr["payment"].ToString()); //该订单金额
  253. if (payment == refund_fees)
  254. {
  255. dr["refund_fees"] = Math.Round(refund_fees, 2);
  256. }
  257. else if (refund_fees == total_fee)
  258. {
  259. dr["refund_fees"] = payment;
  260. }
  261. else
  262. {
  263. decimal result1 = Math.Round(refund_fees / total_fee, 2);//退款占总金额的百分比
  264. decimal result2 = Math.Round(payment / total_fee, 2);//该订单占总金额的百分比
  265. dr["refund_fees"] = Math.Round(refund_fees * result2, 2);
  266. }
  267. }
  268. // 对象操作
  269. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  270. ceErpTradeCell.ctid = dr["ctid"].ToString();
  271. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  272. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  273. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  274. if (dStruct.PageSize != 100000)
  275. {
  276. if (dr["DispatchSort"].ToString() == "2")
  277. {
  278. dr["gongchuang"] = 200;
  279. }
  280. else
  281. {
  282. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  283. dr["gongchuang"] = response.code;
  284. }
  285. }
  286. }
  287. catch (NullReferenceException ex)
  288. {
  289. // 处理空引用异常
  290. dr["refund_fees"] = "0.00";
  291. }
  292. }
  293. }
  294. writeGridDataTableJson(dStruct.TotalCount, dt);
  295. }
  296. public void get_erp_orderlist_sumprice()
  297. {
  298. returnSuccess(JsonConvert.SerializeObject(new { data = 0 }));
  299. return;
  300. List<string> lw = new List<string>();
  301. string tid = GetPostString("ctid");
  302. string date1 = GetPostString("date1");
  303. string date2 = GetPostString("date2");
  304. if (tid.Length > 0 || date1.Length > 0)
  305. {
  306. lw.Add(string.Format("ctid like '%{0}%'", tid));
  307. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  308. if (dw.Length > 0) lw.Add(dw);
  309. }
  310. else
  311. {
  312. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  313. }
  314. string shopname = GetPostString("shopname");
  315. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  316. string buyernick = GetPostString("buyer_nick");
  317. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  318. string customer = GetPostString("customer");
  319. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  320. string design = GetPostString("design");
  321. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  322. string orderState = GetPostString("orderState");
  323. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  324. string address = GetPostString("address");
  325. 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));
  326. string sellermemo = GetPostString("seller_memo");
  327. if (sellermemo.Length > 0)
  328. {
  329. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  330. }
  331. string apdate1 = GetPostString("apdate1");
  332. string apdate2 = GetPostString("apdate2");
  333. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  334. if (dwap.Length > 0) lw.Add(dwap);
  335. string price1 = GetPostString("price1");
  336. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  337. string price2 = GetPostString("price2");
  338. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  339. string isoldcustomer = GetPostString("isoldcus");
  340. if (isoldcustomer.Length > 0) lw.Add(string.Format("IsOldCustomer={0}", isoldcustomer));
  341. if (ex_psize == 0 && tid.Length <= 0 && buyernick.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  342. if (PKey != "admin")
  343. {
  344. string usershop = CurrentUser.User.pemShop == "" ? "''" : CurrentUser.User.pemShop;
  345. lw.Add(string.Format("shopId in ({0})", usershop));
  346. }
  347. //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";
  348. string mainWhere = string.Join(" and ", lw.ToArray());
  349. string sql = "select sum(payment) as sumpayment from view_erptradecell where " + mainWhere;
  350. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  351. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  352. decimal total = 0;
  353. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  354. {
  355. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  356. }
  357. var res = new
  358. {
  359. data = total
  360. };
  361. string ro_jsond = JsonConvert.SerializeObject(res);
  362. returnSuccess(ro_jsond);
  363. return;
  364. }
  365. public void get_erp_CustomerServiceGather()
  366. {
  367. string userWhere = "", orderWhere = "";
  368. List<string> lw = new List<string>();
  369. string customer = GetPostString("customer");
  370. if (customer.Length > 0) userWhere = string.Format(" where name like '%{0}%'", customer);
  371. string shopname = GetPostString("shopname");
  372. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  373. string date1 = GetPostString("date1");
  374. string date2 = GetPostString("date2");
  375. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  376. if (dw.Length > 0) lw.Add(dw);
  377. orderWhere = string.Join(" and ", lw.ToArray());
  378. 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 " +
  379. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  380. "left join " +
  381. "( " +
  382. " select CustomerUserId, sum(payment) as Amount, count(CustomerUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by CustomerUserId " +
  383. ") as b on a.ID = b.CustomerUserId " +
  384. "left join " +
  385. "( " +
  386. " select CustomerUserId, count(CustomerUserId) as WaitRelease from View_ErpTradeCell where OrderState = 1 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  387. ") as d on a.ID = d.CustomerUserId " +
  388. "left join " +
  389. "( " +
  390. " select CustomerUserId, count(CustomerUserId) as WaitRob from View_ErpTradeCell where OrderState = 2 " + (orderWhere == "" ? "" : "and ") + "{1} group by CustomerUserId " +
  391. ") as e on a.ID = e.CustomerUserId " +
  392. "left join " +
  393. "( " +
  394. " select CustomerUserId, RefundCount, RefundSum from " +
  395. " ( " +
  396. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  397. " from CE_ErpTradeRefund a " +
  398. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  399. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  400. " group by CustomerUserId " +
  401. " ) as a " +
  402. ") as f on a.ID = f.CustomerUserId " +
  403. "where a.PostCode = 'CustomerService'",
  404. userWhere, orderWhere);
  405. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  406. writeGridDataTableJson(dt.Rows.Count, dt);
  407. //writeGridDataTableJson(dt.Rows.Count, dt);
  408. }
  409. //设计汇总
  410. public void get_erp_DesignerGather()
  411. {
  412. string userWhere = "", orderWhere = "";
  413. List<string> lw = new List<string>();
  414. string Designer = GetPostString("designer");
  415. int org = GetPostInt("org");
  416. if (Designer.Length > 0)
  417. {
  418. userWhere = string.Format(" where Name like '%{0}%'", Designer);
  419. if (org > 0) userWhere = string.Format(" where Name like '%{0}%' and OrgID={1}", Designer, org);
  420. }
  421. else if (org > 0)
  422. {
  423. userWhere = string.Format(" where OrgID ={0}", org);
  424. }
  425. string shopname = GetPostString("shopname");
  426. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  427. string state = GetPostString("state");
  428. if (state.Length > 0) lw.Add(string.Format("status = {0}", state));
  429. string OrderArea = GetPostString("order_area");
  430. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  431. string date1 = GetPostString("date1");
  432. string date2 = GetPostString("date2");
  433. string dw = GetDateMinuteWhere("WaitDesignTime", date1, date2);
  434. if (dw.Length > 0) lw.Add(dw);
  435. string UpDate1 = GetPostString("UpDate1");
  436. string UpDate2 = GetPostString("UpDate2");
  437. dw = GetDateMinuteWhere("FinishDesignTime", UpDate1, UpDate2);
  438. if (dw.Length > 0) lw.Add(dw);
  439. orderWhere = string.Join(" and ", lw.ToArray());
  440. 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 (" +
  441. "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 " +
  442. "from(select ID, name, PostCode from view_ErpUser {0}) as a " +
  443. "left join " +
  444. "( " +
  445. " select DesignUserId, sum(payment) as Amount, count(DesignUserId) as AllOrder from View_ErpTradeCell " + (orderWhere == "" ? "" : "where ") + " {1} group by DesignUserId " +
  446. ") as b on a.ID = b.DesignUserId " +
  447. "left join " +
  448. "( " +
  449. " select DesignUserId, count(DesignUserId) as WaitDesign from View_ErpTradeCell where OrderState = 3 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  450. ") as d on a.ID = d.DesignUserId " +
  451. "left join " +
  452. "( " +
  453. " select DesignUserId, count(DesignUserId) as Designing from View_ErpTradeCell where OrderState = 4 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  454. ") as e on a.ID = e.DesignUserId " +
  455. "left join " +
  456. "( " +
  457. " select DesignUserId, count(DesignUserId) as DesignFinish from View_ErpTradeCell where OrderState > 5 " + (orderWhere == "" ? "" : "and ") + "{1} group by DesignUserId " +
  458. ") as g on a.ID = g.DesignUserId " +
  459. "left join " +
  460. "( " +
  461. " select CustomerUserId, RefundCount, RefundSum from " +
  462. " ( " +
  463. " select b.CustomerUserId, COUNT(a.tid) as RefundCount, SUM(cast(a.refund_fee as float)) as RefundSum " +
  464. " from CE_ErpTradeRefund a " +
  465. " inner join [view_ErpTradeCell] b on a.tid = b.tid " +
  466. " where b.status = 'TRADE_CLOSED' " + (orderWhere == "" ? "" : "and ") + "{1}" +
  467. " group by CustomerUserId " +
  468. " ) as a " +
  469. ") as f on a.ID = f.CustomerUserId " +
  470. "where a.PostCode = 'Designer') as z",
  471. userWhere, orderWhere);
  472. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  473. writeGridDataTableJson(dt.Rows.Count, dt);
  474. }
  475. //删除tradecell的订单
  476. public void del_erp_cellorder()
  477. {
  478. if (UrlPostParmsCheck("ctid"))
  479. {
  480. string eid = GetPostString("ctid");
  481. CeErpTradeCell.DelByCtid(eid);
  482. LogHelper.addLog(eid, CurrentUser.UserID, "订单删除", 0, 1);
  483. returnSuccessMsg("删除成功");
  484. }
  485. }
  486. public void clear_erp_refundstate()
  487. {
  488. if (UrlPostParmsCheck("ids"))
  489. {
  490. string eids = GetPostString("ids");
  491. string[] ctidList = eids.Split(',');
  492. foreach (string ctid in ctidList)
  493. {
  494. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  495. if (entity != null)
  496. {
  497. entity.IsRefund = 0;
  498. entity.Update();
  499. LogHelper.addLog(ctid, CurrentUser.UserID, "清除退款状态", 0, 1);
  500. }
  501. else
  502. continue;
  503. }
  504. returnSuccessMsg("操作成功");
  505. return;
  506. }
  507. returnErrorMsg("缺少必要参数");
  508. }
  509. public void set_erp_urgency()
  510. {
  511. if (UrlPostParmsCheck("ctid"))
  512. {
  513. string eid = GetPostString("ctid");
  514. CeErpTradeCell entity = null;
  515. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  516. if (entity != null)
  517. {
  518. string utime = GetPostString("urgencytime");
  519. if (utime.Length > 0)
  520. {
  521. entity.UrgencyTime = Convert.ToDateTime(utime);
  522. }
  523. else
  524. {
  525. returnErrorMsg("请选择加急时间");
  526. return;
  527. }
  528. if (entity.OrderState <= 4)
  529. {
  530. //entity.seller_memo = entity.seller_memo + "-加急";
  531. string smemo = entity.seller_memo;
  532. int kindex = smemo.IndexOf(")");
  533. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  534. if (lastoneStr != "-")
  535. {
  536. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  537. }
  538. string prememo = smemo.Substring(0, kindex + 2);
  539. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  540. int lastkindex = lastmemo.IndexOf("(");
  541. DateTime urgtime = Convert.ToDateTime(utime);
  542. string newlastmemo = "";
  543. if (lastkindex == 0)
  544. {
  545. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  546. newlastmemo = "(加急." + urgtime.Day + "号出货." + useLastmemo;
  547. }
  548. else
  549. {
  550. newlastmemo = "(加急." + urgtime.Day + "号出货)-" + lastmemo;
  551. }
  552. entity.seller_memo = prememo + newlastmemo;
  553. }
  554. entity.IsUrgency = true;
  555. entity.UpdateTime = DateTime.Now;
  556. entity.Update();
  557. ApiVo apiVo = new ApiVo();
  558. apiVo.orderNumber = entity.ctid;
  559. apiVo.actionName = "changeDesign";
  560. apiVo.orderRemarks = entity.seller_memo;
  561. apiVo.remarkSign = 3;
  562. designHelper.API_WorkCore(apiVo); //changeDesign
  563. CeErpSukuraData.createInfo(entity.ctid, 7);
  564. LogHelper.addLog(eid, CurrentUser.UserID, "手动订单加急", 0, 1);
  565. returnSuccessMsg("设置成功!");
  566. return;
  567. }
  568. returnErrorMsg("找不到记录");
  569. }
  570. }
  571. public void set_erp_reset()
  572. {
  573. if (UrlPostParmsCheck("ctid"))
  574. {
  575. string eid = GetPostString("ctid");
  576. CeErpTradeCell entity = null;
  577. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  578. if (entity != null)
  579. {
  580. if ((entity.OrderState >= 5 && entity.IsXianHuo == 0) || (entity.OrderState > 6 && entity.IsXianHuo == 1))
  581. {
  582. if (CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserID != 353)
  583. {
  584. returnErrorMsg("财务要求已下单已发货无法重置");
  585. return;
  586. }
  587. }
  588. entity.IsUrgency = false;
  589. entity.seller_memo = "";
  590. entity.OtherMemo = "";
  591. entity.OrderState = 0;
  592. entity.IsReturn = 0;
  593. //entity.IsRefund = 0;
  594. entity.MemoOpt = 0;
  595. entity.AfterSaleState = 0;
  596. entity.AfterSaleResponsible = "";
  597. entity.AfterSaleUserId = 0;
  598. entity.IsNeedBill = 0;
  599. entity.CustomerUserId = 0;
  600. entity.DesignUserId = 0;
  601. entity.SupplierId = 0;
  602. entity.PlaceUserId = 0;
  603. entity.ptid = "";
  604. entity.IsSample = 0;
  605. entity.IsXianHuo = 0;
  606. entity.isDianziOrder = 0;
  607. entity.DispatchSort = 0;
  608. entity.FinishPlaceTime = null;
  609. entity.Update();
  610. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  611. if (trade != null)
  612. {
  613. trade.seller_memo = "";
  614. trade.Update();
  615. }
  616. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "订单重置", entity.OrderState, 1);
  617. returnSuccessMsg("重置成功!");
  618. CeErpDesignerBill desginBill = CeErpDesignerBill.GetByTid(entity.tid);
  619. if (desginBill != null)
  620. {
  621. desginBill.isDel = 1;
  622. desginBill.Update();
  623. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "订单重置", CurrentUser.UserName, 0);
  624. }
  625. ApiVo apiVo = new ApiVo();
  626. apiVo.orderNumber = entity.ctid;
  627. apiVo.actionName = "resetDesign";
  628. designHelper.API_WorkCore(apiVo);//resetDesign
  629. return;
  630. }
  631. returnErrorMsg("找不到记录");
  632. }
  633. }
  634. public void save_erp_sellermemo()
  635. {
  636. if (UrlPostParmsCheck("ctid"))
  637. {
  638. string ctid = GetPostString("ctid");
  639. CeErpTradeCell entity = null;
  640. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  641. if (entity != null)
  642. {
  643. string memo = GetPostString("seller_memo");
  644. memo = memo.Replace(" ", "");
  645. if (memo.Contains("补差"))
  646. {
  647. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  648. return;
  649. }
  650. if (entity.seller_memo != memo)
  651. {
  652. if (entity.IsSample == 2)
  653. {
  654. returnErrorMsg("补差价单不能修改备注,它只能是补差价单,别乱改");
  655. return;
  656. }
  657. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  658. {
  659. if (entity.OrderState >= 5 && entity.seller_memo.IndexOf("礼物") == -1 && entity.seller_memo.IndexOf("现货") == -1 && entity.IsXianHuo == 0 && entity.IsOffLineOrder == 0)
  660. {
  661. returnErrorMsg("无法修改备注,设计稿已使用原备注,修改后下载文件会无法对应");
  662. return;
  663. }
  664. }
  665. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统修改为:" + memo, entity.OrderState, 1);
  666. }
  667. commonHelper.getCytPrice(entity);
  668. int memoopt = GetPostInt("MemoOpt");
  669. Boolean ismemoopt = false;
  670. if (memoopt > 0)
  671. {
  672. string stropt = "";
  673. if (memoopt == 1)
  674. {
  675. stropt = "“改稿”";
  676. ismemoopt = true;
  677. }
  678. else if (memoopt == 2)
  679. {
  680. stropt = "“定稿”";
  681. }
  682. else if (memoopt == 3)
  683. {
  684. stropt = "“查货”";
  685. CeErpSukuraData.createInfo(entity.ctid, 6);
  686. }
  687. entity.MemoOpt = Convert.ToInt32(memoopt);
  688. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "系统标记:" + stropt, entity.OrderState, 1);
  689. }
  690. if (entity.OrderState < 5)
  691. {
  692. memo = memo.Replace("(", "(");
  693. memo = memo.Replace(")", ")");
  694. }
  695. entity.seller_memo = memo;
  696. entity.UpdateTime = DateTime.Now;
  697. entity.Update();
  698. ApiVo apiVo = new ApiVo();
  699. apiVo.orderNumber = entity.ctid;
  700. apiVo.actionName = memoopt > 0 ? "changeDesign" : "orderRemarks";
  701. apiVo.orderRemarks = memo;
  702. apiVo.remarkSign = memoopt;
  703. designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
  704. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, memo, ismemoopt, false);
  705. returnSuccessMsg("保存成功!");
  706. return;
  707. }
  708. returnErrorMsg("找不到记录");
  709. }
  710. }
  711. public void ins_erp_checkorder()
  712. {
  713. if (UrlPostParmsCheck("ctid"))
  714. {
  715. string ctid = GetPostString("ctid");
  716. CeErpTradeCell entity = null;
  717. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  718. if (entity != null)
  719. {
  720. if (entity.OrderState < 6)
  721. {
  722. returnErrorMsg("下单完成后才可查货");
  723. return;
  724. }
  725. /*if (entity.OrderState > 6)
  726. {
  727. returnErrorMsg("订单已发货");
  728. return;
  729. }*/
  730. if (entity.FinishPlaceTime != null)
  731. {
  732. if (DateTime.Now.AddHours(-5) < entity.FinishPlaceTime)
  733. {
  734. returnErrorMsg("下单时间不足,无法查货");
  735. return;
  736. }
  737. }
  738. entity.MemoOpt = 3;
  739. entity.CheckOrderTime = DateTime.Now;
  740. entity.UpdateTime = DateTime.Now;
  741. entity.Update();
  742. CeErpSukuraData.createInfo(entity.ctid, 6);
  743. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记:查货", entity.OrderState, 1);
  744. returnSuccessMsg("操作成功!");
  745. return;
  746. }
  747. returnErrorMsg("找不到记录");
  748. }
  749. }
  750. public void save_erp_othermemo()
  751. {
  752. if (UrlPostParmsCheck("ctid"))
  753. {
  754. string ctid = GetPostString("ctid");
  755. CeErpTradeCell entity = null;
  756. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  757. if (entity != null)
  758. {
  759. entity.OtherMemo = GetPostString("otherMemo");
  760. if (entity.OtherMemo.Contains("寄样客户") && entity.OrderState < 6)
  761. {
  762. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  763. StringBuilder sql = new StringBuilder();
  764. sql.AppendFormat("select * from view_ErpTradeCell where buyer_nick = '{0}' and IsSample=3;", ceErpTrade.buyer_nick);
  765. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  766. if (dt != null && dt.Rows.Count > 0)
  767. {
  768. foreach (DataRow dr in dt.Rows)
  769. {
  770. if (entity.ProductId > 0 && Convert.ToInt32(dr["ProductId"]) > 0 && entity.ProductId == Convert.ToInt32(dr["ProductId"]))
  771. {
  772. //品类一直
  773. entity.SupplierId = Convert.ToInt32(dr["SupplierId"]);
  774. CeErpSampleCustomer ceErpSampleCustomer = CeErpSampleCustomer.GetByNick(ceErpTrade.buyer_nick);
  775. if (ceErpSampleCustomer == null)
  776. {
  777. ceErpSampleCustomer = new CeErpSampleCustomer();
  778. ceErpSampleCustomer.buyer_nick = ceErpTrade.buyer_nick;
  779. ceErpSampleCustomer.phone = dr["receiver_mobile"].ToString();
  780. ceErpSampleCustomer.address = dr["receiver_state"].ToString() + dr["receiver_city"].ToString() + dr["receiver_town"].ToString() + dr["receiver_district"].ToString();
  781. ceErpSampleCustomer.seller_nick = dr["seller_nick"].ToString();
  782. ceErpSampleCustomer.shopId = entity.ShopId;
  783. }
  784. ceErpSampleCustomer.lastbuy_time = entity.pay_time;
  785. ceErpSampleCustomer.lastTid = entity.tid;
  786. if (ceErpSampleCustomer.ID > 0)
  787. {
  788. ceErpSampleCustomer.Update();
  789. }
  790. else
  791. {
  792. ceErpSampleCustomer.Create();
  793. }
  794. }
  795. }
  796. }
  797. }
  798. //if (entity.IsOldCustomer == 1)
  799. //{
  800. //if(entity.ShopId == Convert.ToInt32(webConfig.HhOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZsOrgId) || entity.ShopId == Convert.ToInt32(webConfig.ZfOrgId))
  801. //{
  802. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  803. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:林晨", entity.OrderState);
  804. //}
  805. //if (CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.OrgId) || CurrentUser.UserPost.OrgID == Convert.ToInt32(webConfig.PlaceOrgId))
  806. //{
  807. // if(entity.DesignUserId == Convert.ToInt32(webConfig.PlaceOldCusId))
  808. // {
  809. // if (entity.OtherMemo.IndexOf("改稿") > -1)
  810. // {
  811. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceChangeId);
  812. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户改稿自动指派:林永康", entity.OrderState);
  813. // }
  814. // else if (entity.OtherMemo.IndexOf("重新设计") > -1)
  815. // {
  816. // entity.OrderState = 2;
  817. // entity.DesignUserId = 0;
  818. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户重新设计状态切换为待抢单", entity.OrderState);
  819. // }
  820. // else
  821. // {
  822. // entity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); ;
  823. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "老客户自动指派:下单员", entity.OrderState);
  824. // }
  825. // }
  826. //}
  827. //}
  828. entity.Update();
  829. returnSuccessMsg("保存成功!");
  830. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "额外:" + entity.OtherMemo, entity.OrderState);
  831. return;
  832. }
  833. returnErrorMsg("找不到记录");
  834. }
  835. }
  836. public void save_erp_customermemo()
  837. {
  838. if (UrlPostParmsCheck("ctid"))
  839. {
  840. string ctid = GetPostString("ctid");
  841. CeErpTradeCell entity = null;
  842. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  843. if (entity != null)
  844. {
  845. entity.CustomerMemo = GetPostString("CustomerMemo");
  846. entity.Update();
  847. ApiVo apiVo = new ApiVo();
  848. apiVo.orderNumber = entity.ctid;
  849. apiVo.actionName = "followRemarks";
  850. apiVo.orderRemarks = entity.CustomerMemo;
  851. designHelper.API_WorkCore(apiVo);//followRemarks
  852. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "跟单备注:" + entity.CustomerMemo, entity.OrderState);
  853. returnSuccessMsg("保存成功!");
  854. return;
  855. }
  856. returnErrorMsg("找不到记录");
  857. }
  858. }
  859. public void upd_erp_addmemotag()
  860. {
  861. if (UrlPostParmsCheck("ctid"))
  862. {
  863. ;
  864. string eid = GetPostString("ctid");
  865. string sfTagstr = GetPostString("memotag");
  866. CeErpTradeCell entity = null;
  867. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  868. if (entity != null)
  869. {
  870. if (entity.OrderState == 0)
  871. {
  872. returnErrorMsg("请先领单");
  873. return;
  874. }
  875. //撤销顺丰
  876. if (sfTagstr == "撤销顺丰")
  877. {
  878. entity.IsSF = 0;
  879. string reMsg = "";
  880. string oldmemo = entity.seller_memo;
  881. if (entity.OrderState < 5)
  882. {
  883. oldmemo = oldmemo.Replace("顺丰到付", "");
  884. oldmemo = oldmemo.Replace("顺丰寄付", "");
  885. entity.seller_memo = oldmemo;
  886. }
  887. else
  888. {
  889. if (oldmemo.IndexOf("顺丰到付") != -1 || oldmemo.IndexOf("顺丰寄付") != -1)
  890. {
  891. reMsg = "(设计文件已上传,所以备注中的顺丰字眼还保留,不然文件名跟备注对不上)";
  892. }
  893. }
  894. entity.Update();
  895. work_core_vo.ApiVo api = new work_core_vo.ApiVo();
  896. api.orderNumber = entity.ctid;
  897. api.actionName = "followRemarks";
  898. api.orderRemarks = entity.seller_memo;
  899. api.isSf = entity.IsSF.ToString();
  900. designHelper.API_WorkCore(api);//followRemarks
  901. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
  902. returnSuccessMsg("撤销成功!" + reMsg);
  903. return;
  904. }
  905. if (entity.OrderState < 5 || entity.IsXianHuo == 1)
  906. {
  907. //string oldmemo = entity.seller_memo;
  908. //entity.seller_memo = oldmemo + "-" + GetPostString("memotag");
  909. string sfStr = GetPostString("memotag");
  910. string smemo = entity.seller_memo;
  911. int kindex = smemo.IndexOf(")");
  912. string lastoneStr = smemo.Substring(kindex + 1, 1);//查看订单号后面有没有一个- ,没有就要补上-
  913. if (lastoneStr != "-")
  914. {
  915. smemo = smemo.Substring(0, kindex + 1) + "-" + smemo.Substring(kindex + 1, smemo.Length - kindex - 1);
  916. }
  917. string prememo = smemo.Substring(0, kindex + 2);
  918. string lastmemo = smemo.Substring(kindex + 2, smemo.Length - kindex - 2);
  919. int lastkindex = lastmemo.IndexOf("(");
  920. string newlastmemo = "";
  921. if (lastkindex == 0)
  922. {
  923. string useLastmemo = lastmemo.Substring(1, lastmemo.Length - 1);
  924. newlastmemo = "(" + sfStr + "." + useLastmemo;
  925. }
  926. else
  927. {
  928. newlastmemo = "(" + sfStr + ")-" + lastmemo;
  929. }
  930. entity.seller_memo = prememo + newlastmemo;
  931. }
  932. string sfTagMSg = "";
  933. if (sfTagstr == "顺丰寄付")
  934. {
  935. entity.IsSF = 1;
  936. sfTagMSg = "顺丰寄付";
  937. }
  938. else if (sfTagstr == "顺丰到付")
  939. {
  940. entity.IsSF = 2;
  941. sfTagMSg = "顺丰到付";
  942. }
  943. entity.Update();
  944. ApiVo apiVo = new ApiVo();
  945. apiVo.orderNumber = entity.ctid;
  946. apiVo.actionName = "orderRemarks";
  947. apiVo.orderRemarks = entity.seller_memo;
  948. apiVo.isSf = entity.IsSF.ToString();
  949. designHelper.API_WorkCore(apiVo);//orderRemarks
  950. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "右键标记:" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
  951. returnSuccessMsg("标记成功!");
  952. return;
  953. }
  954. returnErrorMsg("找不到记录");
  955. }
  956. }
  957. public void upd_erp_ordertag()
  958. {
  959. if (UrlPostParmsCheck("ctid"))
  960. {
  961. string eid = GetPostString("ctid");
  962. CeErpTradeCell entity = null;
  963. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  964. if (entity != null)
  965. {
  966. int tag = GetPostInt("wechattag");
  967. //if(tag==4 && entity.IsSample == 2)
  968. //{
  969. // returnErrorMsg("补差价单不能标记微信单");
  970. // return;
  971. //}
  972. entity.wechatTag = tag;
  973. entity.Update();
  974. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  975. if (tag == 1)
  976. {
  977. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  978. if (cash == null)
  979. {
  980. CeErpTrade main = CeErpTrade.Get(entity.tid);
  981. cash = new CeErpReturnCash();
  982. cash.tid = entity.tid;
  983. cash.seller_nick = main.seller_nick;
  984. cash.payment = trade.payment;
  985. cash.buyer_nick = main.buyer_nick;
  986. cash.cashstate = 0;
  987. cash.rtype = "微信返现";
  988. cash.returnprice = 0;
  989. cash.created = DateTime.Now;
  990. cash.con = "订单标记微信单";
  991. cash.img = "";
  992. cash.applyuserid = CurrentUser.UserID;
  993. cash.Create();
  994. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:微信返现");
  995. }
  996. else
  997. {
  998. cash.cashstate = 0;
  999. cash.Update();
  1000. }
  1001. CeErpSukuraData.createInfo(entity.ctid, 9);
  1002. }
  1003. else if (tag == 2)
  1004. {
  1005. CeErpReturnCash cash = CeErpReturnCash.GetByTid(entity.tid);
  1006. if (cash == null)
  1007. {
  1008. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1009. cash = new CeErpReturnCash();
  1010. cash.tid = entity.tid;
  1011. cash.seller_nick = main.seller_nick;
  1012. cash.payment = trade.payment;
  1013. cash.buyer_nick = main.buyer_nick;
  1014. cash.cashstate = 0;
  1015. cash.rtype = "推购返现";
  1016. cash.returnprice = 5;
  1017. cash.created = DateTime.Now;
  1018. cash.con = "订单标记推购单";
  1019. cash.img = "";
  1020. cash.applyuserid = CurrentUser.UserID;
  1021. cash.Create();
  1022. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推购返现");
  1023. }
  1024. else
  1025. {
  1026. cash.cashstate = 0;
  1027. cash.Update();
  1028. }
  1029. CeErpSukuraData.createInfo(entity.ctid, 9);
  1030. }
  1031. else if (tag == 3)
  1032. {
  1033. CeErpPersuade pers = CeErpPersuade.GetByCtid(entity.ctid);
  1034. if (pers == null)
  1035. {
  1036. pers = new CeErpPersuade();
  1037. pers.ctid = entity.ctid;
  1038. pers.pstate = 0;
  1039. pers.created = DateTime.Now;
  1040. pers.applyuserid = CurrentUser.UserID;
  1041. pers.Create();
  1042. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:挽回推多");
  1043. }
  1044. else
  1045. {
  1046. pers.pstate = 0;
  1047. pers.Update();
  1048. }
  1049. }
  1050. else if (tag == 4 || tag == 5)
  1051. {
  1052. CeErpTrade main = CeErpTrade.Get(entity.tid);
  1053. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1054. if (pers == null)
  1055. {
  1056. pers = new CeErpStayGoods();
  1057. pers.t_id = entity.tid;
  1058. pers.status = "待审核";
  1059. pers.audit_type = 0;
  1060. if (tag == 4)
  1061. {
  1062. pers.stay_type = "微信推购";
  1063. }
  1064. else
  1065. {
  1066. pers.stay_type = "旺旺推购";
  1067. }
  1068. if (entity.IsXianHuo == 0)
  1069. {
  1070. pers.product_id = entity.ProductId;
  1071. }
  1072. pers.wangwang = main.buyer_nick;
  1073. pers.shop_name = main.seller_nick;
  1074. pers.creata_time = DateTime.Now;
  1075. pers.create_u_id = CurrentUser.UserID;
  1076. pers.create_u_name = CurrentUser.UserName;
  1077. pers.Create();
  1078. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "添加:推多推购");
  1079. }
  1080. else
  1081. {
  1082. pers.audit_type = 0;
  1083. pers.Update();
  1084. }
  1085. CeErpSukuraData.createInfo(entity.ctid, 10);
  1086. }
  1087. //LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记微信或者推购", entity.OrderState, 1);
  1088. returnSuccessMsg("标记成功!");
  1089. return;
  1090. }
  1091. returnErrorMsg("找不到记录");
  1092. }
  1093. }
  1094. public void upd_erp_ordertag_cancel()
  1095. {
  1096. if (UrlPostParmsCheck("ctid"))
  1097. {
  1098. string eid = GetPostString("ctid");
  1099. CeErpTradeCell entity = null;
  1100. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1101. if (entity != null)
  1102. {
  1103. entity.wechatTag = 0;
  1104. entity.Update();
  1105. CeErpStayGoods pers = CeErpStayGoods.GetByTid(entity.tid);
  1106. if (pers != null)
  1107. {
  1108. pers.status = "取消推购";
  1109. pers.audit_type = 3;
  1110. pers.Update();
  1111. }
  1112. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消:推多推购");
  1113. returnSuccessMsg("标记成功!");
  1114. return;
  1115. }
  1116. returnErrorMsg("找不到记录");
  1117. }
  1118. }
  1119. public void upd_erp_addweichattag()
  1120. {
  1121. if (UrlPostParmsCheck("ctid"))
  1122. {
  1123. ;
  1124. string eid = GetPostString("ctid");
  1125. CeErpTradeCell entity = null;
  1126. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1127. if (entity != null)
  1128. {
  1129. if (entity.IsAddWechat > 0)
  1130. {
  1131. returnErrorMsg("此单已经标记过了");
  1132. return;
  1133. }
  1134. 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);
  1135. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  1136. if (dt.Rows.Count > 0)
  1137. {
  1138. entity.IsAddWechat = 2;
  1139. }
  1140. else
  1141. {
  1142. entity.IsAddWechat = 1;
  1143. }
  1144. entity.Update();
  1145. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记已添加微信", entity.OrderState, 1);
  1146. returnSuccessMsg("标记成功!");
  1147. return;
  1148. }
  1149. returnErrorMsg("找不到记录");
  1150. }
  1151. }
  1152. public void upd_erp_getmyorder()
  1153. {
  1154. if (UrlPostParmsCheck("ctid"))
  1155. {
  1156. ;
  1157. string eid = GetPostString("ctid");
  1158. CeErpTradeCell entity = null;
  1159. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1160. if (entity != null)
  1161. {
  1162. if (entity.ctid.IndexOf("C") != -1)
  1163. {
  1164. StringBuilder sql = new StringBuilder();
  1165. sql.AppendFormat("select * from view_ErpTradeCell where tid='{0}';", entity.tid);
  1166. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1167. if (dt.Rows.Count > 0)
  1168. {
  1169. decimal total = 0;
  1170. foreach (DataRow dr in dt.Rows)
  1171. {
  1172. total += Convert.ToDecimal(dr["payment"]);
  1173. }
  1174. decimal main_payment = Convert.ToDecimal(dt.Rows[0]["main_payment"]);
  1175. if (Math.Abs(main_payment - total) > Convert.ToDecimal(0.01))
  1176. {
  1177. returnErrorMsg("拆分金额跟原单金额不一致,无法领单!");
  1178. return;
  1179. }
  1180. }
  1181. }
  1182. entity.CustomerUserId = CurrentUser.UserID;
  1183. if (entity.OrderState < 2)
  1184. {
  1185. entity.OrderState = 2;
  1186. if (entity.ShopId != 0)
  1187. {
  1188. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1189. }
  1190. }
  1191. entity.UpdateTime = DateTime.Now;
  1192. entity.Update();
  1193. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动领单", entity.OrderState, 1);
  1194. returnSuccessMsg("领单成功!");
  1195. return;
  1196. }
  1197. returnErrorMsg("找不到记录");
  1198. }
  1199. }
  1200. public void getmyorder_from_init()
  1201. {
  1202. if (UrlPostParmsCheck("ctid"))
  1203. {
  1204. string eid = GetPostString("ctid");
  1205. CeErpTradeCell entity = null;
  1206. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1207. if (entity != null)
  1208. {
  1209. string sellerMemo = GetPostString("sellerMemo");
  1210. if (sellerMemo.Length > 0)
  1211. {
  1212. entity.seller_memo = sellerMemo;
  1213. }
  1214. string oterhMemo = GetPostString("otherMemo");
  1215. if (oterhMemo.Length > 0)
  1216. {
  1217. entity.OtherMemo = oterhMemo;
  1218. }
  1219. int urg = GetPostInt("urgency");
  1220. entity.IsUrgency = (urg == 1 ? true : false);
  1221. int wechat = GetPostInt("wechat");
  1222. int command = GetPostInt("command");
  1223. if (wechat == 1)
  1224. {
  1225. entity.wechatTag = 1;
  1226. }
  1227. if (command == 1)
  1228. {
  1229. entity.wechatTag = 2;
  1230. }
  1231. string pPro = GetPostString("pprofession");
  1232. if (pPro.Length > 0)
  1233. {
  1234. entity.ParentProfessionId = Convert.ToInt32(pPro);
  1235. string spro = GetPostString("profession");
  1236. if (spro.Length > 0)
  1237. {
  1238. entity.ProfessionId = Convert.ToInt32(spro);
  1239. }
  1240. }
  1241. string proId = GetPostString("productId");
  1242. if (proId.Length > 0)
  1243. {
  1244. entity.ProductId = Convert.ToInt32(proId);
  1245. }
  1246. entity.Material = GetPostString("material");
  1247. entity.Craft = GetPostString("craft");
  1248. entity.CustomerUserId = CurrentUser.UserID;
  1249. if (entity.OrderState < 2)
  1250. {
  1251. entity.OrderState = 2;
  1252. if (entity.ShopId != 0)
  1253. {
  1254. entity.OrderState = tmcHelper.orderAudit(entity.ShopId);
  1255. }
  1256. }
  1257. entity.Update();
  1258. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "选择型手动领单", entity.OrderState, 1);
  1259. returnSuccessMsg("领单成功!");
  1260. return;
  1261. }
  1262. returnErrorMsg("找不到记录");
  1263. }
  1264. }
  1265. public void upd_erp_setrelationorder()
  1266. {
  1267. if (UrlPostParmsCheck("ctid"))
  1268. {
  1269. ;
  1270. string eid = GetPostString("ctid");
  1271. string ftid = GetPostString("ftid");
  1272. CeErpTradeCell entity = null;
  1273. CeErpTradeCell fentity = null;
  1274. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1275. if (ftid != "") fentity = CeErpTradeCell.GetByCtid(ftid);
  1276. if (fentity == null)
  1277. {
  1278. returnErrorMsg("找不到关联的主订单");
  1279. return;
  1280. }
  1281. if (entity != null)
  1282. {
  1283. if (entity.OrderState >= 5)
  1284. {
  1285. returnErrorMsg("本单已经设计完成无法关联");
  1286. return;
  1287. }
  1288. if ((eid.Contains("N_") || ftid.Contains("N_")) && (fentity.OrderState == -1 || entity.OrderState == -1))
  1289. {
  1290. returnErrorMsg("线下单续审核后才能关联!");
  1291. return;
  1292. }
  1293. entity.ptid = ftid;
  1294. entity.OrderState = fentity.OrderState;
  1295. //entity.status = fentity.status;
  1296. entity.CustomerUserId = fentity.CustomerUserId;
  1297. entity.DesignUserId = fentity.DesignUserId;
  1298. entity.seller_memo = "补差价单:" + ftid;
  1299. entity.IsSample = 2;
  1300. entity.Update();
  1301. ApiVo apiVo = new ApiVo();
  1302. apiVo.orderNumber = ftid;
  1303. apiVo.payment = entity.payment;
  1304. apiVo.actionName = "repairDesign";
  1305. designHelper.API_WorkCore(apiVo);//repairDesign
  1306. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "手动关联补差价", entity.OrderState, 1);
  1307. returnSuccessMsg("关联成功!");
  1308. return;
  1309. }
  1310. else
  1311. returnErrorMsg("找不到记录");
  1312. }
  1313. }
  1314. public void download_erp_neworder()
  1315. {
  1316. string seller = GetPostString("seller_nick");
  1317. string tid = GetPostString("tid");
  1318. if (seller.Length <= 0 || tid.Length <= 0)
  1319. {
  1320. returnErrorMsg("数据错误");
  1321. }
  1322. //if (taobaoHelper.ShopKeyDics.ContainsKey(seller) == false)
  1323. //{
  1324. // returnErrorMsg("找不到店铺Sessionkey");
  1325. //}
  1326. //string sessionkey = taobaoHelper.ShopKeyDics[seller];
  1327. //string res = taobaoHelper.TradeFullinfoGet(sessionkey, tid);
  1328. string res = apiHelper.API_TradeFullinfoGet(tid, "", "");
  1329. if (res.IndexOf("refOid") == -1)
  1330. {
  1331. returnErrorMsg("下载订单数据失败");
  1332. return;
  1333. }
  1334. tmcHelper.Api_Tmc_CreateNewOrder(res);
  1335. returnSuccessMsg("下载完成");
  1336. //tmcHelper.createNewOrder(res);
  1337. //CeErpTrade entr = null;
  1338. //entr = CeErpTrade.Get(tid);
  1339. //if (entr != null)
  1340. //{
  1341. // returnSuccess("下载成功");
  1342. // //下载成功之后,Cell表生成对应的订单;
  1343. // tmcHelper.createCellOrder(entr,entr.tid,entr.seller_memo,entr.buyer_nick,true);//最后加上true跳过阻止直接拆分创建cell子单
  1344. //}
  1345. //else
  1346. //{
  1347. // returnErrorMsg("下载失败或者创建订单失败");
  1348. //}
  1349. }
  1350. public void set_erp_atersale()
  1351. {
  1352. if (UrlPostParmsCheck("ctid"))
  1353. {
  1354. string eid = GetPostString("ctid");
  1355. string reason = GetPostString("AfterSaleReason");
  1356. CeErpTradeCell entity = null;
  1357. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1358. if (entity != null)
  1359. {
  1360. if (CurrentUser.UserPost.Post.Code != "AfterSale" && CurrentUser.UserPost.Post.Code != "SysAdmin" && entity.AfterSaleState > 0 && CurrentUser.UserPost.Post.Code != "AfterSaleMaster")
  1361. {
  1362. returnErrorMsg("此订单已经在售后");
  1363. return;
  1364. }
  1365. entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
  1366. entity.UpdateTime = DateTime.Now; //entity.AfterSaleReason = reason;
  1367. entity.AfterSaleTime = DateTime.Now;
  1368. entity.Update();
  1369. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
  1370. returnSuccessMsg("转售后成功!");
  1371. return;
  1372. }
  1373. returnErrorMsg("找不到记录");
  1374. }
  1375. }
  1376. public void set_erp_withdraw()
  1377. {
  1378. if (UrlPostParmsCheck("ctid"))
  1379. {
  1380. try
  1381. {
  1382. string eid = GetPostString("ctid");//商品id
  1383. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(eid);
  1384. CeWithdraw ceWithdrawSelect = null;
  1385. ceWithdrawSelect = CeWithdraw.GetByTid(eid);
  1386. if (ceWithdrawSelect != null)
  1387. {
  1388. if (ceWithdrawSelect.status == 2 && ceWithdrawSelect.providerid.Equals("-1"))
  1389. {
  1390. ceWithdrawSelect.status = -1;
  1391. ceWithdrawSelect.Update();
  1392. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "重新发起审核成功,待车间确认", ceErpTradeCell.OrderState);
  1393. returnSuccessMsg("重新发起审核成功");
  1394. return;
  1395. }
  1396. else
  1397. {
  1398. returnSuccessMsg("请勿重复申请!");
  1399. return;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. string CustomerUserId = GetPostString("CustomerUserId");//供应商id
  1405. if (string.IsNullOrEmpty(CustomerUserId))
  1406. {
  1407. CustomerUserId = "-1";
  1408. }
  1409. int Userid = CurrentUser.UserID;//用户id
  1410. CeWithdraw ceWithdraw = new CeWithdraw();
  1411. ceWithdraw.tid = eid;
  1412. ceWithdraw.userid = Userid;
  1413. ceWithdraw.providerid = CustomerUserId;
  1414. ceWithdraw.status = 3;
  1415. ceWithdraw.creationtime = DateTime.Now;
  1416. ceWithdraw.Create();
  1417. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "申请撤回订单成功,待车间确认", ceErpTradeCell.OrderState);
  1418. returnSuccessMsg("申请撤回订单成功,待车间确认");
  1419. return;
  1420. }
  1421. }
  1422. catch
  1423. {
  1424. returnErrorMsg("申请撤回订单失败");
  1425. return;
  1426. }
  1427. }
  1428. }
  1429. public void ins_erp_billinfo()
  1430. {
  1431. if (UrlPostParmsCheck("ctid"))
  1432. {
  1433. string eid = GetPostString("ctid");
  1434. CeErpTradeCell entity = null;
  1435. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1436. if (entity != null)
  1437. {
  1438. CeErpBill bill = CeErpBill.GetByTid(eid);
  1439. bool isHave = false;
  1440. if (bill != null)
  1441. {
  1442. isHave = true;
  1443. if (bill.state != 4)
  1444. {
  1445. returnErrorMsg("此单已经申请过发票了");
  1446. return;
  1447. }
  1448. }
  1449. if (entity.IsNeedBill == 0)
  1450. {
  1451. entity.IsNeedBill = 1;
  1452. }
  1453. entity.Update();
  1454. string errjson = "";
  1455. try
  1456. {
  1457. CeErpBill bill_entity = new CeErpBill();
  1458. bill_entity.tid = entity.tid;
  1459. bill_entity.title = GetPostString("title");
  1460. string taxstr = GetPostString("tax");
  1461. taxstr = taxstr.Replace(" ", "");
  1462. bill_entity.tax = taxstr;
  1463. bill_entity.bank = GetPostString("bank");
  1464. string bankacstr = GetPostString("bankac");
  1465. bankacstr = bankacstr.Replace(" ", "");
  1466. bill_entity.bankac = bankacstr;
  1467. bill_entity.address = GetPostString("address");
  1468. bill_entity.phone = GetPostString("phone");
  1469. bill_entity.price = GetPostString("price");
  1470. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / 1000.00);
  1471. if (Convert.ToDouble(bill_entity.price) % 1000.00 > 0.00001)
  1472. {
  1473. billCount += 1;
  1474. }
  1475. string prebill = "ltb";
  1476. for (int idx = 1; idx <= billCount; idx++)
  1477. {
  1478. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  1479. string billoid = prebill + idx + dtstr;
  1480. bill_entity.billOrderId += billoid;
  1481. if (idx < billCount)
  1482. {
  1483. bill_entity.billOrderId += ",";
  1484. }
  1485. }
  1486. bill_entity.productId = GetPostInt("ProductName");
  1487. bill_entity.num = GetPostInt("num");
  1488. bill_entity.unit = GetPostString("unit");
  1489. bill_entity.type = GetPostString("type");
  1490. bill_entity.sendType = GetPostString("SendType");
  1491. bill_entity.email = GetPostString("email");
  1492. bill_entity.buyer_nick = GetPostString("buyer_nick");
  1493. bill_entity.shopName = GetPostString("ShopName");
  1494. bill_entity.applymemo = GetPostString("applyMemo");
  1495. bill_entity.createTime = DateTime.Now;
  1496. bill_entity.state = 0;
  1497. bill_entity.userId = CurrentUser.UserID;
  1498. errjson = Utils.Serialization.JsonString.ConvertObject(bill_entity);
  1499. bill_entity.Create();
  1500. }
  1501. catch (Exception ex)
  1502. {
  1503. XLog.SaveLog(0, errjson + "创建发票出错," + ex.Message);
  1504. returnErrorMsg("创建发票出错!");
  1505. return;
  1506. }
  1507. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "申请发票", entity.OrderState, 1);
  1508. returnSuccessMsg("发票申请成功!");
  1509. return;
  1510. }
  1511. returnErrorMsg("找不到记录");
  1512. }
  1513. }
  1514. public void ins_erp_neworder()
  1515. {
  1516. if (UrlPostParmsCheck("receiver_name"))
  1517. {
  1518. CeErpTrade entity = new CeErpTrade();
  1519. string plat_form = GetPostString("platform");
  1520. string preStr = "N_";
  1521. if (plat_form == "拼多多")
  1522. {
  1523. preStr = "P_";
  1524. }
  1525. else if (plat_form == "阿里巴巴")
  1526. {
  1527. preStr = "A_";
  1528. }
  1529. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1530. entity.seller_nick = GetPostString("seller_nick");
  1531. entity.buyer_nick = GetPostString("buyer_nick");
  1532. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1533. entity.total_fee = entity.payment;
  1534. entity.pay_time = DateTime.Now;
  1535. entity.status = "NOT_SHIPPED";
  1536. entity.receiver_name = GetPostString("receiver_name");
  1537. entity.receiver_mobile = GetPostString("receiver_mobile");
  1538. entity.receiver_state = GetPostString("receiver_state");
  1539. entity.receiver_city = GetPostString("receiver_city");
  1540. entity.receiver_district = GetPostString("receiver_district");
  1541. entity.receiver_address = GetPostString("receiver_address");
  1542. if (entity.receiver_state == "" || entity.receiver_city == "")
  1543. {
  1544. returnErrorMsg("收件地址不能为空");
  1545. return;
  1546. }
  1547. int shopId = 0;
  1548. CeErpShop nShop = CeErpShop.GetShopIdByName(entity.seller_nick);
  1549. if (nShop != null)
  1550. {
  1551. shopId = nShop.ID;
  1552. }
  1553. if (shopId != 34 && entity.payment == 0)
  1554. {
  1555. returnErrorMsg("公司自用的单金额才能为0");
  1556. return;
  1557. }
  1558. entity.Create();
  1559. CeErpTradeCell entitycell = new CeErpTradeCell();
  1560. entitycell.ctid = entity.tid;
  1561. entitycell.tid = entity.tid;
  1562. entitycell.ShopId = shopId;
  1563. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1564. entitycell.OrderState = 0;
  1565. entitycell.pay_time = entity.pay_time;
  1566. entitycell.IsOffLineOrder = 1;
  1567. entitycell.Create();
  1568. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1569. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增订单", 0, 0);
  1570. return;
  1571. }
  1572. }
  1573. public void ins_erp_neworder2()
  1574. {
  1575. if (UrlPostParmsCheck("receiver_name"))
  1576. {
  1577. //string plat_form = GetPostString("platform");
  1578. string preStr = "X_";
  1579. string memo = GetPostString("memo");
  1580. string productId = GetPostString("productId");
  1581. string primg = GetPostString("proofimg");
  1582. string sellerNick = GetPostString("seller_nick");
  1583. string addFrom = GetPostString("addfrom");
  1584. if (addFrom == "1")
  1585. {
  1586. preStr = "N_";
  1587. }
  1588. int shopId = 0;
  1589. CeErpShop nShop = CeErpShop.GetShopIdByName(sellerNick);
  1590. if (nShop != null)
  1591. {
  1592. shopId = nShop.ID;
  1593. }
  1594. else
  1595. {
  1596. returnErrorMsg("找不到对应店铺");
  1597. return;
  1598. }
  1599. if ((shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114) && primg.Length <= 0)//公司自用店铺ID
  1600. {
  1601. returnErrorMsg("必须上传付款凭证");
  1602. return;
  1603. }
  1604. CeErpTrade entity = new CeErpTrade();
  1605. entity.tid = (preStr + DateTime.Now.ToString("yyyyMMddHHmmss"));
  1606. entity.seller_nick = sellerNick;
  1607. entity.buyer_nick = GetPostString("buyer_nick");
  1608. entity.payment = Convert.ToDouble(GetPostString("payment"));
  1609. entity.total_fee = entity.payment;
  1610. entity.pay_time = DateTime.Now;
  1611. entity.status = "NOT_SHIPPED";
  1612. entity.receiver_name = GetPostString("receiver_name");
  1613. entity.receiver_mobile = GetPostString("receiver_mobile");
  1614. entity.receiver_state = GetPostString("receiver_state");
  1615. entity.receiver_city = GetPostString("receiver_city");
  1616. entity.receiver_district = GetPostString("receiver_district");
  1617. entity.receiver_address = GetPostString("receiver_address");
  1618. entity.seller_memo = memo;
  1619. entity.orderFrom = 20;
  1620. entity.orderType = 15;
  1621. if (entity.receiver_state == "" || entity.receiver_city == "")
  1622. {
  1623. returnErrorMsg("收件地址不能为空");
  1624. return;
  1625. }
  1626. if ((shopId != 34 && shopId != 94 && shopId != 96 && shopId != 95 && shopId != 114) && entity.payment == 0)
  1627. {
  1628. returnErrorMsg("公司自用的单金额才能为0");
  1629. return;
  1630. }
  1631. entity.Create();
  1632. string toWhere = GetPostString("towhere");
  1633. CeErpTradeCell entitycell = new CeErpTradeCell();
  1634. entitycell.ctid = entity.tid;
  1635. //唯一标识
  1636. entitycell.OrderSn = entity.tid;
  1637. string orderSn = dataHelper.getSaleOrderSn();
  1638. if (orderSn != "")
  1639. {
  1640. entitycell.OrderSn = orderSn;
  1641. }
  1642. entitycell.tid = entity.tid;
  1643. //if (preStr == "X_")
  1644. //{
  1645. entitycell.IsOffLineOrder = 1;
  1646. //}
  1647. entitycell.CustomerUserId = CurrentUser.UserID;
  1648. entitycell.PayProofImg = primg;
  1649. entitycell.seller_memo = "(" + entitycell.OrderSn + ")-" + memo;
  1650. entitycell.ProductId = Convert.ToInt32(productId);
  1651. entitycell.ShopId = shopId;
  1652. entitycell.UpdateTime = DateTime.Now;
  1653. entitycell.payment = Convert.ToDouble(GetPostString("payment"));
  1654. if (entity.buyer_nick == "现货手提袋" || memo.IndexOf("现货手提袋") != -1)
  1655. {
  1656. entitycell.IsXianHuo = 1;
  1657. }
  1658. entitycell.pay_time = entity.pay_time;
  1659. if (toWhere == "1")
  1660. {
  1661. entitycell.OrderState = 2;
  1662. }
  1663. else
  1664. {
  1665. entitycell.OrderState = 6;
  1666. entitycell.FinishPlaceTime = entitycell.pay_time;
  1667. }
  1668. if (shopId == 94)
  1669. {
  1670. entitycell.OrderState = 4;
  1671. entitycell.WaitDesignTime = entitycell.pay_time;
  1672. entitycell.StartDesignTime = entitycell.pay_time;
  1673. entitycell.DesignUserId = 218;
  1674. }
  1675. if (addFrom == "1" && (shopId != 34 && shopId != 96 && shopId != 95 && shopId != 94 && shopId != 114))
  1676. {
  1677. entitycell.OrderState = -1;//修改12-5
  1678. CeWithdraw ceWithdraw = new CeWithdraw();
  1679. ceWithdraw.tid = entity.tid;
  1680. ceWithdraw.providerid = "-1";
  1681. ceWithdraw.status = -1;
  1682. ceWithdraw.creationtime = DateTime.Now;
  1683. ceWithdraw.userid = 1337;
  1684. ceWithdraw.Create();
  1685. }
  1686. entitycell.Create();
  1687. CeErpTradeCellExtend.createInfo(entitycell.ctid, 15, 20);
  1688. if (shopId == 34 && entity.buyer_nick == "现货手提袋")
  1689. {
  1690. addPlaceRegist(entitycell, CurrentUser.UserID);
  1691. }
  1692. returnSuccessMsg("订单已生成!单号:" + entity.tid);
  1693. LogHelper.addLog(entitycell.ctid, CurrentUser.UserID, "新增线下订单", 0, 0);
  1694. return;
  1695. }
  1696. }
  1697. public void addPlaceRegist(CeErpTradeCell tradecell, int userid)
  1698. {
  1699. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  1700. entity.PlactTime = tradecell.pay_time;
  1701. entity.AddUserId = userid;
  1702. entity.FileName = tradecell.seller_memo;
  1703. entity.Supplier = 24;
  1704. entity.CreateTime = DateTime.Now;
  1705. entity.Did = tradecell.ctid;
  1706. entity.tid = tradecell.tid;
  1707. entity.splitTag = tradecell.SplitTag;
  1708. entity.CurState = "未完成";
  1709. entity.Create();
  1710. }
  1711. public void get_erp_offlinelist()
  1712. {
  1713. DataStruct dStruct = GetPostStruct();
  1714. List<string> lw = new List<string>();
  1715. string tid = GetPostString("ctid");
  1716. string date1 = GetPostString("date1");
  1717. string date2 = GetPostString("date2");
  1718. if (tid.Length > 0 || date1.Length > 0)
  1719. {
  1720. lw.Add(string.Format("ctid like '%{0}%'", tid));
  1721. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1722. if (dw.Length > 0) lw.Add(dw);
  1723. }
  1724. else
  1725. {
  1726. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  1727. }
  1728. string shopname = GetPostString("shopname");
  1729. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1730. string buyernick = GetPostString("buyer_nick");
  1731. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1732. string customer = GetPostString("customer");
  1733. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  1734. string design = GetPostString("design");
  1735. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  1736. string orderState = GetPostString("orderState");
  1737. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  1738. string address = GetPostString("address");
  1739. 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));
  1740. string sellermemo = GetPostString("seller_memo");
  1741. if (sellermemo.Length > 0)
  1742. {
  1743. lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1744. }
  1745. string price1 = GetPostString("price1");
  1746. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1747. string price2 = GetPostString("price2");
  1748. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1749. //if (PKey != "admin")
  1750. //{
  1751. // string usershop = CurrentUser.User.pemShop;
  1752. // lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  1753. //}
  1754. //if (ex_psize > 0)
  1755. //{
  1756. dStruct.Order = "pay_time desc";
  1757. //}
  1758. //else
  1759. // dStruct.Order = "isRefund desc,IsUrgency desc,pay_time desc";
  1760. lw.Add(string.Format("IsOffLineOrder=1"));
  1761. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1762. DataTable dt = null;
  1763. dt = WebCache.GetData("view_erptradecell", dStruct);
  1764. writeGridDataTableJson(dStruct.TotalCount, dt);
  1765. }
  1766. public void get_erp_returncashrecord()
  1767. {
  1768. DataStruct dStruct = GetPostStruct();
  1769. List<string> lw = new List<string>();
  1770. string tid = GetPostString("ctid");
  1771. if (tid.Length > 0)
  1772. {
  1773. lw.Add(string.Format("tid like '%{0}%'", tid));
  1774. dStruct.Order = "id desc";
  1775. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1776. DataTable dt = WebCache.GetData("view_erpreturncash", dStruct);
  1777. //writeGridDataTableJson(dStruct.TotalCount, dt);
  1778. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  1779. return;
  1780. }
  1781. returnErrorMsg("id数据错误!");
  1782. }
  1783. public void ins_erp_returncashrecord()
  1784. {
  1785. if (UrlPostParmsCheck("tid"))
  1786. {
  1787. string tid = GetPostString("tid");
  1788. string retype = GetPostString("type");
  1789. StringBuilder sql = new StringBuilder();
  1790. sql.AppendFormat("select * from ce_ErpReturnCash where tid='{0}' and rtype like '%{1}%' and cashstate!=2;", tid, retype);
  1791. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  1792. if (dt.Rows.Count > 0)
  1793. {
  1794. returnErrorMsg("相同返现类型记录已存在");
  1795. return;
  1796. }
  1797. CeErpReturnCash entity = new CeErpReturnCash();
  1798. entity.tid = tid;
  1799. entity.seller_nick = GetPostString("seller_nick");
  1800. string pment = GetPostString("payment");
  1801. if (pment.Length > 0)
  1802. {
  1803. entity.payment = Convert.ToDouble(pment);
  1804. }
  1805. entity.buyer_nick = GetPostString("buyer_nick");
  1806. entity.cashstate = 0;
  1807. entity.rtype = retype;
  1808. string rPrice = GetPostString("returnprice");
  1809. if (rPrice.Length > 0)
  1810. {
  1811. entity.returnprice = Convert.ToDouble(rPrice);
  1812. }
  1813. entity.created = DateTime.Now;
  1814. entity.con = GetPostString("con");
  1815. entity.img = GetPostString("img");
  1816. entity.applyuserid = CurrentUser.UserID;
  1817. entity.Create();
  1818. LogHelper.addLog(entity.tid, CurrentUser.UserID, "添加:" + entity.rtype);
  1819. returnSuccessMsg("操作成功!");
  1820. return;
  1821. }
  1822. }
  1823. public void set_erp_predelivery()
  1824. {
  1825. if (UrlPostParmsCheck("ctid"))
  1826. {
  1827. string eid = GetPostString("ctid");
  1828. CeErpTradeCell entity = null;
  1829. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1830. if (entity != null)
  1831. {
  1832. //CeErpTrade mainTd = CeErpTrade.Get(entity.tid);
  1833. //if (mainTd != null && mainTd.status== "WAIT_BUYER_CONFIRM_GOODS")
  1834. //{
  1835. // returnErrorMsg("此单淘宝状态为已发货,无需重复发货");
  1836. // return;
  1837. //}
  1838. entity.IsPreDelivery = 1;
  1839. entity.Update();
  1840. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1841. returnSuccessMsg("预发货成功!");
  1842. return;
  1843. //string shop = GetPostString("seller_nick");
  1844. ////string sessionkey = taobaoHelper.ShopKeyDics[shop];
  1845. //string comName = GetPostString("comName");
  1846. //string comCode = GetPostString("comCode");
  1847. //string outSid = GetPostString("outSid");//运单号
  1848. //string deliveryType = GetPostString("deliveryType");//发货类型 物流 还是虚拟
  1849. //string deliveryMemo = GetPostString("deliveryMemo"); //发货备注
  1850. ////string res = taobaoHelper.LogisticsOnlineSend(sessionkey, entity.tid, comCode, outSid);
  1851. //string apires = "";
  1852. //if (deliveryType == "虚拟发货")
  1853. //{
  1854. // apires = apiHelper.API_LogisticsDummySend(entity.tid, mainTd.posCode);
  1855. //}
  1856. //else
  1857. //{
  1858. // apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainTd.posCode, comCode, outSid);
  1859. //}
  1860. ////if (res.IndexOf("is_success") != -1 && res.IndexOf("true") != -1)
  1861. ////{
  1862. //if (apires.IndexOf("发货成功") != -1)
  1863. //{
  1864. // if (deliveryType != "虚拟发货")
  1865. // {
  1866. // //还要插入快递信息到 快递信息表
  1867. // CeErpExpressInfo exinfo = new CeErpExpressInfo();
  1868. // exinfo.tid = eid;
  1869. // exinfo.out_sid = outSid;
  1870. // exinfo.company_code = comCode;
  1871. // exinfo.company_name = comName;
  1872. // exinfo.delivery_memo = deliveryMemo;
  1873. // exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  1874. // exinfo.deliveryType = deliveryType;
  1875. // exinfo.Create();
  1876. // }
  1877. // returnSuccessMsg("发货成功!");
  1878. // LogHelper.addLog(entity.ctid, CurrentUser.UserID, "预发货", entity.OrderState);
  1879. //}
  1880. //else
  1881. //{
  1882. // returnErrorMsg("淘宝发货失败!!");
  1883. //}
  1884. //return;
  1885. }
  1886. returnErrorMsg("找不到订单记录");
  1887. }
  1888. }
  1889. public void get_erp_unusuallist()
  1890. {
  1891. DataStruct dStruct = GetPostStruct();
  1892. List<string> lw = new List<string>();
  1893. string tid = GetPostString("ctid");
  1894. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  1895. string shopname = GetPostString("shopname");
  1896. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  1897. string buyernick = GetPostString("buyer_nick");
  1898. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  1899. string ResponsibleMan = GetPostString("responsible");
  1900. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  1901. string date1 = GetPostString("date1");
  1902. string date2 = GetPostString("date2");
  1903. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  1904. if (dw.Length > 0) lw.Add(dw);
  1905. string price1 = GetPostString("price1");
  1906. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  1907. string price2 = GetPostString("price2");
  1908. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  1909. string orderState = GetPostString("orderState");
  1910. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  1911. string sellermemo = GetPostString("seller_memo");
  1912. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  1913. lw.Add(string.Format("UnusualTag > 0"));
  1914. lw.Add(string.Format("IsRefund<={0}", 1));
  1915. dStruct.Order = "pay_time desc";
  1916. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  1917. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  1918. writeGridDataTableJson(dStruct.TotalCount, dt);
  1919. }
  1920. public void set_erp_unusualtonomal()
  1921. {
  1922. if (UrlPostParmsCheck("ctid"))
  1923. {
  1924. string eid = GetPostString("ctid");
  1925. CeErpTradeCell entity = null;
  1926. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1927. if (entity != null)
  1928. {
  1929. entity.UnusualTag = -1;
  1930. entity.Update();
  1931. returnSuccessMsg("忽略成功!");
  1932. return;
  1933. }
  1934. returnErrorMsg("找不到记录");
  1935. }
  1936. }
  1937. public void ins_erp_unusualreason()
  1938. {
  1939. if (UrlPostParmsCheck("ctid"))
  1940. {
  1941. string eid = GetPostString("ctid");
  1942. CeErpTradeCell entity = null;
  1943. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  1944. if (entity != null)
  1945. {
  1946. entity.MemoOpt = 4;
  1947. entity.UnusualCon = GetPostString("con");
  1948. entity.Update();
  1949. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  1950. if (trade != null)
  1951. {
  1952. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  1953. }
  1954. //查货是否超时
  1955. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  1956. if (ceErpTradeCellExtend == null)
  1957. {
  1958. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  1959. ceErpTradeCellExtend.ctid = entity.ctid;
  1960. }
  1961. if (ceErpTradeCellExtend.CheckTime == null && DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.CheckOrderTime) >= 0)
  1962. {
  1963. ceErpTradeCellExtend.CheckOut += 1;
  1964. }
  1965. ceErpTradeCellExtend.CheckTime = DateTime.Now;
  1966. if (ceErpTradeCellExtend.ID > 0)
  1967. {
  1968. ceErpTradeCellExtend.Update();
  1969. }
  1970. else
  1971. {
  1972. ceErpTradeCellExtend.Create();
  1973. }
  1974. CeErpTradeLog.AddLog(eid, 6, CurrentUser.UserID, "异常解释:" + entity.UnusualCon);
  1975. returnSuccessMsg("操作成功!");
  1976. return;
  1977. }
  1978. returnErrorMsg("找不到记录");
  1979. }
  1980. }
  1981. public void upd_erp_sampleorder()
  1982. {
  1983. if (UrlPostParmsCheck("ctid"))
  1984. {
  1985. string eid = GetPostString("ctid");
  1986. string[] eArr = eid.Split(',');
  1987. if (eArr.Length > 1)
  1988. {
  1989. List<string> eLst = new List<string>();
  1990. for (int i = 0; i < eArr.Length; i++)
  1991. {
  1992. eLst.Add("'" + eArr[i] + "'");
  1993. }
  1994. eid = string.Join(",", eLst.ToArray());
  1995. }
  1996. else
  1997. {
  1998. eid = "'" + eid + "'";
  1999. }
  2000. StringBuilder sql = new StringBuilder();
  2001. sql.AppendFormat("select * from view_ErpTradeCell where ctid in ({0});", eid);
  2002. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2003. int supplierId = Convert.ToInt32(webConfig.SampleOrderSupplier);
  2004. if (dt.Rows.Count > 0)
  2005. {
  2006. string errmsg = "";
  2007. foreach (DataRow dr in dt.Rows)
  2008. {
  2009. StringBuilder sqlsb = new StringBuilder();
  2010. sqlsb.AppendFormat("update CE_ErpTradeCell with(rowlock) set IsSample=1 ,OrderState=6,SupplierId={1},seller_memo='拿样订单【标记】' where ctid='{0}';", dr["tid"].ToString(), supplierId);
  2011. sqlsb.AppendFormat("insert into CE_ErpTradeSample(ctid,SampleUserId ,SampleDate) Values('{0}',{1},getdate());", dr["tid"].ToString(), CurrentUser.UserID);
  2012. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  2013. //string res = taobaoHelper.TradeMemoUpdate(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["seller_nick"].ToString(), 5, "拿样订单【标记】");//修改备注,5为紫色旗子
  2014. string apires = apiHelper.API_TradeMemoUpdate(dr["tid"].ToString(), dr["posCode"].ToString(), "PURPLE", "拿样订单【标记】");
  2015. if (apires.IndexOf("修改成功") != -1 && apires.IndexOf("true") != -1)
  2016. {
  2017. continue;
  2018. }
  2019. else
  2020. {
  2021. string emsg = commonHelper.KeepChinese(apires);
  2022. errmsg += emsg;
  2023. }
  2024. }
  2025. if (errmsg.Length > 0)
  2026. {
  2027. returnErrorMsg(errmsg);
  2028. return;
  2029. }
  2030. returnSuccessMsg("操作成功");
  2031. return;
  2032. }
  2033. returnErrorMsg("找不到记录");
  2034. }
  2035. }
  2036. public void upd_erp_transcustomer()
  2037. {
  2038. if (UrlPostParmsCheck("ctid"))
  2039. {
  2040. string eid = GetPostString("ctid");
  2041. int userid = GetPostInt("CustomerUserId");
  2042. CeErpTradeCell entity = null;
  2043. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2044. if (entity != null)
  2045. {
  2046. //string[] mlist = entity.seller_memo.Split('-');
  2047. //string sql = "select * from view_erpuser where id=" + userid;
  2048. //DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2049. //if (dt != null && dt.Rows.Count > 0)
  2050. //{
  2051. // string nmemo = "";
  2052. // for(int i = 0; i < mlist.Length - 1; i++)
  2053. // {
  2054. // nmemo += mlist[i];
  2055. // nmemo += "-";
  2056. // }
  2057. // nmemo+= dt.Rows[0]["Tb"].ToString();
  2058. // entity.seller_memo = nmemo;
  2059. //}
  2060. entity.CustomerUserId = userid;
  2061. entity.Update();
  2062. returnSuccessMsg("操作成功!");
  2063. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他客服" + userid, entity.OrderState);
  2064. return;
  2065. }
  2066. returnErrorMsg("找不到记录");
  2067. }
  2068. }
  2069. public void upd_erp_transdesigner()
  2070. {
  2071. if (UrlPostParmsCheck("ctid"))
  2072. {
  2073. string eids = GetPostString("ctid");
  2074. string[] ctidList = eids.Split(',');
  2075. int userid = GetPostInt("DesignUserId");
  2076. foreach (string ctid in ctidList)
  2077. {
  2078. CeErpTradeCell entity = null;
  2079. CeErpDesignerBill entitys = null;
  2080. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2081. entitys = CeErpDesignerBill.GetByTid(ctid);
  2082. if (entity != null)
  2083. {
  2084. if (entity.OrderState > 4)
  2085. {
  2086. continue;
  2087. }
  2088. //存在退款不能流转
  2089. if (entity.IsRefund > 0)
  2090. {
  2091. continue;
  2092. }
  2093. entity.DesignUserId = userid;
  2094. entity.WaitDesignTime = DateTime.Now;
  2095. entity.Update();
  2096. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "转单给其他设计师" + userid, entity.OrderState);
  2097. }
  2098. }
  2099. returnSuccessMsg("操作成功!");
  2100. }
  2101. }
  2102. public void upd_erp_distributedesigner()
  2103. {
  2104. if (UrlPostParmsCheck("ctid"))
  2105. {
  2106. string eid = GetPostString("ctid");
  2107. int userid = GetPostInt("DesignUserId");
  2108. string[] idlist = eid.Split(',');
  2109. if (idlist.Length <= 0)
  2110. {
  2111. returnErrorMsg("订单不能为空");
  2112. return;
  2113. }
  2114. foreach (string ctid in idlist)
  2115. {
  2116. CeErpTradeCell entity = null;
  2117. CeErpDesignerBill entitys = null;
  2118. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  2119. else continue;
  2120. if (entity != null)
  2121. {
  2122. if (userid == 2125 || userid == 3542)
  2123. { }
  2124. if (entity.payment <= 0 && entity.ShopId != 34 && entity.ShopId != 94 && entity.ShopId != 96 && entity.isAfterSaleOrder != 1) //公司自用可以为0
  2125. {
  2126. returnErrorMsg("金额错误的订单无法指派");
  2127. return;
  2128. }
  2129. if (entity.OrderState >= 5)
  2130. {
  2131. returnErrorMsg("已经设计完成无法指派");
  2132. return;
  2133. }
  2134. if (entity.OrderState == -1)
  2135. {
  2136. returnErrorMsg("审核中的订单无法指派");
  2137. return;
  2138. }
  2139. if (entity.isAfterSaleOrder == 1 && entity.IsReturn == 3)
  2140. {
  2141. returnErrorMsg("售后单被打回了,到售后打回列表恢复即可!");
  2142. return;
  2143. }
  2144. //157赖橙帆 159林晨
  2145. if (entity.OrderState > 3 && entity.DispatchSort == 2 && userid != 3542 && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Summarize" && CurrentUser.UserID != 157 && CurrentUser.UserID != 159 && CurrentUser.UserID != 1479)
  2146. {
  2147. returnErrorMsg("指派设计共创无法再次指派!");
  2148. return;
  2149. }
  2150. entity.OrderState = 3;
  2151. CeErpUserPost userEntity = CeErpUserPost.GetByUserID(userid);
  2152. if (entity.ctid.IndexOf("S_") == -1 && userEntity.OrgID == 10)
  2153. {
  2154. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2155. entity.SupplierId = suid;
  2156. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2157. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2158. }
  2159. if (userid == 2125 && entity.seller_memo != "")
  2160. {
  2161. apiDesign.API_GetPrintData_CreateOrder(entity);
  2162. }
  2163. if (userid == 3542 && entity.seller_memo != "")
  2164. {
  2165. designApiResponseVo response = designHelper.API_GetPrintData_CreateOrder(entity, CurrentUser.UserPost.Post.Code);
  2166. LogHelper.addLog(entity.ctid, 3542, "手动派单:" + response.msg, entity.OrderState);
  2167. if (response.msg != "设计共创:成功")
  2168. {
  2169. returnErrorMsg(response.msg);
  2170. return;
  2171. }
  2172. entity.DispatchSort = 2;
  2173. }
  2174. else
  2175. {
  2176. if (entity.DispatchSort == 2)
  2177. {
  2178. ApiVo apiVo = new ApiVo();
  2179. apiVo.actionName = "closeDesign";
  2180. apiVo.orderNumber = entity.ctid;
  2181. designHelper.API_WorkCore(apiVo);//closeDesign
  2182. }
  2183. entity.DispatchSort = 0;
  2184. }
  2185. entity.DesignUserId = userid;
  2186. entity.WaitDesignTime = DateTime.Now;
  2187. entity.UpdateTime = DateTime.Now;
  2188. entity.Update();
  2189. string name = commonHelper.getUserNameById(userid);
  2190. commonHelper.UpdateRelationOrder(entity.ctid);
  2191. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派设计师" + name + userid, entity.OrderState);
  2192. }
  2193. }
  2194. returnSuccessMsg("操作成功!");
  2195. return;
  2196. }
  2197. }
  2198. public string getTidByCtid(string ctid)
  2199. {
  2200. string tid = "";
  2201. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2202. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2203. if (dataTable != null && dataTable.Rows.Count > 0)
  2204. {
  2205. tid = dataTable.Rows[0]["tid"].ToString();
  2206. }
  2207. return tid;
  2208. }
  2209. public List<string> getTidByCtidLike(string ctid)
  2210. {
  2211. string sql = string.Format("select tid from CE_ErpTradeCell where (ctid='{0}' or tid='{0}' or orderSn='{0}')", ctid);
  2212. DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2213. List<string> list = new List<string>();
  2214. if (dataTable != null && dataTable.Rows.Count > 0)
  2215. {
  2216. foreach (DataRow item in dataTable.Rows)
  2217. {
  2218. list.Add("'" + item["tid"].ToString() + "'");
  2219. }
  2220. }
  2221. return list;
  2222. }
  2223. public void get_erp_myorderlist()
  2224. {
  2225. DataStruct dStruct = GetPostStruct();
  2226. List<string> lw = new List<string>();
  2227. string tid = GetPostString("ctid");
  2228. if (tid.Length > 0)
  2229. {
  2230. string select_tid = getTidByCtid(tid);
  2231. lw.Add(string.Format("tid='{0}'", select_tid));
  2232. }
  2233. else
  2234. {
  2235. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2236. }
  2237. //12-1 修改
  2238. string urgent = GetPostString("urgent");
  2239. string back = GetPostString("back");
  2240. string offlineSearch = GetPostString("offlineSearch");
  2241. if (!string.IsNullOrWhiteSpace(urgent))
  2242. {
  2243. if (urgent.Equals("true"))
  2244. {
  2245. lw.Add(string.Format("(IsUrgency='{0}' )", 1));
  2246. }
  2247. }
  2248. if (!string.IsNullOrWhiteSpace(back))
  2249. {
  2250. if (back.Equals("true"))
  2251. {
  2252. lw.Add(string.Format("(IsReturn='{0}' )", 1));
  2253. }
  2254. }
  2255. if (!string.IsNullOrWhiteSpace(offlineSearch))
  2256. {
  2257. if (offlineSearch.Equals("true"))
  2258. {
  2259. lw.Add(string.Format("(ctid like '{0}%')", "N"));
  2260. }
  2261. }
  2262. //end
  2263. string shopname = GetPostString("shopname");
  2264. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2265. string buyernick = GetPostString("buyer_nick");
  2266. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2267. string design = GetPostString("design");
  2268. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2269. string orderState = GetPostString("orderState");
  2270. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2271. string sellermemo = GetPostString("seller_memo");
  2272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2273. string date1 = GetPostString("date1");
  2274. string date2 = GetPostString("date2");
  2275. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2276. if (dw.Length > 0) lw.Add(dw);
  2277. string price1 = GetPostString("price1");
  2278. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2279. string price2 = GetPostString("price2");
  2280. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2281. string urgency = GetPostString("urgency");
  2282. if (urgency.Length > 0) lw.Add(string.Format("IsUrgency = {0}", 1));
  2283. string after = GetPostString("after");
  2284. if (after.Length > 0) lw.Add(string.Format("AfterSaleState > {0}", 0));
  2285. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2286. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2287. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2288. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2289. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2290. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2291. if (dt != null && dt.Rows.Count > 0)
  2292. {
  2293. foreach (DataRow dr in dt.Rows)
  2294. {
  2295. try
  2296. {
  2297. // 对象操作
  2298. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2299. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2300. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2301. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2302. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2303. if (dStruct.PageSize != 100000)
  2304. {
  2305. if (dr["DispatchSort"].ToString() == "2")
  2306. {
  2307. dr["gongchuang"] = 200;
  2308. }
  2309. else
  2310. {
  2311. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2312. dr["gongchuang"] = response.code;
  2313. }
  2314. }
  2315. }
  2316. catch (NullReferenceException ex)
  2317. {
  2318. }
  2319. }
  2320. }
  2321. writeGridDataTableJson(dStruct.TotalCount, dt);
  2322. }
  2323. public void get_erp_myreturnorderlist()
  2324. {
  2325. DataStruct dStruct = GetPostStruct();
  2326. List<string> lw = new List<string>();
  2327. string tid = GetPostString("ctid");
  2328. if (tid.Length > 0)
  2329. {
  2330. string select_tid = getTidByCtid(tid);
  2331. lw.Add(string.Format("tid='{0}'", select_tid));
  2332. }
  2333. else
  2334. {
  2335. lw.Add(string.Format("datediff(d,pay_time,getdate())<=91 "));
  2336. }
  2337. string shopname = GetPostString("shopname");
  2338. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2339. string buyernick = GetPostString("buyer_nick");
  2340. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2341. string design = GetPostString("design");
  2342. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2343. string orderState = GetPostString("orderState");
  2344. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2345. string sellermemo = GetPostString("seller_memo");
  2346. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2347. string date1 = GetPostString("date1");
  2348. string date2 = GetPostString("date2");
  2349. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2350. if (dw.Length > 0) lw.Add(dw);
  2351. string price1 = GetPostString("price1");
  2352. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2353. string price2 = GetPostString("price2");
  2354. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2355. if (CurrentUser.UserPost.Post.Code == "Director" || CurrentUser.UserPost.Post.Code == "CustomerMr")
  2356. {
  2357. lw.Add(string.Format("ShopId in ({0})", CurrentUser.User.pemShop));
  2358. }
  2359. else
  2360. {
  2361. lw.Add(string.Format("CustomerUserId = {0}", CurrentUser.UserID));
  2362. }
  2363. lw.Add(string.Format(" IsReturn>0 and OrderState=0"));
  2364. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2365. dStruct.Order = "IsReturn desc,isRefund desc,IsUrgency desc, pay_time desc";
  2366. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2367. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2368. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2369. if (dt != null && dt.Rows.Count > 0)
  2370. {
  2371. foreach (DataRow dr in dt.Rows)
  2372. {
  2373. try
  2374. {
  2375. // 对象操作
  2376. if (dStruct.PageSize != 100000)
  2377. {
  2378. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2379. dr["gongchuang"] = response.code;
  2380. }
  2381. }
  2382. catch (NullReferenceException ex)
  2383. {
  2384. // 处理空引用异常
  2385. }
  2386. }
  2387. }
  2388. writeGridDataTableJson(dStruct.TotalCount, dt);
  2389. }
  2390. public void get_erp_myorderlist_pregather()
  2391. {
  2392. string date1 = GetPostString("date1");
  2393. string date2 = GetPostString("date2");
  2394. int userId = CurrentUser.UserID; //客服id
  2395. string orderWhere = "";
  2396. List<string> lw = new List<string>();
  2397. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2398. if (dw.Length > 0) lw.Add(dw);
  2399. lw.Add(string.Format("CustomerUserId={0}", userId));
  2400. lw.Add(string.Format("OrderState<9"));
  2401. orderWhere = string.Join(" and ", lw.ToArray());
  2402. string orderWhere2 = "";
  2403. List<string> lw2 = new List<string>();
  2404. string dw2 = GetDateMinuteWhere("pay_time", date1, date2);
  2405. if (dw2.Length > 0) lw2.Add(dw2);
  2406. lw2.Add(string.Format("CustomerUserId={0}", userId));
  2407. orderWhere2 = string.Join(" and ", lw2.ToArray());
  2408. string sql = string.Format("select *" +
  2409. "from(select CustomerUserId, sum(payment) as Amount, count(ctid) as Count from View_ErpTradeCell where " + orderWhere + " group by CustomerUserId) a " +
  2410. "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 " +
  2411. "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 " +
  2412. "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");
  2413. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2414. //writeGridDataTableJson(dt.Rows.Count, dt);
  2415. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2416. }
  2417. public void upd_erp_publishorder()
  2418. {
  2419. if (UrlPostParmsCheck("ctid"))
  2420. {
  2421. string eid = GetPostString("ctid");
  2422. CeErpTradeCell entity = null;
  2423. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2424. if (entity != null)
  2425. {
  2426. entity.OrderState = 0; //发布后,变为待抢单
  2427. entity.Update();
  2428. commonHelper.UpdateRelationOrder(entity.ctid);
  2429. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发布订单", entity.OrderState);
  2430. returnSuccessMsg("发布成功!");
  2431. return;
  2432. }
  2433. returnErrorMsg("找不到记录");
  2434. }
  2435. }
  2436. public void get_erp_my_tiporder()
  2437. {
  2438. StringBuilder sql = new StringBuilder();
  2439. int userId = 0;
  2440. if (CurrentUser != null) userId = CurrentUser.UserID;
  2441. string posCode = CurrentUser.UserPost.Post.Code;
  2442. string isTipedAfterSaleVerify = GetPostString("af");
  2443. DataTable dt = new DataTable();
  2444. if (posCode != "Supplier")
  2445. {
  2446. if (posCode == "CustomerService" || posCode == "Director")
  2447. {
  2448. sql.AppendFormat("select * from ce_erptradecell where CustomerUserId={0} and OrderState=0 and IsReadTag>0 ", userId);
  2449. }
  2450. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  2451. {
  2452. sql.AppendFormat("select * from ce_erptradecell where AfterSaleUserId={0} and IsReadTag>0 ", userId);
  2453. }
  2454. else
  2455. {
  2456. string teamIds = CurrentUser.User.TeamIds;
  2457. if (teamIds == "")
  2458. {
  2459. teamIds = "0";
  2460. }
  2461. 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);
  2462. }
  2463. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2464. }
  2465. if (dt.Rows.Count <= 0)
  2466. {
  2467. string key = "aftersale_order_" + userId;
  2468. if (RedisHelper.HasKey(key))
  2469. {
  2470. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2471. dt.Columns.Add("ctid", typeof(string));
  2472. dt.Columns.Add("IsReadTag", typeof(int));
  2473. foreach (var i in list)
  2474. {
  2475. DataRow data = dt.NewRow();
  2476. data["ctid"] = i;
  2477. data["IsReadTag"] = 4;
  2478. dt.Rows.Add(data);
  2479. }
  2480. RedisHelper.StringDelete(key);
  2481. }
  2482. }
  2483. if (dt.Rows.Count <= 0)
  2484. {
  2485. sql = new StringBuilder();
  2486. sql.AppendFormat("select * from CE_ErpTradeResponsible where UserId={0} and VerifyState=3 and type = 0 ", userId);
  2487. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2488. }
  2489. if (posCode == "Supplier")
  2490. {
  2491. string ids = CurrentUser.User.pemVend;
  2492. if (ids != null && ids.Length > 0)
  2493. {
  2494. string[] ids_list = ids.Split(',');
  2495. foreach (var item in ids_list)
  2496. {
  2497. string key = "return_order_" + item;
  2498. if (RedisHelper.HasKey(key))
  2499. {
  2500. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  2501. dt.Columns.Add("ctid", typeof(string));
  2502. dt.Columns.Add("IsReadTag", typeof(int));
  2503. foreach (var i in list)
  2504. {
  2505. DataRow data = dt.NewRow();
  2506. data["ctid"] = i;
  2507. data["IsReadTag"] = 1;
  2508. dt.Rows.Add(data);
  2509. }
  2510. RedisHelper.StringDelete(key);
  2511. }
  2512. }
  2513. }
  2514. if (dt.Rows.Count <= 0)
  2515. {
  2516. sql = new StringBuilder();
  2517. 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);
  2518. dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  2519. }
  2520. }
  2521. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  2522. }
  2523. public void reset_erp_tiporder()
  2524. {
  2525. string ids = GetPostString("ids");
  2526. string[] ctidList = ids.Split(',');
  2527. foreach (string ctid in ctidList)
  2528. {
  2529. CeErpTradeCell enty = CeErpTradeCell.GetByCtid(ctid);
  2530. if (enty != null)
  2531. {
  2532. enty.IsReadTag = 0;
  2533. enty.Update();
  2534. }
  2535. }
  2536. returnSuccessMsg("成功!");
  2537. return;
  2538. }
  2539. public void get_erp_designlist()
  2540. {
  2541. DataStruct dStruct = GetPostStruct();
  2542. List<string> lw = new List<string>();
  2543. string tid = GetPostString("ctid");
  2544. if (tid.Length > 0)
  2545. {
  2546. string select_tid = getTidByCtid(tid);
  2547. lw.Add(string.Format("tid='{0}'", select_tid));
  2548. }
  2549. string shopname = GetPostString("shopname");
  2550. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  2551. string buyernick = GetPostString("buyer_nick");
  2552. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  2553. string customer = GetPostString("customer");
  2554. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2555. string design = GetPostString("design");
  2556. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  2557. string orderState = GetPostString("orderState");
  2558. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2559. lw.Add(string.Format("OrderState<6"));
  2560. string address = GetPostString("address");
  2561. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  2562. string sellermemo = GetPostString("seller_memo");
  2563. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2564. string date1 = GetPostString("date1");
  2565. string date2 = GetPostString("date2");
  2566. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2567. if (dw.Length > 0) lw.Add(dw);
  2568. string apdate1 = GetPostString("apdate1");
  2569. string apdate2 = GetPostString("apdate2");
  2570. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2571. if (dwap.Length > 0) lw.Add(dwap);
  2572. string price1 = GetPostString("price1");
  2573. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2574. string price2 = GetPostString("price2");
  2575. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2576. string designTime = GetPostString("designtime");
  2577. if (designTime.Length > 0)
  2578. {
  2579. lw.Add(string.Format("FinishDesignTime > '{0}' or FinishDesignTime = ''", designTime));
  2580. }
  2581. string usershop = CurrentUser.User.pemShop;
  2582. if (usershop.Length > 0)
  2583. {
  2584. lw.Add(string.Format("shopId in ({0})", usershop));
  2585. }
  2586. int myOrgid = CurrentUser.UserPost.OrgID;
  2587. string myOrgCode = CurrentUser.UserPost.Post.Code;
  2588. if (myOrgCode.IndexOf("Designer") != -1)
  2589. {
  2590. if (CurrentUser.User.ManageOrgIds.Length > 0)
  2591. {
  2592. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  2593. }
  2594. else
  2595. {
  2596. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  2597. }
  2598. }
  2599. else
  2600. {
  2601. string orgId = GetPostString("designerhd");
  2602. if (orgId.Length > 0) lw.Add(string.Format("DesOrgID = '{0}'", orgId));
  2603. }
  2604. if (tid.Length > 0 || buyernick.Length > 0)
  2605. {
  2606. lw.Add(string.Format("OrderState >= 3"));
  2607. }
  2608. else
  2609. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2610. if (tid.Length <= 0) lw.Add(string.Format("IsRefund<={0}", 1));
  2611. dStruct.Order = "IsReturn desc,MemoOpt desc, pay_time desc";
  2612. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2613. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2614. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2615. if (dt != null && dt.Rows.Count > 0)
  2616. {
  2617. foreach (DataRow dr in dt.Rows)
  2618. {
  2619. try
  2620. {
  2621. // 对象操作
  2622. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2623. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2624. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2625. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2626. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2627. if (dStruct.PageSize != 100000)
  2628. {
  2629. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2630. dr["gongchuang"] = response.code;
  2631. }
  2632. }
  2633. catch (NullReferenceException ex)
  2634. {
  2635. }
  2636. }
  2637. }
  2638. writeGridDataTableJson(dStruct.TotalCount, dt);
  2639. }
  2640. public void get_erp_mydesignlist()
  2641. {
  2642. DataStruct dStruct = GetPostStruct();
  2643. List<string> lw = new List<string>();
  2644. string tid = GetPostString("ctid");
  2645. if (tid.Length > 0)
  2646. {
  2647. string select_tid = getTidByCtid(tid);
  2648. lw.Add(string.Format("tid='{0}'", select_tid));
  2649. }
  2650. string shopname = GetPostString("shopname");
  2651. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2652. string buyernick = GetPostString("buyer_nick");
  2653. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2654. string customer = GetPostString("customer");
  2655. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  2656. string orderState = GetPostString("orderState");
  2657. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", orderState));
  2658. //lw.Add(string.Format("OrderState<6"));
  2659. string date1 = GetPostString("date1");
  2660. string date2 = GetPostString("date2");
  2661. string dw = GetDateWhere("pay_time", date1, date2);
  2662. if (dw.Length > 0) lw.Add(dw);
  2663. string apdate1 = GetPostString("apdate1");
  2664. string apdate2 = GetPostString("apdate2");
  2665. string dwap = GetDateMinuteWhere("WaitDesignTime", apdate1, apdate2);
  2666. if (dwap.Length > 0) lw.Add(dwap);
  2667. string price1 = GetPostString("price1");
  2668. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2669. string price2 = GetPostString("price2");
  2670. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2671. string olddownload = GetPostString("olddown");
  2672. if (olddownload == "1")
  2673. {
  2674. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')>=0", "2021-08-01 00:00:00"));
  2675. }
  2676. else if (olddownload == "2")
  2677. {
  2678. lw.Add(string.Format("datediff(d, OldCustomerTime,'{0}')<0", "2021-08-01 00:00:00"));
  2679. }
  2680. string sellermemo = GetPostString("seller_memo");
  2681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2682. lw.Add(string.Format("OrderState >= 3 and OrderState <= 5"));
  2683. if (CurrentUser.UserPost.Post.Code != "SysAdmin")
  2684. {
  2685. if (CurrentUser.User.TeamIds.Length > 0)
  2686. {
  2687. if (CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr")
  2688. lw.Add(string.Format("(DesignUserId = {0} or DesignUserId in ({1}) )", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2689. else
  2690. lw.Add(string.Format("(DesignUserId = {0} or ((IsReturn>0 or MemoOpt>0) and DesignUserId in ({1})))", CurrentUser.UserID, CurrentUser.User.TeamIds));
  2691. }
  2692. else
  2693. {
  2694. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  2695. }
  2696. }
  2697. if (tid.Length <= 0)
  2698. {
  2699. lw.Add(string.Format("IsRefund<={0} and datediff(d,WaitDesignTime,getdate())<=92", 1));
  2700. }
  2701. lw.Add(string.Format("IsReturn!=3"));
  2702. dStruct.Order = "IsReturn desc,OrderState asc,MemoOpt desc,pay_time desc";
  2703. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2704. string teamids = CurrentUser.User.TeamIds.ToString();
  2705. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2706. dt.Columns.Add(new DataColumn("gongchuang", typeof(string)));
  2707. if (dt != null && dt.Rows.Count > 0)
  2708. {
  2709. foreach (DataRow dr in dt.Rows)
  2710. {
  2711. try
  2712. {
  2713. // 对象操作
  2714. CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
  2715. ceErpTradeCell.ctid = dr["ctid"].ToString();
  2716. ceErpTradeCell.seller_memo = dr["seller_memo"].ToString();
  2717. ceErpTradeCell.ShopId = Convert.ToInt32(dr["ShopId"]);
  2718. ceErpTradeCell.ProductId = Convert.ToInt32(dr["ProductId"]);
  2719. if (dStruct.PageSize != 100000)
  2720. {
  2721. designApiResponseVo response = commonHelper.checkOrderListDesignInfo(dr["tid"].ToString());
  2722. dr["gongchuang"] = response.code;
  2723. }
  2724. }
  2725. catch (NullReferenceException ex)
  2726. {
  2727. }
  2728. }
  2729. }
  2730. writeGridDataTableJson(dStruct.TotalCount, dt);
  2731. }
  2732. public void set_erp_startdesign()
  2733. {
  2734. if (UrlPostParmsCheck("ctid"))
  2735. {
  2736. string eid = GetPostString("ctid");
  2737. CeErpTradeCell entity = null;
  2738. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2739. if (entity != null)
  2740. {
  2741. if (entity.OrderState != 3)
  2742. {
  2743. returnErrorMsg("请刷新,订单已经设计了");
  2744. return;
  2745. }
  2746. entity.StartDesignTime = DateTime.Now;
  2747. entity.OrderState = 4;
  2748. if (entity.ctid.IndexOf("S_") == -1 && entity.SupplierId == 0)
  2749. {
  2750. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  2751. entity.SupplierId = suid;
  2752. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2753. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2754. }
  2755. entity.UpdateTime = DateTime.Now;
  2756. //entity.MakeSupplier = suname;
  2757. entity.Update();
  2758. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2759. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2760. commonHelper.DeleteOriginalOrderIfIsSplitOrder(entity.tid, entity.SplitTag);
  2761. commonHelper.getCytPrice(entity);
  2762. returnSuccessMsg("操作成功!");
  2763. return;
  2764. }
  2765. returnErrorMsg("找不到记录");
  2766. }
  2767. }
  2768. public void ins_erp_designselfmemo()
  2769. {
  2770. if (UrlPostParmsCheck("ctid"))
  2771. {
  2772. string eid = GetPostString("ctid");
  2773. string con = GetPostString("con");
  2774. CeErpTradeCell entity = null;
  2775. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2776. if (entity != null)
  2777. {
  2778. entity.DesignSelfMemo = con;
  2779. entity.Update();
  2780. returnSuccessMsg("操作成功!");
  2781. return;
  2782. }
  2783. returnErrorMsg("找不到记录");
  2784. }
  2785. }
  2786. public void ins_erp_designprice()
  2787. {
  2788. if (UrlPostParmsCheck("ctid"))
  2789. {
  2790. string eid = GetPostString("ctid");
  2791. int uid = CurrentUser.UserID;
  2792. string userName = CurrentUser.UserName;
  2793. CeErpTradeCell entity = null;
  2794. CeErpDesignerBill entitys = CeErpDesignerBill.GetByTid("ctid");
  2795. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2796. if (entitys == null)
  2797. {
  2798. entitys = new CeErpDesignerBill();
  2799. }
  2800. if (entity != null)
  2801. {
  2802. entity.DesignPrice = Convert.ToDouble(GetPostString("price"));
  2803. //entity.Number = Convert.ToInt32(GetPostString("number"));
  2804. entity.StartDesignTime = DateTime.Now;
  2805. entity.OrderState = 4;
  2806. string suname = "";
  2807. if (entity.SupplierId == 0)
  2808. {
  2809. int sid = commonHelper.autoDistributeToSupplier(entity);
  2810. entity.SupplierId = sid;
  2811. suname = commonHelper.getSupplierNameById(entity.SupplierId);
  2812. }
  2813. entity.Update();
  2814. CeErpUserPost ceErpUserPost = CeErpUserPost.GetByUserID(CurrentUser.UserID);
  2815. if (ceErpUserPost != null)
  2816. {
  2817. CeErpPost ceErpPost = CeErpPost.Get(ceErpUserPost.PostID);
  2818. if (ceErpPost != null)
  2819. {
  2820. if (eid.IndexOf("S") != 0 || !ceErpPost.Name.Equals("设计师P0"))
  2821. {
  2822. entitys.tid = entity.ctid;
  2823. entitys.oid = entity.tid;
  2824. entitys.uid = uid;
  2825. entitys.userName = userName;
  2826. entitys.designerType = 1;
  2827. entitys.designerTypeText = "内部设计师";
  2828. entitys.price = Convert.ToDouble(GetPostString("price"));
  2829. entitys.designNum = GetPostInt("designNum");
  2830. entitys.modifyNum = GetPostInt("modifyNum");
  2831. entitys.designSize = GetPostString("designSize");
  2832. entitys.modifySize = GetPostString("modifySize");
  2833. if (CeErpDesignerBill.GetByTid("ctid") == null)
  2834. {
  2835. entitys.create_time = DateTime.Now;
  2836. entitys.create_u_id = uid;
  2837. entitys.create_u_name = userName;
  2838. entitys.Save();
  2839. }
  2840. else
  2841. {
  2842. entitys.update_time = DateTime.Now;
  2843. entitys.update_u_id = uid;
  2844. entitys.update_u_name = userName;
  2845. entitys.Update();
  2846. }
  2847. }
  2848. }
  2849. }
  2850. commonHelper.UpdateRelationOrder(entity.ctid); //更新补差价单
  2851. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始设计", entity.OrderState);
  2852. LogHelper.addDesignerBillLog(entity.ctid, CurrentUser.UserID, "评估设计费", CurrentUser.UserName, 0);
  2853. if (suname != "")
  2854. {
  2855. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  2856. }
  2857. commonHelper.getCytPrice(entity);
  2858. returnSuccessMsg("操作成功!");
  2859. return;
  2860. }
  2861. returnErrorMsg("找不到记录");
  2862. }
  2863. }
  2864. public void upload_erp_filecomplete()
  2865. {
  2866. if (UrlPostParmsCheck("ctid"))
  2867. {
  2868. string eid = GetPostString("ctid");
  2869. CeErpTradeCell entity = null;
  2870. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  2871. if (entity != null)
  2872. {
  2873. entity.OrderState = 5; //设计完成
  2874. entity.Update();
  2875. returnSuccessMsg(eid + "上传成功,设计完成!");
  2876. return;
  2877. }
  2878. returnErrorMsg("找不到订单记录");
  2879. }
  2880. }
  2881. public void get_erp_designovertimelist()
  2882. {
  2883. DataStruct dStruct = GetPostStruct();
  2884. List<string> lw = new List<string>();
  2885. string tid = GetPostString("ctid");
  2886. if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}' or orderSn='{0}')", tid));
  2887. string shopname = GetPostString("shopname");
  2888. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  2889. string buyernick = GetPostString("buyer_nick");
  2890. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  2891. string ResponsibleMan = GetPostString("responsible");
  2892. if (ResponsibleMan.Length > 0) lw.Add(string.Format("ResponsibleMan like '%{0}%'", ResponsibleMan));
  2893. string date1 = GetPostString("date1");
  2894. string date2 = GetPostString("date2");
  2895. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  2896. if (dw.Length > 0) lw.Add(dw);
  2897. string price1 = GetPostString("price1");
  2898. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  2899. string price2 = GetPostString("price2");
  2900. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  2901. string orderState = GetPostString("orderState");
  2902. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  2903. string sellermemo = GetPostString("seller_memo");
  2904. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  2905. lw.Add(string.Format("UnusualTag=3"));
  2906. lw.Add(string.Format("IsRefund<={0}", 1));
  2907. dStruct.Order = "WaitDesignTime desc";
  2908. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  2909. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  2910. writeGridDataTableJson(dStruct.TotalCount, dt);
  2911. }
  2912. //设计管理 获取抢单大厅列表
  2913. public void get_erp_grabinglist()
  2914. {
  2915. int maxPrice = CurrentUser.UserPost.Post.OrderAmountLimit;
  2916. DataTable org = CeErpOrganization.Get(CurrentUser.UserPost.OrgID);
  2917. bool oldOrder = false;
  2918. if (org != null)
  2919. {
  2920. oldOrder = Convert.ToBoolean(org.Rows[0]["OldOrder"]);
  2921. }
  2922. string sql = string.Format("select * from view_cell where OrderState = 2 and IsSample <> 2 and IsRefund<=0 and DesignUserId = 0");
  2923. sql += !oldOrder ? " and IsOldCustomer != 1 " : "";
  2924. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2925. Dictionary<string, Dictionary<string, int>> map = new Dictionary<string, Dictionary<string, int>>();
  2926. //先处理订单数据
  2927. if (dt.Rows.Count > 0)
  2928. {
  2929. Dictionary<string, int> design = null;
  2930. int count = 0;
  2931. foreach (DataRow row in dt.Rows)
  2932. {
  2933. if (map.ContainsKey(row["ShopId"].ToString()))
  2934. {
  2935. map.TryGetValue(row["ShopId"].ToString(), out design);
  2936. }
  2937. else
  2938. {
  2939. design = new Dictionary<string, int>();
  2940. }
  2941. if (design.ContainsKey(row["ProductId"].ToString()))
  2942. {
  2943. design.TryGetValue(row["ProductId"].ToString(), out count);
  2944. }
  2945. count++;
  2946. design[row["ProductId"].ToString()] = count;
  2947. map[row["ShopId"].ToString()] = design;
  2948. }
  2949. }
  2950. sql = string.Format("select * from Ce_ErpDesignInfo where type=1 and tarId={0}", CurrentUser.User.ID);
  2951. DataTable design_dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  2952. //把店铺排序和技能排序分类
  2953. Dictionary<string, List<string>> shop_orders = new Dictionary<string, List<string>>();
  2954. Dictionary<string, Dictionary<string, string>> design_orders = new Dictionary<string, Dictionary<string, string>>();
  2955. if (design_dt.Rows.Count > 0)
  2956. {
  2957. Dictionary<string, string> design = null;
  2958. List<string> shopIds = null;
  2959. foreach (DataRow row in design_dt.Rows)
  2960. {
  2961. if ("0".Equals(row["designId"].ToString()))
  2962. {
  2963. if (shop_orders.ContainsKey(row["orders"].ToString()))
  2964. {
  2965. shop_orders.TryGetValue(row["orders"].ToString(), out shopIds);
  2966. }
  2967. else
  2968. {
  2969. shopIds = new List<string>();
  2970. }
  2971. shopIds.Add(row["shopId"].ToString());
  2972. shop_orders[row["orders"].ToString()] = shopIds;
  2973. }
  2974. else
  2975. {
  2976. if (design_orders.ContainsKey(row["shopId"].ToString()))
  2977. {
  2978. design_orders.TryGetValue(row["shopId"].ToString(), out design);
  2979. }
  2980. else
  2981. {
  2982. design = new Dictionary<string, string>();
  2983. }
  2984. design[row["orders"].ToString()] = row["designId"].ToString();
  2985. design_orders[row["shopId"].ToString()] = design;
  2986. }
  2987. }
  2988. //处理成key value后根据key排序
  2989. shop_orders = shop_orders.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2990. foreach (List<string> val in shop_orders.Values)
  2991. {
  2992. if (val != null)
  2993. {
  2994. foreach (string key in val)
  2995. {
  2996. if (design_orders.ContainsKey(key.ToString()))
  2997. {
  2998. design_orders[key] = design_orders[key].OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
  2999. }
  3000. }
  3001. }
  3002. }
  3003. }
  3004. //校验哪个优先级有订单
  3005. Dictionary<string, string> designIds = new Dictionary<string, string>();
  3006. foreach (string key in shop_orders.Keys)
  3007. {
  3008. List<string> ids = null;
  3009. shop_orders.TryGetValue(key, out ids);
  3010. //id为shopid
  3011. foreach (string id in ids)
  3012. {
  3013. Dictionary<string, int> list = null;
  3014. Dictionary<string, string> desing = null;
  3015. map.TryGetValue(id, out list);
  3016. design_orders.TryGetValue(id, out desing);
  3017. if (list != null && desing != null)
  3018. {
  3019. foreach (var item in desing)
  3020. {
  3021. int count = 0;
  3022. if (list.ContainsKey(item.Value))
  3023. {
  3024. list.TryGetValue(item.Value, out count);
  3025. if (count > 0)
  3026. {
  3027. designIds[id] = item.Value;
  3028. break;
  3029. }
  3030. }
  3031. }
  3032. }
  3033. }
  3034. if (designIds.Count > 0)
  3035. {
  3036. break;
  3037. }
  3038. }
  3039. DataTable table = new DataTable();
  3040. table.Columns.Add("tid", typeof(string));
  3041. table.Columns.Add("ctid", typeof(string));
  3042. table.Columns.Add("seller_nick", typeof(string));
  3043. table.Columns.Add("productName", typeof(string));
  3044. table.Columns.Add("pay_time", typeof(string));
  3045. table.Columns.Add("seller_memo", typeof(string));
  3046. if (designIds.Count > 0)
  3047. {
  3048. string shopId = "";
  3049. string productId = "";
  3050. foreach (var designInfo in designIds)
  3051. {
  3052. shopId = designInfo.Key;
  3053. productId = designInfo.Value;
  3054. CeErpShop ceErpShop = CeErpShop.Get(shopId);
  3055. CeErpProduct ceErpProduct = CeErpProduct.Get(productId);
  3056. if (dt.Rows.Count > 0)
  3057. {
  3058. foreach (DataRow row in dt.Rows)
  3059. {
  3060. if (shopId.Equals(row["shopId"].ToString()) && productId.Equals(row["productId"].ToString()))
  3061. {
  3062. DataRow data = table.NewRow();
  3063. data["ctid"] = row["ctid"].ToString();
  3064. data["tid"] = row["tid"].ToString();
  3065. data["seller_nick"] = ceErpShop.ShopName;
  3066. data["pay_time"] = row["pay_time"].ToString();
  3067. data["seller_memo"] = row["seller_memo"].ToString();
  3068. data["productName"] = ceErpProduct.PType;
  3069. table.Rows.Add(data);
  3070. }
  3071. }
  3072. }
  3073. }
  3074. }
  3075. writeGridDataTableJson(table.Rows.Count, table);
  3076. }
  3077. private object rushLockObject = new object();
  3078. public void set_erp_grabingorder()
  3079. {
  3080. if (UrlPostParmsCheck("ctid"))
  3081. {
  3082. int total = CurrentUser.User.Person.Total;
  3083. int userId = CurrentUser.User.ID;
  3084. int noFinish = CurrentUser.User.Person.NoFinish;
  3085. int finalization = CurrentUser.User.Person.Finalization;
  3086. string eids = GetPostString("ctid");
  3087. string key = "RushKey_" + userId;
  3088. int count = 0;
  3089. if (erpRedis.RedisHelper.KeyExists(key))
  3090. {
  3091. string redisCount = erpRedis.RedisHelper.StringGet(key);
  3092. if (redisCount != null)
  3093. {
  3094. count = Convert.ToInt32(redisCount);
  3095. }
  3096. }
  3097. if (count >= total)
  3098. {
  3099. returnErrorMsg("半小时内已经抢" + total + "单");
  3100. return;
  3101. }
  3102. string[] ctidlist = eids.Split(',');
  3103. if (count + ctidlist.Length > total)
  3104. {
  3105. returnErrorMsg("选择单数超过半小时可抢数量," + "已抢:" + count + "单");
  3106. return;
  3107. }
  3108. int itag = 0;
  3109. lock (rushLockObject)
  3110. {
  3111. if (ctidlist.Length > 0)
  3112. {
  3113. string[] dtList = new string[ctidlist.Length];
  3114. for (int i = 0; i < ctidlist.Length; i++)
  3115. {
  3116. dtList[i] = "'" + ctidlist[i] + "'";
  3117. }
  3118. 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"));
  3119. DataTable dt_user = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  3120. if (dt_user.Rows.Count > 0)
  3121. {
  3122. int doing = 0;//未定稿
  3123. int finish = 0;//已完成
  3124. foreach (DataRow dr in dt_user.Rows)
  3125. {
  3126. if (Convert.ToInt32(dr["OrderState"]) == 3 || Convert.ToInt32(dr["OrderState"]) == 4)
  3127. {
  3128. doing++;
  3129. }
  3130. else
  3131. {
  3132. finish++;
  3133. }
  3134. }
  3135. if (doing >= noFinish)
  3136. {
  3137. returnErrorMsg(doing + "未定稿数量,无法继续抢单");
  3138. return;
  3139. }
  3140. if (doing + finish >= total && finalization > 0 && ((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) < finalization)
  3141. {
  3142. returnErrorMsg(((Convert.ToDecimal(finish) / Convert.ToDecimal(dt_user.Rows.Count)) * 100) + "未定稿率,无法继续抢单");
  3143. return;
  3144. }
  3145. }
  3146. //校验选择单子状态
  3147. string sql = string.Format("select ctid,OrderState from CE_ErpTradeCell where ctid in (" + string.Join(",", dtList) + ")");
  3148. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  3149. if (dt.Rows.Count > 0)
  3150. {
  3151. List<string> list = new List<string>();
  3152. foreach (DataRow dr in dt.Rows)
  3153. {
  3154. if (Convert.ToInt32(dr["OrderState"]) != 2)
  3155. {
  3156. list.Add(dr["ctid"].ToString());
  3157. }
  3158. }
  3159. if (list.Count > 0)
  3160. {
  3161. returnErrorMsg(string.Join(",", list) + "状态不可抢单,请重新选择!");
  3162. return;
  3163. }
  3164. }
  3165. foreach (string ctid in ctidlist)
  3166. {
  3167. CeErpTradeCell entity = null;
  3168. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3169. if (entity != null)
  3170. {
  3171. entity.OrderState = 3;
  3172. entity.DesignUserId = CurrentUser.UserID;
  3173. entity.WaitDesignTime = DateTime.Now;
  3174. entity.StartDesignTime = DateTime.Now;
  3175. entity.Update();
  3176. commonHelper.UpdateRelationOrder(entity.ctid);
  3177. commonHelper.UpdateSameOrderToDesigner(entity, CurrentUser.UserID);
  3178. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "抢单成功", entity.OrderState);
  3179. itag++;
  3180. }
  3181. }
  3182. }
  3183. }
  3184. count += ctidlist.Length;
  3185. erpRedis.RedisHelper.StringSet(key, count.ToString(), TimeSpan.FromMinutes(30));
  3186. if (itag == 0)
  3187. returnErrorMsg("没有找到相关订单");
  3188. else
  3189. returnSuccessMsg("抢单成功!");
  3190. return;
  3191. }
  3192. }
  3193. public void get_erp_waitorderlist()
  3194. {
  3195. DataStruct dStruct = GetPostStruct();
  3196. List<string> lw = new List<string>();
  3197. string tid = GetPostString("ctid");
  3198. if (tid.Length > 0)
  3199. {
  3200. string select_tid = getTidByCtid(tid);
  3201. lw.Add(string.Format("tid='{0}'", select_tid));
  3202. }
  3203. string shopname = GetPostString("shopname");
  3204. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3205. string buyernick = GetPostString("buyer_nick");
  3206. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3207. string customer = GetPostString("customer");
  3208. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3209. string design = GetPostString("design");
  3210. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3211. string orderState = GetPostString("orderState");
  3212. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3213. string supplier = GetPostString("supplier");
  3214. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3215. string sellermemo = GetPostString("seller_memo");
  3216. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3217. string otherMemo = GetPostString("otherMemo");
  3218. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3219. string address = GetPostString("address");
  3220. 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));
  3221. string date1 = GetPostString("date1");
  3222. string date2 = GetPostString("date2");
  3223. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3224. if (dw.Length > 0) lw.Add(dw);
  3225. string price1 = GetPostString("price1");
  3226. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3227. string price2 = GetPostString("price2");
  3228. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3229. lw.Add(string.Format("IsVerifyToSupplier=0"));//审核给供应商的不显示
  3230. lw.Add(string.Format("IsSample != 2 "));
  3231. lw.Add(string.Format("OrderState = 5 "));
  3232. lw.Add(string.Format("IsRefund<={0}", 1));
  3233. dStruct.Order = "IsReturn desc,IsUrgency desc,FinishDesignTime asc";
  3234. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3235. string pagesize = GetPostString("pagesize");
  3236. if (pagesize != null)
  3237. {
  3238. dStruct.PageSize = 200;
  3239. }
  3240. DataTable dt = WebCache.GetData("view_Waitorderlist", dStruct);
  3241. if (dt != null)
  3242. {
  3243. foreach (DataRow dr in dt.Rows)
  3244. {
  3245. 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();
  3246. if (Convert.IsDBNull(dr["SupplierId"]) || Convert.ToInt32(dr["SupplierId"]) == 0)
  3247. {
  3248. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(dr["ctid"].ToString());
  3249. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  3250. entity.SupplierId = suid;
  3251. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  3252. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  3253. entity.Update();
  3254. }
  3255. }
  3256. }
  3257. writeGridDataTableJson(dStruct.TotalCount, dt);
  3258. }
  3259. public void get_erp_supplierwaitorderlist()
  3260. {
  3261. DataStruct dStruct = GetPostStruct();
  3262. List<string> lw = new List<string>();
  3263. string tid = GetPostString("ctid");
  3264. if (tid.Length > 0)
  3265. {
  3266. string select_tid = getTidByCtid(tid);
  3267. lw.Add(string.Format("tid='{0}'", select_tid));
  3268. }
  3269. string shopname = GetPostString("shopname");
  3270. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3271. string sellermemo = GetPostString("seller_memo");
  3272. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3273. string date1 = GetPostString("date1");
  3274. string date2 = GetPostString("date2");
  3275. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  3276. if (dw.Length > 0) lw.Add(dw);
  3277. lw.Add(string.Format("OrderState = 5 "));
  3278. lw.Add(string.Format("IsVerifyToSupplier=1"));
  3279. if (PKey != "admin" && CurrentUser.UserPost.Post.Code != "SysAdmin" && CurrentUser.UserPost.Post.Code != "Place" && CurrentUser.UserPost.Post.Code != "PlaceMr")
  3280. {
  3281. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3282. }
  3283. string supplier = GetPostString("supplier");
  3284. if ((PKey == "admin" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserPost.Post.Code == "Place" || CurrentUser.UserPost.Post.Code == "PlaceMr") && supplier.Length > 0)
  3285. {
  3286. lw.Add(string.Format("SupplierName = '{0}'", supplier));
  3287. }
  3288. lw.Add(string.Format("IsRefund<={0}", 1));
  3289. dStruct.Order = "FinishDesignTime desc";
  3290. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3291. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3292. if (dt != null)
  3293. {
  3294. foreach (DataRow dr in dt.Rows)
  3295. {
  3296. 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();
  3297. }
  3298. }
  3299. writeGridDataTableJson(dStruct.TotalCount, dt);
  3300. }
  3301. public void upd_erp_verifytosupplier()
  3302. {
  3303. if (UrlPostParmsCheck("ctid"))
  3304. {
  3305. string eids = GetPostString("ctid");
  3306. CeErpTradeCell entity = null;
  3307. string[] eidsList = eids.Split(',');
  3308. if (eidsList.Length <= 0)
  3309. {
  3310. returnErrorMsg("订单号不能空");
  3311. return;
  3312. }
  3313. List<string> tLst = new List<string>();
  3314. foreach (string ctidstr in eidsList)
  3315. {
  3316. tLst.Add("'" + ctidstr + "'");
  3317. CeErpDataSendOrderInfo.createObject(ctidstr);
  3318. }
  3319. string needtids = string.Join(",", tLst.ToArray());
  3320. StringBuilder sql = new StringBuilder();
  3321. //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
  3322. sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1} where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
  3323. sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
  3324. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3325. returnSuccessMsg("操作成功!");
  3326. return;
  3327. /**foreach (string ctidstr in eidsList)
  3328. {
  3329. entity = CeErpTradeCell.GetByCtid(ctidstr);
  3330. if (entity != null)
  3331. {
  3332. if (entity.SupplierId == 0)
  3333. {
  3334. continue;
  3335. }
  3336. entity.IsVerifyToSupplier = true;
  3337. if (entity.IsReturn == 1) //1是供应商打回
  3338. {
  3339. entity.IsReturn = 0;
  3340. }
  3341. entity.FinishPlaceTime = DateTime.Now;
  3342. entity.PlaceUserId = CurrentUser.UserID;
  3343. entity.Update();
  3344. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核给供应商", entity.OrderState);
  3345. }
  3346. }
  3347. returnSuccessMsg("操作成功!");
  3348. return;**/
  3349. }
  3350. }
  3351. public void upd_erp_supplierback()
  3352. {
  3353. if (UrlPostParmsCheck("ctid"))
  3354. {
  3355. string eid = GetPostString("ctid");
  3356. string reason = GetPostString("returnreason");
  3357. CeErpTradeCell entity = null;
  3358. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3359. if (entity != null)
  3360. {
  3361. if (CurrentUser.UserPost.Post.Code != "Supplier")//不是供应商打回
  3362. {
  3363. string key = "return_order_" + entity.SupplierId;
  3364. List<string> list = new List<string>();
  3365. if (RedisHelper.HasKey(key))
  3366. {
  3367. object data = RedisHelper.StringGet(key);
  3368. list = Convert.ToString(data).Split(',').ToList();
  3369. }
  3370. list.Add(eid);
  3371. RedisHelper.StringSet(key, string.Join(",", list));
  3372. }
  3373. entity.IsVerifyToSupplier = false;
  3374. entity.IsReturn = 1;
  3375. entity.ReturnTime = DateTime.Now;
  3376. entity.ReturnReason = reason;
  3377. if (entity.OrderState == 6)
  3378. {
  3379. entity.OrderState = 5;
  3380. }
  3381. entity.Update();
  3382. CeErpSukuraData.createInfo(entity.ctid, 5);
  3383. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  3384. returnSuccessMsg("操作成功!");
  3385. return;
  3386. }
  3387. returnErrorMsg("找不到订单记录");
  3388. }
  3389. }
  3390. public void upd_erp_toaftersaleorder()
  3391. {
  3392. if (UrlPostParmsCheck("ctid"))
  3393. {
  3394. string eid = GetPostString("ctid");
  3395. string reason = GetPostString("returnreason");
  3396. CeErpTradeCell entity = null;
  3397. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3398. if (entity != null)
  3399. {
  3400. if (entity.isAfterSaleOrder != 1)
  3401. {
  3402. returnErrorMsg("带S的售后单才能打回给售后");
  3403. return;
  3404. }
  3405. if (entity.OrderState >= 5)
  3406. {
  3407. returnErrorMsg("已经设计完成了不能打回给售后");
  3408. return;
  3409. }
  3410. entity.OrderState = 0;
  3411. entity.IsReturn = 3;
  3412. entity.ReturnTime = DateTime.Now;
  3413. entity.UpdateTime = DateTime.Now;
  3414. entity.ReturnReason = reason;
  3415. entity.Update();
  3416. CeErpSukuraData.createInfo(entity.ctid, 5);
  3417. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从待设计打回到售后", entity.OrderState);
  3418. returnSuccessMsg("操作成功!");
  3419. return;
  3420. }
  3421. returnErrorMsg("找不到订单记录");
  3422. }
  3423. }
  3424. public void upd_erp_aftersaletodesign()
  3425. {
  3426. if (UrlPostParmsCheck("ctid"))
  3427. {
  3428. string eid = GetPostString("ctid");
  3429. CeErpTradeCell entity = null;
  3430. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3431. if (entity != null)
  3432. {
  3433. entity.OrderState = 3;
  3434. entity.IsReturn = 0;
  3435. entity.UpdateTime = DateTime.Now;
  3436. entity.Update();
  3437. CeErpSukuraData.createInfo(entity.ctid, 5);
  3438. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后单从打回售后恢复到设计", entity.OrderState);
  3439. returnSuccessMsg("操作成功!");
  3440. return;
  3441. }
  3442. returnErrorMsg("找不到订单记录");
  3443. }
  3444. }
  3445. public void assign_erp_supplier()
  3446. {
  3447. if (UrlPostParmsCheck("ctid"))
  3448. {
  3449. string eids = GetPostString("ctid");
  3450. int sid = GetPostInt("SupplierName");
  3451. string fromTag = GetPostString("tag");
  3452. string[] eidList = eids.Split(',');
  3453. if (eidList.Length <= 0)
  3454. {
  3455. returnErrorMsg("指派不能为空");
  3456. return;
  3457. }
  3458. string errMsg = "";
  3459. string suname = commonHelper.getSupplierNameById(sid);
  3460. foreach (string ctid in eidList)
  3461. {
  3462. CeErpTradeCell entity = null;
  3463. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3464. if (entity != null)
  3465. {
  3466. if (fromTag == "waitingorder" && entity.OrderState >= 6)
  3467. {
  3468. errMsg += (ctid + "指派失败!!!");
  3469. continue;
  3470. }
  3471. entity.SupplierId = sid;
  3472. entity.Update();
  3473. commonHelper.UpdateRelationOrder(entity.ctid);
  3474. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "指派供应商:" + suname, entity.OrderState);
  3475. if (entity.OrderState >= 6)
  3476. {
  3477. //if (entity.MakeSupplier.IndexOf(",") != -1)
  3478. //{
  3479. // string msl = entity.MakeSupplier;
  3480. // string[] mslist = msl.Split(',');
  3481. // 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);
  3482. // DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3483. //}
  3484. //else
  3485. //{
  3486. StringBuilder sql = new StringBuilder();
  3487. 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);
  3488. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  3489. //}
  3490. }
  3491. }
  3492. else
  3493. {
  3494. continue;
  3495. }
  3496. }
  3497. if (errMsg.Length > 0)
  3498. {
  3499. returnErrorMsg(errMsg);
  3500. return;
  3501. }
  3502. returnSuccessMsg("操作成功!");
  3503. return;
  3504. }
  3505. }
  3506. public void assign_erp_makesupplier()
  3507. {
  3508. if (UrlPostParmsCheck("ctid"))
  3509. {
  3510. string eids = GetPostString("ctid");
  3511. string sname = GetPostString("SupplierName");
  3512. string[] eidList = eids.Split(',');
  3513. if (eidList.Length <= 0)
  3514. {
  3515. returnErrorMsg("指派不能为空");
  3516. return;
  3517. }
  3518. List<string> tLst = new List<string>();
  3519. foreach (string ctid in eidList)
  3520. {
  3521. CeErpTradeCell entity = null;
  3522. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3523. if (entity != null)
  3524. {
  3525. entity.MakeSupplier = sname;
  3526. entity.Update();
  3527. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "设置制作供应商:" + sname, entity.OrderState);
  3528. tLst.Add("'" + ctid + "'");
  3529. }
  3530. else
  3531. {
  3532. continue;
  3533. }
  3534. }
  3535. string ctids = string.Join(",", tLst.ToArray());
  3536. StringBuilder sql2 = new StringBuilder();
  3537. sql2.AppendFormat("update ce_erptradecell2 set MakeSupplier='{0}' where ctid in ({1}) ", sname, ctids);
  3538. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3539. returnSuccessMsg("操作成功!");
  3540. return;
  3541. }
  3542. }
  3543. public void ins_erp_returnreason()
  3544. {
  3545. if (UrlPostParmsCheck("ctid"))
  3546. {
  3547. string eid = GetPostString("ctid");
  3548. CeErpTradeCell entity = null;
  3549. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3550. string userpost = CurrentUser.UserPost.Post.Code;
  3551. if (entity != null)
  3552. {
  3553. bool isPlace = false;
  3554. if (entity.OrderState > 6)
  3555. {
  3556. returnErrorMsg("已发货无法打回!");
  3557. return;
  3558. }
  3559. if (entity.OrderState == 6)
  3560. {
  3561. isPlace = true;
  3562. }
  3563. bool isNeedUpdateCell2 = false;
  3564. if (entity.OrderState >= 6)
  3565. {
  3566. isNeedUpdateCell2 = true;
  3567. }
  3568. int returnTag = 2;
  3569. if (userpost == "Supplier")
  3570. {
  3571. returnTag = 1;
  3572. }
  3573. int toType = GetPostInt("totype");
  3574. string fromType = "3";
  3575. if (entity.OrderState < 5)
  3576. {
  3577. fromType = "3";
  3578. }
  3579. else
  3580. {
  3581. fromType = "4";
  3582. }
  3583. if (entity.IsXianHuo == 0)
  3584. {
  3585. if (returnTag == 2)
  3586. {
  3587. if (toType == 1)
  3588. {
  3589. entity.OrderState = 0;
  3590. entity.ReturnUserType = 1;
  3591. string clearman = GetPostString("clearman");
  3592. if (!string.IsNullOrEmpty(clearman))
  3593. {
  3594. entity.DesignUserId = 0;
  3595. }
  3596. }
  3597. else
  3598. {
  3599. entity.OrderState = 3;
  3600. entity.ReturnUserType = 2;
  3601. }
  3602. entity.IsReadTag = 1;
  3603. }
  3604. else if (returnTag == 1)
  3605. {
  3606. entity.OrderState = 5;
  3607. }
  3608. entity.IsVerifyToSupplier = false;
  3609. }
  3610. if (entity.IsXianHuo == 1)
  3611. {
  3612. entity.OrderState = 5;
  3613. }
  3614. entity.UnusualTag = 0;
  3615. entity.UnusualTime = null;
  3616. entity.UnusualCon = "";
  3617. entity.IsReturn = returnTag;
  3618. entity.ReturnTime = DateTime.Now;
  3619. entity.UpdateTime = DateTime.Now;
  3620. entity.ReturnReason = GetPostString("returnreason");
  3621. entity.Update();
  3622. if (entity.OrderState == 3)
  3623. {
  3624. ApiVo apiVo = new ApiVo();
  3625. apiVo.orderNumber = entity.ctid;
  3626. apiVo.actionName = "rebutDesign";
  3627. apiVo.orderRemarks = entity.ReturnReason;
  3628. designHelper.API_WorkCore(apiVo);//rebutDesign
  3629. }
  3630. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  3631. if (ceErpTradeCellExtend != null && ceErpTradeCellExtend.orderFrom == 30)
  3632. {
  3633. dataHelper.api_orderBack(entity.ctid, fromType, entity.ReturnReason);
  3634. }
  3635. CeErpSukuraData.createInfo(entity.ctid, 5);
  3636. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3637. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3638. if (isPlace)
  3639. {
  3640. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", entity.ctid);
  3641. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  3642. if (dth != null && dth.Rows.Count > 0)
  3643. {
  3644. dataSendOrderBean dataSendOrderBean = null;
  3645. foreach (DataRow item in dth.Rows)
  3646. {
  3647. try
  3648. {
  3649. dataSendOrderBean = new dataSendOrderBean();
  3650. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  3651. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  3652. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  3653. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  3654. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  3655. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  3656. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  3657. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  3658. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  3659. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  3660. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  3661. dataSendOrderBean.Radio1723534706288 = "打回";
  3662. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  3663. if (result != null)
  3664. {
  3665. if ("0".Equals(result.errcode))
  3666. {
  3667. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  3668. }
  3669. else
  3670. {
  3671. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  3672. }
  3673. }
  3674. }
  3675. catch (Exception ex)
  3676. {
  3677. }
  3678. }
  3679. }
  3680. }
  3681. if (isNeedUpdateCell2)
  3682. {
  3683. if (entity.MakeSupplier.IndexOf(",") != -1)
  3684. {
  3685. StringBuilder sql2 = new StringBuilder();
  3686. 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);
  3687. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3688. }
  3689. else
  3690. {
  3691. StringBuilder sql2 = new StringBuilder();
  3692. 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);
  3693. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3694. }
  3695. }
  3696. returnSuccessMsg("操作成功!");
  3697. return;
  3698. }
  3699. returnErrorMsg("找不到订单记录");
  3700. }
  3701. }
  3702. public void cyt_erp_returnreason()
  3703. {
  3704. if (UrlPostParmsCheck("ctid"))
  3705. {
  3706. string eid = GetPostString("ctid");
  3707. CeErpTradeCell entity = null;
  3708. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  3709. string userpost = CurrentUser.UserPost.Post.Code;
  3710. if (entity != null)
  3711. {
  3712. if (entity.OrderState > 6)
  3713. {
  3714. returnErrorMsg("已发货无法打回!");
  3715. return;
  3716. }
  3717. JObject jsonObject = new JObject
  3718. {
  3719. { "Userid", "77886" },
  3720. { "Pwd", "lt666888" },
  3721. { "LTOrderId",eid }
  3722. };
  3723. string response = HttpPost(" http://www.kiy.cn/m-mobile/autobaojia/LTCancelOrder", jsonObject.ToString());
  3724. JObject jsonObjects = JObject.Parse(response);
  3725. string msg = (string)jsonObjects["msg"];
  3726. if (msg != "取消成功")
  3727. {
  3728. returnErrorMsg(msg);
  3729. return;
  3730. }
  3731. bool isNeedUpdateCell2 = false;
  3732. if (entity.OrderState >= 6)
  3733. {
  3734. isNeedUpdateCell2 = true;
  3735. }
  3736. int returnTag = 2;
  3737. if (userpost == "Supplier")
  3738. {
  3739. returnTag = 1;
  3740. }
  3741. if (entity.IsXianHuo == 0)
  3742. {
  3743. if (returnTag == 2)
  3744. {
  3745. int toType = GetPostInt("totype");
  3746. if (toType == 1)
  3747. {
  3748. entity.OrderState = 0;
  3749. entity.ReturnUserType = 1;
  3750. }
  3751. else
  3752. {
  3753. entity.OrderState = 4;
  3754. entity.ReturnUserType = 2;
  3755. }
  3756. entity.IsReadTag = 1;
  3757. }
  3758. else if (returnTag == 1)
  3759. {
  3760. entity.OrderState = 5;
  3761. }
  3762. entity.IsVerifyToSupplier = false;
  3763. }
  3764. entity.UnusualTag = 0;
  3765. entity.UnusualTime = null;
  3766. entity.UnusualCon = "";
  3767. entity.IsReturn = returnTag;
  3768. entity.ReturnTime = DateTime.Now;
  3769. entity.ReturnReason = GetPostString("returnreason");
  3770. entity.Update();
  3771. if (entity.OrderState == 4)
  3772. {
  3773. ApiVo apiVo = new ApiVo();
  3774. apiVo.orderNumber = entity.ctid;
  3775. apiVo.actionName = "rebutDesign";
  3776. apiVo.orderRemarks = entity.ReturnReason;
  3777. designHelper.API_WorkCore(apiVo);//rebutDesign
  3778. }
  3779. CeErpSukuraData.createInfo(entity.ctid, 5);
  3780. apiDesign.API_GetPrintData_ModifyOrder(entity.ctid, entity.seller_memo, false, true, entity.ReturnReason);
  3781. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退单:" + entity.ReturnReason, entity.OrderState);
  3782. if (isNeedUpdateCell2)
  3783. {
  3784. if (entity.MakeSupplier.IndexOf(",") != -1)
  3785. {
  3786. StringBuilder sql2 = new StringBuilder();
  3787. 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);
  3788. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3789. }
  3790. else
  3791. {
  3792. StringBuilder sql2 = new StringBuilder();
  3793. 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);
  3794. DbHelper.DbConn.ExecuteNonQuery(sql2.ToString());
  3795. }
  3796. }
  3797. returnSuccessMsg("操作成功!");
  3798. return;
  3799. }
  3800. returnErrorMsg("找不到订单记录");
  3801. }
  3802. }
  3803. public void upd_erp_xianhuoreturntag()
  3804. {
  3805. if (UrlPostParmsCheck("ctid"))
  3806. {
  3807. string eids = GetPostString("ctid");
  3808. string[] ctids = eids.Split(',');
  3809. foreach (string ctid in ctids)
  3810. {
  3811. CeErpTradeCell entity = null;
  3812. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  3813. if (entity != null)
  3814. {
  3815. entity.IsReturn = 0;
  3816. entity.Update();
  3817. CeErpSukuraData.createInfo(entity.ctid, 5);
  3818. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "打回现货恢复到待发货", entity.OrderState);
  3819. }
  3820. }
  3821. returnSuccessMsg("操作成功!");
  3822. return;
  3823. }
  3824. }
  3825. public void get_erp_waitdeliverylist()
  3826. {
  3827. DataStruct dStruct = GetPostStruct();
  3828. List<string> lw = new List<string>();
  3829. string tid = GetPostString("ctid");
  3830. if (tid.Length > 0)
  3831. {
  3832. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3833. if (tid.Length > 5)
  3834. {
  3835. List<string> tids = getTidByCtidLike(tid);
  3836. if (tids.Count > 0 && tids.Count < 10)
  3837. {
  3838. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3839. }
  3840. }
  3841. lw.Add(tid_sql);
  3842. }
  3843. string shopname = GetPostString("shopname");
  3844. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3845. string buyernick = GetPostString("buyer_nick");
  3846. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3847. //if (tid.Length == 0 && buyernick.Length == 0)
  3848. //{
  3849. // lw.Add(string.Format("IsRefund<={0}", 1));
  3850. //}
  3851. string customer = GetPostString("customer");
  3852. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3853. string design = GetPostString("design");
  3854. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3855. string orderState = GetPostString("orderState");
  3856. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3857. string address = GetPostString("address");
  3858. 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));
  3859. string sellermemo = GetPostString("seller_memo");
  3860. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3861. string supplier = GetPostString("supplier");
  3862. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3863. string OrderArea = GetPostString("order_area");
  3864. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3865. string placedate1 = GetPostString("placedate1");
  3866. string placedate2 = GetPostString("placedate2");
  3867. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3868. if (fdw.Length > 0) lw.Add(fdw);
  3869. string price1 = GetPostString("price1");
  3870. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3871. string price2 = GetPostString("price2");
  3872. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3873. string unusualCon = GetPostString("unusualcon");
  3874. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3875. string otherMemo = GetPostString("otherMemo");
  3876. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3877. string posTag = CurrentUser.UserPost.Post.Code;
  3878. if (posTag == "Supplier")
  3879. {
  3880. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3881. }
  3882. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  3883. lw.Add(string.Format("type != 'PDD' "));
  3884. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3885. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3886. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3887. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3888. writeGridDataTableJson(dStruct.TotalCount, dt);
  3889. }
  3890. public void get_erp_changedeliverylist()
  3891. {
  3892. DataStruct dStruct = GetPostStruct();
  3893. List<string> lw = new List<string>();
  3894. string tid = GetPostString("ctid");
  3895. if (tid.Length > 0)
  3896. {
  3897. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3898. if (tid.Length > 5)
  3899. {
  3900. List<string> tids = getTidByCtidLike(tid);
  3901. if (tids.Count > 0 && tids.Count < 10)
  3902. {
  3903. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3904. }
  3905. }
  3906. lw.Add(tid_sql);
  3907. }
  3908. string shopname = GetPostString("shopname");
  3909. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3910. string buyernick = GetPostString("buyer_nick");
  3911. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3912. //if (tid.Length == 0 && buyernick.Length == 0)
  3913. //{
  3914. // lw.Add(string.Format("IsRefund<={0}", 1));
  3915. //}
  3916. string customer = GetPostString("customer");
  3917. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  3918. string design = GetPostString("design");
  3919. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  3920. string orderState = GetPostString("orderState");
  3921. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  3922. string address = GetPostString("address");
  3923. 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));
  3924. string sellermemo = GetPostString("seller_memo");
  3925. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  3926. string supplier = GetPostString("supplier");
  3927. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  3928. string OrderArea = GetPostString("order_area");
  3929. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  3930. string placedate1 = GetPostString("placedate1");
  3931. string placedate2 = GetPostString("placedate2");
  3932. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  3933. if (fdw.Length > 0) lw.Add(fdw);
  3934. string price1 = GetPostString("price1");
  3935. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  3936. string price2 = GetPostString("price2");
  3937. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  3938. string unusualCon = GetPostString("unusualcon");
  3939. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  3940. string otherMemo = GetPostString("otherMemo");
  3941. if (otherMemo.Length > 0) lw.Add(string.Format("otherMemo like '%{0}%'", otherMemo));
  3942. string posTag = CurrentUser.UserPost.Post.Code;
  3943. if (posTag == "Supplier")
  3944. {
  3945. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  3946. }
  3947. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) != '' and attachments is not null) "));
  3948. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  3949. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  3950. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3951. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  3952. /*if (tid.Length > 0)
  3953. {
  3954. List<string> tids = new List<string>();
  3955. if (dt != null && dt.Rows.Count > 0)
  3956. {
  3957. foreach (DataRow item in dt.Rows)
  3958. {
  3959. tids.Add("'" + item["tid"] + "'");
  3960. }
  3961. }
  3962. if (tids.Count > 0)
  3963. {
  3964. lw.RemoveAt(0);
  3965. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  3966. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  3967. dt = WebCache.GetData("view_erptradecell", dStruct);
  3968. }
  3969. }*/
  3970. writeGridDataTableJson(dStruct.TotalCount, dt);
  3971. }
  3972. public void get_erp_pddderiving()
  3973. {
  3974. DataStruct dStruct = GetPostStruct();
  3975. List<string> lw = new List<string>();
  3976. string tid = GetPostString("ctid");
  3977. if (tid.Length > 0)
  3978. {
  3979. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  3980. if (tid.Length > 5)
  3981. {
  3982. List<string> tids = getTidByCtidLike(tid);
  3983. if (tids.Count > 0 && tids.Count < 10)
  3984. {
  3985. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  3986. }
  3987. }
  3988. lw.Add(tid_sql);
  3989. }
  3990. string shopname = GetPostString("shopname");
  3991. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  3992. string buyernick = GetPostString("buyer_nick");
  3993. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  3994. //if (tid.Length == 0 && buyernick.Length == 0)
  3995. //{
  3996. // lw.Add(string.Format("IsRefund<={0}", 1));
  3997. //}
  3998. string customer = GetPostString("customer");
  3999. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4000. string design = GetPostString("design");
  4001. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4002. string orderState = GetPostString("orderState");
  4003. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4004. string address = GetPostString("address");
  4005. 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));
  4006. string sellermemo = GetPostString("seller_memo");
  4007. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4008. string supplier = GetPostString("supplier");
  4009. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4010. string OrderArea = GetPostString("order_area");
  4011. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4012. string placedate1 = GetPostString("placedate1");
  4013. string placedate2 = GetPostString("placedate2");
  4014. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4015. if (fdw.Length > 0) lw.Add(fdw);
  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 unusualCon = GetPostString("unusualcon");
  4021. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4022. string posTag = CurrentUser.UserPost.Post.Code;
  4023. if (posTag == "Supplier")
  4024. {
  4025. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4026. }
  4027. lw.Add(string.Format("OrderState = 6 and (CONVERT(VARCHAR,attachments) = '' or attachments is null)"));
  4028. lw.Add(string.Format("type = 'PDD' "));
  4029. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4030. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4031. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4032. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4033. /*if (tid.Length > 0)
  4034. {
  4035. List<string> tids = new List<string>();
  4036. if (dt != null && dt.Rows.Count > 0)
  4037. {
  4038. foreach (DataRow item in dt.Rows)
  4039. {
  4040. tids.Add("'" + item["tid"] + "'");
  4041. }
  4042. }
  4043. if (tids.Count > 0)
  4044. {
  4045. lw.RemoveAt(0);
  4046. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4047. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4048. dt = WebCache.GetData("view_erptradecell", dStruct);
  4049. }
  4050. }*/
  4051. writeGridDataTableJson(dStruct.TotalCount, dt);
  4052. }
  4053. public void get_erp_jdderiving()
  4054. {
  4055. DataStruct dStruct = GetPostStruct();
  4056. List<string> lw = new List<string>();
  4057. string tid = GetPostString("ctid");
  4058. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%' ", tid));
  4059. string shopname = GetPostString("shopname");
  4060. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4061. string buyernick = GetPostString("buyer_nick");
  4062. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4063. //if (tid.Length == 0 && buyernick.Length == 0)
  4064. //{
  4065. // lw.Add(string.Format("IsRefund<={0}", 1));
  4066. //}
  4067. string customer = GetPostString("customer");
  4068. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4069. string design = GetPostString("design");
  4070. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4071. string orderState = GetPostString("orderState");
  4072. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4073. string address = GetPostString("address");
  4074. 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));
  4075. string sellermemo = GetPostString("seller_memo");
  4076. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4077. string supplier = GetPostString("supplier");
  4078. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4079. string OrderArea = GetPostString("order_area");
  4080. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4081. string placedate1 = GetPostString("placedate1");
  4082. string placedate2 = GetPostString("placedate2");
  4083. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4084. if (fdw.Length > 0) lw.Add(fdw);
  4085. string price1 = GetPostString("price1");
  4086. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4087. string price2 = GetPostString("price2");
  4088. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4089. string unusualCon = GetPostString("unusualcon");
  4090. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4091. string posTag = CurrentUser.UserPost.Post.Code;
  4092. if (posTag == "Supplier")
  4093. {
  4094. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4095. }
  4096. lw.Add(string.Format("OrderState = 6 "));
  4097. lw.Add(string.Format("type = 'JD' "));
  4098. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  4099. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  4100. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4101. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4102. writeGridDataTableJson(dStruct.TotalCount, dt);
  4103. }
  4104. public void get_erp_demoorderlist()
  4105. {
  4106. DataStruct dStruct = GetPostStruct();
  4107. List<string> lw = new List<string>();
  4108. string tid = GetPostString("ctid");
  4109. if (tid.Length > 0)
  4110. {
  4111. string select_tid = getTidByCtid(tid);
  4112. lw.Add(string.Format("tid='{0}'", select_tid));
  4113. }
  4114. string shopname = GetPostString("shopname");
  4115. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4116. string buyernick = GetPostString("buyer_nick");
  4117. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4118. string customer = GetPostString("customer");
  4119. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4120. string design = GetPostString("design");
  4121. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4122. string orderState = GetPostString("orderState");
  4123. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4124. string address = GetPostString("address");
  4125. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4126. string sellermemo = GetPostString("seller_memo");
  4127. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4128. string supplier = GetPostString("supplier");
  4129. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4130. string OrderArea = GetPostString("order_area");
  4131. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4132. string date1 = GetPostString("date1");
  4133. string date2 = GetPostString("date2");
  4134. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4135. if (dw.Length > 0) lw.Add(dw);
  4136. string price1 = GetPostString("price1");
  4137. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4138. string price2 = GetPostString("price2");
  4139. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4140. string posTag = CurrentUser.UserPost.Post.Code;
  4141. if (posTag == "Supplier")
  4142. {
  4143. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4144. }
  4145. //lw.Add(string.Format("OrderState = 6 "));
  4146. lw.Add(string.Format("IsSample={0}", 3));
  4147. lw.Add(string.Format("IsRefund<={0}", 1));
  4148. dStruct.Order = "pay_time desc";
  4149. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4150. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4151. writeGridDataTableJson(dStruct.TotalCount, dt);
  4152. }
  4153. public void save_erp_checkmemo()
  4154. {
  4155. if (UrlPostParmsCheck("ctid"))
  4156. {
  4157. string ctid = GetPostString("ctid");
  4158. CeErpTradeCell entity = null;
  4159. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  4160. if (entity != null)
  4161. {
  4162. entity.CheckMemo = GetPostString("CheckMemo");
  4163. entity.Update();
  4164. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  4165. if (trade != null)
  4166. {
  4167. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.CheckMemo);
  4168. }
  4169. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改查单备注-" + entity.CheckMemo, entity.OrderState);
  4170. returnSuccessMsg("保存成功!");
  4171. return;
  4172. }
  4173. returnErrorMsg("找不到记录");
  4174. }
  4175. }
  4176. public void get_erp_returnlist()
  4177. {
  4178. DataStruct dStruct = GetPostStruct();
  4179. List<string> lw = new List<string>();
  4180. string tid = GetPostString("ctid");
  4181. if (tid.Length > 0)
  4182. {
  4183. string select_tid = getTidByCtid(tid);
  4184. lw.Add(string.Format("tid='{0}'", select_tid));
  4185. }
  4186. string shopname = GetPostString("shopname");
  4187. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4188. string buyernick = GetPostString("buyer_nick");
  4189. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4190. string customer = GetPostString("customer");
  4191. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4192. string design = GetPostString("design");
  4193. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4194. string orderState = GetPostString("orderState");
  4195. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4196. string address = GetPostString("address");
  4197. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4198. string sellermemo = GetPostString("seller_memo");
  4199. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4200. string supplier = GetPostString("supplier");
  4201. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4202. string date1 = GetPostString("date1");
  4203. string date2 = GetPostString("date2");
  4204. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4205. if (dw.Length > 0) lw.Add(dw);
  4206. string bdate1 = GetPostString("backdate1");
  4207. string bdate2 = GetPostString("backdate2");
  4208. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4209. if (dw_back.Length > 0) lw.Add(dw_back);
  4210. string price1 = GetPostString("price1");
  4211. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4212. string price2 = GetPostString("price2");
  4213. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4214. lw.Add(string.Format("IsReturn>0"));
  4215. lw.Add(string.Format("IsXianHuo=0"));
  4216. lw.Add(string.Format("IsReturn!=3"));
  4217. string backtype = GetPostString("backtype");
  4218. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4219. dStruct.Order = "FinishDesignTime desc";
  4220. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4221. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4222. writeGridDataTableJson(dStruct.TotalCount, dt);
  4223. }
  4224. public void get_erp_today_sumreturn()
  4225. {
  4226. DataStruct dStruct = GetPostStruct();
  4227. List<string> lw = new List<string>();
  4228. string bdate1 = GetPostString("returnTimeS");
  4229. string bdate2 = GetPostString("returnTimeE");
  4230. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4231. if (dw_back.Length > 0) lw.Add(dw_back);
  4232. lw.Add(string.Format("IsReturn=0"));
  4233. lw.Add(string.Format("IsXianHuo=0"));
  4234. string mainWhere = string.Join(" and ", lw.ToArray());
  4235. string sql = "";
  4236. if (dw_back.Length > 0)
  4237. {
  4238. sql = "select count(0) as total,(select count(0) from view_erptradecell where " + mainWhere + ") as today_finish from view_erptradecell where " + dw_back;
  4239. }
  4240. else
  4241. {
  4242. 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 + "'";
  4243. }
  4244. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  4245. decimal total = 0, today_finish = 0;
  4246. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["total"]) != "")
  4247. {
  4248. total = Convert.ToDecimal(dt.Rows[0]["total"]);
  4249. }
  4250. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["today_finish"]) != "")
  4251. {
  4252. today_finish = Convert.ToDecimal(dt.Rows[0]["today_finish"]);
  4253. }
  4254. var res = new
  4255. {
  4256. data = total,
  4257. data1 = today_finish,
  4258. };
  4259. string ro_jsond = JsonConvert.SerializeObject(res);
  4260. returnSuccess(ro_jsond);
  4261. return;
  4262. }
  4263. public void get_erp_allreturnlist()
  4264. {
  4265. DataStruct dStruct = GetPostStruct();
  4266. List<string> lw = new List<string>();
  4267. string tid = GetPostString("ctid");
  4268. if (tid.Length > 0)
  4269. {
  4270. string select_tid = getTidByCtid(tid);
  4271. lw.Add(string.Format("tid='{0}'", select_tid));
  4272. }
  4273. string shopname = GetPostString("shopname");
  4274. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4275. string buyernick = GetPostString("buyer_nick");
  4276. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4277. string customer = GetPostString("customer");
  4278. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4279. string design = GetPostString("design");
  4280. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4281. string orderState = GetPostString("orderState");
  4282. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4283. string address = GetPostString("address");
  4284. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4285. string sellermemo = GetPostString("seller_memo");
  4286. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4287. string supplier = GetPostString("supplier");
  4288. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4289. string date1 = GetPostString("date1");
  4290. string date2 = GetPostString("date2");
  4291. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4292. if (dw.Length > 0) lw.Add(dw);
  4293. string bdate1 = GetPostString("backdate1");
  4294. string bdate2 = GetPostString("backdate2");
  4295. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4296. if (dw_back.Length > 0) lw.Add(dw_back);
  4297. string price1 = GetPostString("price1");
  4298. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4299. string price2 = GetPostString("price2");
  4300. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4301. string backreason = GetPostString("backreason");
  4302. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4303. lw.Add(string.Format("IsXianHuo=0"));
  4304. lw.Add(string.Format("ReturnTime != ''"));
  4305. string backtype = GetPostString("backtype");
  4306. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4307. dStruct.Order = "FinishDesignTime desc";
  4308. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4309. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4310. writeGridDataTableJson(dStruct.TotalCount, dt);
  4311. }
  4312. public void get_erp_aftersalereturnlist()
  4313. {
  4314. DataStruct dStruct = GetPostStruct();
  4315. List<string> lw = new List<string>();
  4316. string tid = GetPostString("ctid");
  4317. if (tid.Length > 0)
  4318. {
  4319. string select_tid = getTidByCtid(tid);
  4320. lw.Add(string.Format("tid='{0}'", select_tid));
  4321. }
  4322. string shopname = GetPostString("shopname");
  4323. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4324. string buyernick = GetPostString("buyer_nick");
  4325. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4326. string customer = GetPostString("customer");
  4327. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4328. string design = GetPostString("design");
  4329. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4330. string orderState = GetPostString("orderState");
  4331. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4332. string address = GetPostString("address");
  4333. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4334. string sellermemo = GetPostString("seller_memo");
  4335. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4336. string supplier = GetPostString("supplier");
  4337. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4338. string date1 = GetPostString("date1");
  4339. string date2 = GetPostString("date2");
  4340. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4341. if (dw.Length > 0) lw.Add(dw);
  4342. string bdate1 = GetPostString("backdate1");
  4343. string bdate2 = GetPostString("backdate2");
  4344. string dw_back = GetDateMinuteWhere("ReturnTime", bdate1, bdate2);
  4345. if (dw_back.Length > 0) lw.Add(dw_back);
  4346. string price1 = GetPostString("price1");
  4347. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4348. string price2 = GetPostString("price2");
  4349. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4350. lw.Add(string.Format("IsReturn=3"));
  4351. string backtype = GetPostString("backtype");
  4352. if (backtype.Length > 0) lw.Add(string.Format("IsReturn={0}", Convert.ToInt32(backtype)));
  4353. string backreason = GetPostString("backreason");
  4354. if (backreason.Length > 0) lw.Add(string.Format("ReturnReason like '%{0}%'", backreason));
  4355. dStruct.Order = "ReturnTime desc";
  4356. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4357. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4358. writeGridDataTableJson(dStruct.TotalCount, dt);
  4359. }
  4360. public void get_erp_xianhuoreturnlist()
  4361. {
  4362. DataStruct dStruct = GetPostStruct();
  4363. List<string> lw = new List<string>();
  4364. string tid = GetPostString("ctid");
  4365. if (tid.Length > 0)
  4366. {
  4367. string select_tid = getTidByCtid(tid);
  4368. lw.Add(string.Format("tid='{0}'", select_tid));
  4369. }
  4370. string shopname = GetPostString("shopname");
  4371. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4372. string buyernick = GetPostString("buyer_nick");
  4373. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4374. string customer = GetPostString("customer");
  4375. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4376. string design = GetPostString("design");
  4377. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4378. string orderState = GetPostString("orderState");
  4379. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  4380. string address = GetPostString("address");
  4381. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  4382. string sellermemo = GetPostString("seller_memo");
  4383. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4384. string supplier = GetPostString("supplier");
  4385. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4386. string OrderArea = GetPostString("order_area");
  4387. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  4388. string date1 = GetPostString("date1");
  4389. string date2 = GetPostString("date2");
  4390. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4391. if (dw.Length > 0) lw.Add(dw);
  4392. string price1 = GetPostString("price1");
  4393. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4394. string price2 = GetPostString("price2");
  4395. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4396. string posTag = CurrentUser.UserPost.Post.Code;
  4397. if (posTag == "Supplier")
  4398. {
  4399. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4400. }
  4401. lw.Add(string.Format("OrderState=6 "));
  4402. lw.Add(string.Format("IsXianHuo=1 "));
  4403. lw.Add(string.Format("IsReturn>0 "));
  4404. lw.Add(string.Format("IsReturn!=3"));
  4405. lw.Add(string.Format("IsRefund<={0}", 1));
  4406. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc";
  4407. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4408. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4409. writeGridDataTableJson(dStruct.TotalCount, dt);
  4410. }
  4411. public void set_erp_orderdelivery()
  4412. {
  4413. if (UrlPostParmsCheck("ctid"))
  4414. {
  4415. string eid = GetPostString("ctid");
  4416. CeErpTradeCell entity = null;
  4417. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4418. if (entity != null)
  4419. {
  4420. if (entity.OrderState >= 7)
  4421. {
  4422. returnErrorMsg("此单已发货,无需重复发货");
  4423. return;
  4424. }
  4425. if (entity.OrderState != 6)
  4426. {
  4427. returnErrorMsg("此单状态为非【下单完成】,无法发货");
  4428. return;
  4429. }
  4430. string shop = GetPostString("seller_nick");
  4431. //string sessionkey = taobaoHelper.ShopKeyDics[shop];
  4432. string comName = GetPostString("comName");
  4433. string comCode = GetPostString("comCode");
  4434. string outSid = GetPostString("outSid");
  4435. string deliveryType = GetPostString("deliveryType");
  4436. string deliveryMemo = GetPostString("deliveryMemo");
  4437. outSid = outSid.Trim();
  4438. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  4439. if (mainEn == null)
  4440. {
  4441. returnErrorMsg("找不到原始订单记录");
  4442. return;
  4443. }
  4444. bool isInitOrderDeliv = false;
  4445. if (mainEn.status == "SHIPPED" || mainEn.status == "COMPLETE")
  4446. {
  4447. isInitOrderDeliv = true;
  4448. }
  4449. string apires = "";
  4450. string dcomcode = commonHelper.GetD3ComCode(comCode, comCode);
  4451. 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)
  4452. {
  4453. apires = "发货成功true";
  4454. }
  4455. else
  4456. {
  4457. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  4458. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4459. }
  4460. if ((apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1) || isInitOrderDeliv)
  4461. {
  4462. entity.OrderState = 7;//发货后订单已发货
  4463. entity.OutSid = outSid;
  4464. entity.MemoOpt = 0;
  4465. entity.UpdateTime = DateTime.Now;
  4466. entity.FinishDeliveryTime = DateTime.Now;
  4467. entity.Update();
  4468. commonHelper.aftersaleSend(entity.ctid, comName, outSid);
  4469. commonHelper.UpdateRelationOrder(entity.ctid);
  4470. //还要插入快递信息到 快递信息表
  4471. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  4472. exinfo.tid = eid;
  4473. exinfo.out_sid = outSid;
  4474. exinfo.company_code = comCode;
  4475. exinfo.company_name = comName;
  4476. exinfo.delivery_memo = deliveryMemo;
  4477. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  4478. exinfo.deliveryType = deliveryType;
  4479. exinfo.Create();
  4480. returnSuccessMsg("发货操作成功!");
  4481. commonHelper.UpdateRelationOrder(entity.ctid);
  4482. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, dcomcode, outSid);
  4483. CeErpSukuraData.createInfo(entity.ctid, 4);
  4484. if (entity.SupplierId == 64)
  4485. {
  4486. commonHelper.sendCytExpress(exinfo);
  4487. }
  4488. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  4489. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "发货-" + comName + "-" + outSid, entity.OrderState);
  4490. }
  4491. else
  4492. {
  4493. string errmsg = commonHelper.KeepChinese(apires);
  4494. returnErrorMsg("淘宝发货失败!" + errmsg + "----物流编码:" + dcomcode);
  4495. XLog.SaveLog(0, "发货接口失败," + entity.tid + apires + "----物流编码:" + dcomcode);
  4496. }
  4497. return;
  4498. }
  4499. returnErrorMsg("找不到订单记录");
  4500. }
  4501. }
  4502. public void set_erp_multidelivery()
  4503. {
  4504. string eids = GetPostString("tids");
  4505. string[] eidList = eids.Split(',');
  4506. if (eidList.Length <= 0)
  4507. {
  4508. returnErrorMsg("发货不能为空");
  4509. return;
  4510. }
  4511. foreach (string ctid in eidList)
  4512. {
  4513. if (ctid.Length <= 0) continue;
  4514. CeErpExpressInfo expInfo = CeErpExpressInfo.GetByCtid(ctid);
  4515. if (expInfo != null)
  4516. {
  4517. StringBuilder sql = new StringBuilder();
  4518. sql.AppendFormat("select * from view_ErpTradeCell where ctid='{0}';", ctid);
  4519. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  4520. if (dt.Rows.Count > 0)
  4521. {
  4522. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) >= 7)
  4523. {
  4524. expInfo.delivery_memo = "此单状态为【已发货】,无需重复发货";
  4525. expInfo.state = "异常";
  4526. expInfo.isMultiDelivery = 1;
  4527. expInfo.Update();
  4528. continue;
  4529. }
  4530. if (Convert.ToInt32(dt.Rows[0]["OrderState"]) != 6)
  4531. {
  4532. expInfo.delivery_memo = "此单状态为非【下单完成】,无法发货";
  4533. expInfo.state = "异常";
  4534. expInfo.Update();
  4535. continue;
  4536. }
  4537. //string sessionkey = taobaoHelper.ShopKeyDics[dt.Rows[0]["seller_nick"].ToString()];
  4538. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey, dt.Rows[0]["tid"].ToString(), expInfo.company_code, expInfo.out_sid);
  4539. bool isInitOrderDeliv = false;
  4540. if (dt.Rows[0]["status"].ToString() == "SHIPPED" || dt.Rows[0]["status"].ToString() == "COMPLETE")
  4541. {
  4542. isInitOrderDeliv = true;
  4543. expInfo.isMultiDelivery = 1;
  4544. }
  4545. if (ctid.IndexOf("N") != -1)
  4546. {
  4547. StringBuilder sqlbucha = new StringBuilder();
  4548. sqlbucha.AppendFormat("insert into S_BuChaJia(ctid,orderState,dotype,addtime) values('{1}',{0},'updatestate_shipped',getdate());", (int)OrderState.已发货, dt.Rows[0]["tid"].ToString());
  4549. CeErpTradeCell.ExecuteNonQuery(sqlbucha.ToString());
  4550. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4551. commonHelper.UpdateRelationOrder(ctid);
  4552. expInfo.delivery_memo = "发货成功";
  4553. expInfo.state = "发货成功";
  4554. expInfo.isMultiDelivery = 1;
  4555. expInfo.Update();
  4556. }
  4557. else
  4558. {
  4559. string dcomcode = commonHelper.GetD3ComCode(expInfo.company_code, expInfo.company_name);
  4560. string apires = apiHelper.API_LogisticsOnlineSend(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4561. if (apires.IndexOf("发货成功") != -1 && apires.IndexOf("true") != -1 || isInitOrderDeliv)
  4562. {
  4563. expInfo.delivery_memo = "发货成功";
  4564. expInfo.state = "发货成功";
  4565. expInfo.isMultiDelivery = 1;
  4566. expInfo.Update();
  4567. commonHelper.UpdateRelationOrder(ctid);
  4568. CeErpSukuraData.createInfo(ctid, 4);
  4569. commonHelper.insertToBuchaForDelivery(dt.Rows[0]["tid"].ToString(), dt.Rows[0]["posCode"].ToString(), dcomcode, expInfo.out_sid);
  4570. LogHelper.addLog(ctid, CurrentUser.UserID, "批量发货-" + expInfo.company_code + "-" + expInfo.out_sid);
  4571. }
  4572. else
  4573. {
  4574. expInfo.delivery_memo = apires + "---物流编码:" + dcomcode;
  4575. expInfo.state = "异常";
  4576. expInfo.Update();
  4577. }
  4578. }
  4579. }
  4580. }
  4581. }
  4582. returnSuccessMsg("操作完成");
  4583. }
  4584. public void reset_erp_memoopt()
  4585. {
  4586. if (UrlPostParmsCheck("ctid"))
  4587. {
  4588. string eid = GetPostString("ctid");
  4589. CeErpTradeCell entity = null;
  4590. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  4591. if (entity != null)
  4592. {
  4593. string stropt = "";
  4594. if (entity.MemoOpt == 1)
  4595. {
  4596. stropt = "“改稿”";
  4597. }
  4598. else if (entity.MemoOpt == 2)
  4599. {
  4600. stropt = "“定稿”";
  4601. }
  4602. else if (entity.MemoOpt == 3)
  4603. {
  4604. stropt = "“完成查货”";
  4605. CeErpSukuraData.createInfo(entity.ctid, 6);
  4606. }
  4607. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "已确认:" + stropt, entity.OrderState, 1);
  4608. entity.UpdateTime = DateTime.Now;
  4609. entity.MemoOpt = 0;
  4610. entity.Update();
  4611. returnSuccessMsg("操作成功!");
  4612. return;
  4613. }
  4614. returnErrorMsg("找不到记录");
  4615. }
  4616. }
  4617. public void get_erp_deliveryunusual()
  4618. {
  4619. DataStruct dStruct = GetPostStruct();
  4620. List<string> lw = new List<string>();
  4621. string tid = GetPostString("ctid");
  4622. if (tid.Length > 0)
  4623. {
  4624. string select_tid = getTidByCtid(tid);
  4625. lw.Add(string.Format("tid='{0}'", select_tid));
  4626. }
  4627. string shopname = GetPostString("shopname");
  4628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  4629. string buyernick = GetPostString("buyer_nick");
  4630. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  4631. string customer = GetPostString("customer");
  4632. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4633. string design = GetPostString("design");
  4634. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4635. string sellermemo = GetPostString("seller_memo");
  4636. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4637. string supplier = GetPostString("supplier");
  4638. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4639. string date1 = GetPostString("date1");
  4640. string date2 = GetPostString("date2");
  4641. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4642. if (dw.Length > 0) lw.Add(dw);
  4643. string placedate1 = GetPostString("placedate1");
  4644. string placedate2 = GetPostString("placedate2");
  4645. string dw_place = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4646. if (dw_place.Length > 0) lw.Add(dw_place);
  4647. string price1 = GetPostString("price1");
  4648. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4649. string price2 = GetPostString("price2");
  4650. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4651. string unusualCon = GetPostString("unusualcon");
  4652. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  4653. string posTag = CurrentUser.UserPost.Post.Code;
  4654. if (posTag == "Supplier")
  4655. {
  4656. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4657. }
  4658. lw.Add(string.Format("OrderState = 6"));
  4659. lw.Add(string.Format("UnusualTag = 5"));
  4660. lw.Add(string.Format("IsRefund<={0}", 1));
  4661. dStruct.Order = "FinishPlaceTime desc";
  4662. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4663. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4664. writeGridDataTableJson(dStruct.TotalCount, dt);
  4665. }
  4666. public void get_erp_deliveryedlist()
  4667. {
  4668. DataStruct dStruct = GetPostStruct();
  4669. List<string> lw = new List<string>();
  4670. string tid = GetPostString("ctid");
  4671. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4672. string shopname = GetPostString("shopname");
  4673. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4674. string buyernick = GetPostString("buyer_nick");
  4675. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4676. string customer = GetPostString("customer");
  4677. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4678. string design = GetPostString("design");
  4679. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4680. string sellermemo = GetPostString("seller_memo");
  4681. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4682. string logistics = GetPostString("logistics");
  4683. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4684. string date1 = GetPostString("date1");
  4685. string date2 = GetPostString("date2");
  4686. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4687. //if (dw.Length > 0) lw.Add(dw);
  4688. string placedate1 = GetPostString("placedate1");
  4689. string placedate2 = GetPostString("placedate2");
  4690. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4691. if (fdw.Length > 0) lw.Add(fdw);
  4692. string devdate1 = GetPostString("deliverydate1");
  4693. string devdate2 = GetPostString("deliverydate2");
  4694. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4695. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4696. string price1 = GetPostString("price1");
  4697. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4698. string price2 = GetPostString("price2");
  4699. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4700. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4701. {
  4702. if (tid.Length > 0)
  4703. {
  4704. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4705. if (tid.Length > 5)
  4706. {
  4707. List<string> tids = getTidByCtidLike(tid);
  4708. if (tids.Count > 0 && tids.Count < 10)
  4709. {
  4710. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4711. }
  4712. }
  4713. lw.Add(tid_sql);
  4714. }
  4715. if (buyernick.Length > 0)
  4716. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4717. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4718. if (dw.Length > 0) lw.Add(dw);
  4719. }
  4720. else
  4721. {
  4722. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4723. }
  4724. string posTag = CurrentUser.UserPost.Post.Code;
  4725. if (posTag == "Supplier")
  4726. {
  4727. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4728. }
  4729. else
  4730. {
  4731. string supplier = GetPostString("supplier");
  4732. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4733. }
  4734. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4735. lw.Add(string.Format("type != 'PDD' "));
  4736. lw.Add(string.Format("IsRefund!={0}", 2));
  4737. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4738. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4739. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4740. /*if (tid.Length > 0)
  4741. {
  4742. List<string> tids = new List<string>();
  4743. if (dt != null && dt.Rows.Count > 0)
  4744. {
  4745. foreach (DataRow item in dt.Rows)
  4746. {
  4747. tids.Add("'" + item["tid"] + "'");
  4748. }
  4749. }
  4750. if (tids.Count > 0)
  4751. {
  4752. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4753. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4754. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4755. dt = WebCache.GetData("view_erptradecell", dStruct);
  4756. }
  4757. }*/
  4758. if (dt != null)
  4759. {
  4760. foreach (DataRow dr in dt.Rows)
  4761. {
  4762. 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();
  4763. }
  4764. }
  4765. writeGridDataTableJson(dStruct.TotalCount, dt);
  4766. }
  4767. public void get_erp_pdddeliveryed()
  4768. {
  4769. DataStruct dStruct = GetPostStruct();
  4770. List<string> lw = new List<string>();
  4771. string tid = GetPostString("ctid");
  4772. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4773. string shopname = GetPostString("shopname");
  4774. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4775. string buyernick = GetPostString("buyer_nick");
  4776. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4777. string customer = GetPostString("customer");
  4778. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4779. string design = GetPostString("design");
  4780. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4781. string sellermemo = GetPostString("seller_memo");
  4782. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4783. string logistics = GetPostString("logistics");
  4784. if (logistics.Length > 0) lw.Add(string.Format("(OutSid like '{0}%')", logistics));
  4785. string date1 = GetPostString("date1");
  4786. string date2 = GetPostString("date2");
  4787. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4788. //if (dw.Length > 0) lw.Add(dw);
  4789. string placedate1 = GetPostString("placedate1");
  4790. string placedate2 = GetPostString("placedate2");
  4791. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4792. if (fdw.Length > 0) lw.Add(fdw);
  4793. string devdate1 = GetPostString("deliverydate1");
  4794. string devdate2 = GetPostString("deliverydate2");
  4795. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4796. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4797. string price1 = GetPostString("price1");
  4798. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4799. string price2 = GetPostString("price2");
  4800. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4801. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4802. {
  4803. if (tid.Length > 0)
  4804. {
  4805. string tid_sql = string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%') ", tid);
  4806. if (tid.Length > 5)
  4807. {
  4808. List<string> tids = getTidByCtidLike(tid);
  4809. if (tids.Count > 0 && tids.Count < 10)
  4810. {
  4811. tid_sql = string.Format("tid in ({0}) ", string.Join(",", tids));
  4812. }
  4813. }
  4814. lw.Add(tid_sql);
  4815. }
  4816. if (buyernick.Length > 0)
  4817. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4818. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4819. if (dw.Length > 0) lw.Add(dw);
  4820. }
  4821. else
  4822. {
  4823. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4824. }
  4825. string posTag = CurrentUser.UserPost.Post.Code;
  4826. if (posTag == "Supplier")
  4827. {
  4828. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4829. }
  4830. else
  4831. {
  4832. string supplier = GetPostString("supplier");
  4833. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4834. }
  4835. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4836. lw.Add(string.Format("type = 'PDD' "));
  4837. lw.Add(string.Format("IsRefund!={0}", 2));
  4838. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4839. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4840. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4841. /* if (tid.Length > 0)
  4842. {
  4843. List<string> tids = new List<string>();
  4844. if (dt != null && dt.Rows.Count > 0)
  4845. {
  4846. foreach (DataRow item in dt.Rows)
  4847. {
  4848. tids.Add("'" + item["tid"] + "'");
  4849. }
  4850. }
  4851. if (tids.Count > 0)
  4852. {
  4853. lw.Remove(string.Format("(ctid like '%{0}%' or OrderSn like '%{0}%')", tid));
  4854. lw.Add(string.Format("tid in ({0})", string.Join(", ", tids)));
  4855. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4856. dt = WebCache.GetData("view_erptradecell", dStruct);
  4857. }
  4858. }*/
  4859. foreach (DataRow dr in dt.Rows)
  4860. {
  4861. 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();
  4862. }
  4863. writeGridDataTableJson(dStruct.TotalCount, dt);
  4864. }
  4865. public void get_erp_jddeliveryed()
  4866. {
  4867. DataStruct dStruct = GetPostStruct();
  4868. List<string> lw = new List<string>();
  4869. string tid = GetPostString("ctid");
  4870. //if (tid.Length > 0) lw.Add(string.Format("(ctid='{0}' or tid='{0}')", tid));
  4871. string shopname = GetPostString("shopname");
  4872. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4873. string buyernick = GetPostString("buyer_nick");
  4874. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4875. string customer = GetPostString("customer");
  4876. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4877. string design = GetPostString("design");
  4878. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4879. string sellermemo = GetPostString("seller_memo");
  4880. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4881. string date1 = GetPostString("date1");
  4882. string date2 = GetPostString("date2");
  4883. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4884. //if (dw.Length > 0) lw.Add(dw);
  4885. string placedate1 = GetPostString("placedate1");
  4886. string placedate2 = GetPostString("placedate2");
  4887. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  4888. if (fdw.Length > 0) lw.Add(fdw);
  4889. string devdate1 = GetPostString("deliverydate1");
  4890. string devdate2 = GetPostString("deliverydate2");
  4891. string dw_dev = GetDateMinuteWhere("delivery_time", devdate1, devdate2);
  4892. if (dw_dev.Length > 0) lw.Add(dw_dev);
  4893. string price1 = GetPostString("price1");
  4894. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4895. string price2 = GetPostString("price2");
  4896. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4897. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0)
  4898. {
  4899. if (tid.Length > 0)
  4900. lw.Add(string.Format("ctid like '%{0}%'", tid));
  4901. if (buyernick.Length > 0)
  4902. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4903. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4904. if (dw.Length > 0) lw.Add(dw);
  4905. }
  4906. else
  4907. {
  4908. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4909. }
  4910. string posTag = CurrentUser.UserPost.Post.Code;
  4911. if (posTag == "Supplier")
  4912. {
  4913. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4914. }
  4915. else
  4916. {
  4917. string supplier = GetPostString("supplier");
  4918. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  4919. }
  4920. lw.Add(string.Format("(OrderState = 7 or OrderState=8)"));
  4921. lw.Add(string.Format("type = 'JD' "));
  4922. lw.Add(string.Format("IsRefund!={0}", 2));
  4923. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4924. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4925. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  4926. foreach (DataRow dr in dt.Rows)
  4927. {
  4928. 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();
  4929. }
  4930. writeGridDataTableJson(dStruct.TotalCount, dt);
  4931. }
  4932. public void get_erp_allplacelist()
  4933. {
  4934. DataStruct dStruct = GetPostStruct();
  4935. List<string> lw = new List<string>();
  4936. string tid = GetPostString("ctid");
  4937. //if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  4938. string shopname = GetPostString("shopname");
  4939. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  4940. string buyernick = GetPostString("buyer_nick");
  4941. //if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4942. string customer = GetPostString("customer");
  4943. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  4944. string design = GetPostString("design");
  4945. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  4946. string sellermemo = GetPostString("seller_memo");
  4947. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  4948. string supplier = GetPostString("supplier");
  4949. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  4950. string date1 = GetPostString("date1");
  4951. string date2 = GetPostString("date2");
  4952. string pldate1 = GetPostString("placedate1");
  4953. string pldate2 = GetPostString("placedate2");
  4954. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4955. //if (dw.Length > 0) lw.Add(dw);
  4956. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  4957. {
  4958. if (tid.Length > 0)
  4959. {
  4960. string select_tid = getTidByCtid(tid);
  4961. lw.Add(string.Format("tid='{0}'", select_tid));
  4962. }
  4963. if (buyernick.Length > 0)
  4964. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  4965. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  4966. if (dw.Length > 0) lw.Add(dw);
  4967. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  4968. if (dw_place.Length > 0) lw.Add(dw_place);
  4969. }
  4970. else
  4971. {
  4972. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  4973. {
  4974. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  4975. }
  4976. }
  4977. string price1 = GetPostString("price1");
  4978. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  4979. string price2 = GetPostString("price2");
  4980. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  4981. string posTag = CurrentUser.UserPost.Post.Code;
  4982. if (posTag == "Supplier")
  4983. {
  4984. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  4985. }
  4986. lw.Add(string.Format("OrderState >= 6"));
  4987. lw.Add(string.Format("IsSample != 2 "));
  4988. //lw.Add(string.Format("isDianziOrder = 0 "));
  4989. lw.Add(string.Format("SupplierId > 0 "));
  4990. //lw.Add(string.Format("IsRefund<={0}", 1));
  4991. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  4992. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  4993. DataTable dt = WebCache.GetData("view_ErpAllPlace", dStruct);
  4994. foreach (DataRow dr in dt.Rows)
  4995. {
  4996. 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();
  4997. }
  4998. writeGridDataTableJson(dStruct.TotalCount, dt);
  4999. }
  5000. public void get_erp_financeallplacelist()
  5001. {
  5002. DataStruct dStruct = GetPostStruct();
  5003. List<string> lw = new List<string>();
  5004. string tid = GetPostString("ctid");
  5005. string shopname = GetPostString("shopname");
  5006. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  5007. string buyernick = GetPostString("buyer_nick");
  5008. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5009. string customer = GetPostString("customer");
  5010. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5011. string design = GetPostString("design");
  5012. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5013. string sellermemo = GetPostString("seller_memo");
  5014. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5015. string supplier = GetPostString("supplier");
  5016. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5017. string date1 = GetPostString("date1");
  5018. string date2 = GetPostString("date2");
  5019. string pldate1 = GetPostString("placedate1");
  5020. string pldate2 = GetPostString("placedate2");
  5021. if (tid.Length > 0 || date1.Length > 0 || buyernick.Length > 0 || pldate1.Length > 0)
  5022. {
  5023. if (tid.Length > 0)
  5024. {
  5025. string select_tid = getTidByCtid(tid);
  5026. lw.Add(string.Format("tid='{0}'", select_tid));
  5027. }
  5028. if (buyernick.Length > 0)
  5029. lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  5030. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5031. if (dw.Length > 0) lw.Add(dw);
  5032. string dw_place = GetDateMinuteWhere("FinishPlaceTime", pldate1, pldate2);
  5033. if (dw_place.Length > 0) lw.Add(dw_place);
  5034. }
  5035. else
  5036. {
  5037. if (ex_psize <= 0) //非导出的时候 显示3个月数据
  5038. {
  5039. lw.Add(string.Format("datediff(d,pay_time,getdate())<=92 "));
  5040. }
  5041. }
  5042. string price1 = GetPostString("price1");
  5043. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5044. string price2 = GetPostString("price2");
  5045. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5046. string posTag = CurrentUser.UserPost.Post.Code;
  5047. if (posTag == "Supplier")
  5048. {
  5049. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5050. }
  5051. //lw.Add(string.Format("OrderState >= 6"));
  5052. lw.Add(string.Format("IsSample != 2 "));
  5053. lw.Add(string.Format("isDianziOrder = 0 "));
  5054. //lw.Add(string.Format("IsRefund<={0}", 1));
  5055. dStruct.Order = "MemoOpt desc, FinishPlaceTime desc";
  5056. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5057. DataTable dt = WebCache.GetData("view_erptradecell2", dStruct);
  5058. foreach (DataRow dr in dt.Rows)
  5059. {
  5060. 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();
  5061. }
  5062. writeGridDataTableJson(dStruct.TotalCount, dt);
  5063. }
  5064. public void get_erp_expresslist()
  5065. {
  5066. int listtype = GetInt("ltype");
  5067. DataStruct dStruct = GetPostStruct();
  5068. List<string> lw = new List<string>();
  5069. string tid = GetPostString("tid");
  5070. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  5071. string outsid = GetPostString("out_sid");
  5072. if (outsid.Length > 0) lw.Add(string.Format("out_sid like '%{0}%'", outsid));
  5073. string importer = GetPostString("ImportUserName");
  5074. if (importer.Length > 0) lw.Add(string.Format("ImportUserName like '%{0}%'", importer));
  5075. string file = GetPostString("import_file");
  5076. if (file.Length > 0) lw.Add(string.Format("import_file like '%{0}%'", file));
  5077. string printman = GetPostString("printman");
  5078. if (printman.Length > 0) lw.Add(string.Format("printUser like '%{0}%'", printman));
  5079. string date1 = GetPostString("date1");
  5080. string date2 = GetPostString("date2");
  5081. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5082. if (dw.Length > 0) lw.Add(dw);
  5083. string fdate1 = GetPostString("finishdate1");
  5084. string fdate2 = GetPostString("finishdate2");
  5085. string fdw = GetDateMinuteWhere("print_time", fdate1, fdate2);
  5086. if (fdw.Length > 0) lw.Add(fdw);
  5087. string supplierId = GetPostString("supplierId");
  5088. if (supplierId.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplierId));
  5089. if (listtype == 1)
  5090. {
  5091. lw.Add(string.Format("importUserId !=0"));
  5092. }
  5093. string posTag = CurrentUser.UserPost.Post.Code;
  5094. if (posTag == "Supplier")
  5095. {
  5096. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  5097. }
  5098. if (dStruct.PageSize != 100000)
  5099. {
  5100. dStruct.Order = "isMultiDelivery asc, import_time desc";
  5101. }
  5102. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5103. DataTable dt = WebCache.GetData("view_ErpExpressInfo", dStruct);
  5104. writeGridDataTableJson(dStruct.TotalCount, dt);
  5105. }
  5106. public void set_erp_buchaorderdelivery()
  5107. {
  5108. if (UrlPostParmsCheck("ctid"))
  5109. {
  5110. string eid = GetPostString("ctid");
  5111. CeErpTradeCell entity = null;
  5112. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5113. if (entity != null)
  5114. {
  5115. if (entity.IsSample != 2)
  5116. {
  5117. returnErrorMsg("补差价单才能标记为已发货");
  5118. return;
  5119. }
  5120. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记为已发货", entity.OrderState, 1);
  5121. entity.OrderState = 7;
  5122. entity.Update();
  5123. returnSuccessMsg("操作成功!");
  5124. return;
  5125. }
  5126. returnErrorMsg("找不到记录");
  5127. }
  5128. }
  5129. public void get_stdtemplates()
  5130. {
  5131. //string res = taobaoHelper.CainiaoCloudprintStdtemplatesGet(seller_nick);
  5132. //string res = taobaoHelper.test();
  5133. string res = apiHelper.API_PrintTemplate();
  5134. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5135. if (res.IndexOf("error_message") != -1 && res.IndexOf("false") != -1)
  5136. {
  5137. int sidx = res.IndexOf("error_code");
  5138. int eidx = res.IndexOf("success");
  5139. string msg = res.Substring(sidx, eidx - sidx);
  5140. returnErrorMsg(msg);
  5141. return;
  5142. }
  5143. if (res.Length <= 0)
  5144. {
  5145. returnErrorMsg("模板数据为空!");
  5146. return;
  5147. }
  5148. ReturnSuccess(res);
  5149. }
  5150. public void cancel_print_order()
  5151. {
  5152. if (UrlPostParmsCheck("ctid"))
  5153. {
  5154. string ctid = GetPostString("ctid");
  5155. CeErpTradeCell entity = null;
  5156. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5157. if (entity != null)
  5158. {
  5159. string res = "";
  5160. string code = entity.LastBillWaybillCode;
  5161. if (code == "")
  5162. {
  5163. code = entity.OutSid;
  5164. }
  5165. res = apiHelper.API_CancelPrint(entity.LastBillWaybillCode);
  5166. XLog.SaveLog(0, "取消面单" + res);
  5167. }
  5168. }
  5169. }
  5170. public void set_erp_printwaybill()
  5171. {
  5172. if (UrlPostParmsCheck("ctid"))
  5173. {
  5174. string ctid = GetPostString("ctid");
  5175. string cpCode = GetPostString("cpcode"); //"code":"YTO","id":1,"cpCode":"YTO-CAINIAO",
  5176. string cpName = GetPostString("cpname");
  5177. string isTogether = GetPostString("together");
  5178. //var res_obj = new
  5179. //{
  5180. // restype = 1,
  5181. // 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\"}"
  5182. //};
  5183. //string ro_json = JsonConvert.SerializeObject(res_obj);
  5184. //ReturnSuccess(ro_json);
  5185. //return;
  5186. bool isUseLastWayBillCode = false;
  5187. CeErpTradeCell entity = null;
  5188. if (ctid != "") entity = CeErpTradeCell.GetByCtid(ctid);
  5189. if (entity != null)
  5190. {
  5191. if ((entity.OrderState == 7 || entity.OrderState == 6) && entity.LastBillCpCode == cpCode && entity.LastBillWaybillCode != "")
  5192. {
  5193. isUseLastWayBillCode = true;
  5194. }
  5195. if (entity.OrderState == 7 && "2".Equals(isTogether))
  5196. {
  5197. ReturnSuccess(JsonConvert.SerializeObject(new { restype = 2, data = "" }));
  5198. return;
  5199. }
  5200. if (entity.IsSF > 0 && cpCode.IndexOf("SF") == -1)
  5201. {
  5202. returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
  5203. return;
  5204. }
  5205. }
  5206. string res = "";
  5207. Api_waybill_code_response_Obj fullObj = null;
  5208. string pData_str = "";
  5209. string curUseWayBillCode = "";
  5210. if (isUseLastWayBillCode == false)
  5211. {
  5212. res = apiHelper.API_GetWaybill(cpCode, ctid);
  5213. //string res = "{"response":{"data":{"content":[{"outerCode":"1909374336748825642","result":true,"waybillCode":"YT5608401979200"}]},"success":true}}";
  5214. if (res.IndexOf("failure") != -1)
  5215. {
  5216. //int idx = res.IndexOf("sub_message");
  5217. //int idx2 = res.IndexOf("flag");
  5218. //string emsg = res.Substring(idx + 14, idx2 - idx - 17);
  5219. string errMsgNeed = commonHelper.KeepChinese(res);
  5220. var res_objd = new
  5221. {
  5222. restype = 0,
  5223. data = "获取面单失败" + errMsgNeed
  5224. };
  5225. string ro_jsond = JsonConvert.SerializeObject(res_objd);
  5226. returnSuccess(ro_jsond);
  5227. if (res.IndexOf("停发") != -1)
  5228. {
  5229. entity.UnusualCon = "物流停发";
  5230. entity.Update();
  5231. }
  5232. //returnErrorMsg("获取面单失败,"+emsg);
  5233. XLog.SaveLog(0, "获取面单失败" + cpCode + ":" + res);
  5234. return;
  5235. }
  5236. else if (res.IndexOf("errorMsg") != -1)
  5237. {
  5238. //int idx = res.IndexOf("errorMsg");
  5239. //int idx2 = res.IndexOf("}]}");
  5240. //string emsg = res.Substring(idx + 11, idx2 - idx - 12);
  5241. string errMsgNeed = commonHelper.KeepChinese(res);
  5242. var res_objf = new
  5243. {
  5244. restype = 0,
  5245. data = "获取面单失败2" + errMsgNeed
  5246. };
  5247. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5248. if (res.IndexOf("停发") != -1)
  5249. {
  5250. entity.UnusualCon = "物流停发";
  5251. entity.Update();
  5252. CeErpTrade trade = CeErpTrade.Get(entity.tid);
  5253. if (trade != null)
  5254. {
  5255. string apires = apiHelper.API_TradeMemoUpdate(trade.tid, trade.posCode, "", trade.seller_memo + "-" + entity.UnusualCon);
  5256. }
  5257. }
  5258. returnSuccess(ro_jsonf);
  5259. //returnErrorMsg("获取面单失败," + emsg);
  5260. XLog.SaveLog(0, "获取面单失败2" + cpCode + ":" + res);
  5261. return;
  5262. }
  5263. try
  5264. {
  5265. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5266. //res = res.Replace(" ", "");
  5267. fullObj = JsonConvert.DeserializeObject<Api_waybill_code_response_Obj>(res);
  5268. }
  5269. catch (Exception ex)
  5270. {
  5271. XLog.SaveLog(0, "生成fullObj" + res);
  5272. var res_objf = new
  5273. {
  5274. restype = 0,
  5275. data = "生成fullObj发生错误" + ex.Message
  5276. };
  5277. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5278. returnSuccess(ro_jsonf);
  5279. return;
  5280. }
  5281. if (fullObj.response.data.content.Count > 0)
  5282. {
  5283. ContentItem codeObj = fullObj.response.data.content[0];
  5284. if (cpCode.IndexOf("SFFQ-") != -1)
  5285. {
  5286. pData_str = apiHelper.API_GetPrintData_SF(codeObj.waybillCode);
  5287. }
  5288. else
  5289. pData_str = apiHelper.API_GetPrintData(codeObj.waybillCode);
  5290. curUseWayBillCode = codeObj.waybillCode;
  5291. }
  5292. else
  5293. {
  5294. XLog.SaveLog(0, "生成fullObj找不到快递单号waybillCode" + res);
  5295. var res_objf = new
  5296. {
  5297. restype = 0,
  5298. data = "生成fullObj找不到快递单号waybillCode"
  5299. };
  5300. string ro_jsonf = JsonConvert.SerializeObject(res_objf);
  5301. returnSuccess(ro_jsonf);
  5302. return;
  5303. }
  5304. }
  5305. else
  5306. {
  5307. //使用上次打印的快递单号
  5308. if (cpCode == "SFFQ-LY")
  5309. {
  5310. pData_str = apiHelper.API_GetPrintData_SF(entity.LastBillWaybillCode);
  5311. }
  5312. else
  5313. pData_str = apiHelper.API_GetPrintData(entity.LastBillWaybillCode);
  5314. curUseWayBillCode = entity.LastBillWaybillCode;
  5315. }
  5316. if (pData_str.IndexOf("props") == -1 && pData_str.IndexOf("printData") == -1)
  5317. {
  5318. var res_obje = new
  5319. {
  5320. restype = 0,
  5321. data = "获取加密打印数据失败"
  5322. };
  5323. string ro_jsone = JsonConvert.SerializeObject(res_obje);
  5324. returnSuccess(ro_jsone);
  5325. entity.LastBillCpCode = cpCode;
  5326. entity.LastBillWaybillCode = curUseWayBillCode;
  5327. entity.Update();
  5328. XLog.SaveLog(0, "获取加密打印数据失败" + curUseWayBillCode + pData_str);
  5329. //returnErrorMsg("获取加密打印数据失败");
  5330. return;
  5331. }
  5332. //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
  5333. //string msg = "{\"data\":\""+pageUrl+"\"}";
  5334. string btnType = "";
  5335. if (entity != null)
  5336. {
  5337. CeErpTrade mainEn = CeErpTrade.Get(entity.tid);
  5338. //string res = taobaoHelper.LogisticsOnlineSend(sessionkey,entity.tid,comCode,outSid);
  5339. //cpcode是 YTO-CAINIAO
  5340. //string comCode = cpCode.Split('-')[0].ToString();
  5341. string apires = "";
  5342. if (ctid.IndexOf("N") != -1)
  5343. {
  5344. apires = "发货成功";
  5345. }
  5346. else
  5347. {
  5348. apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5349. }
  5350. //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
  5351. //打单后发货
  5352. if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
  5353. {
  5354. try
  5355. {
  5356. btnType = "待发货";
  5357. entity.OutSid = curUseWayBillCode;
  5358. entity.OrderState = 7;
  5359. entity.IsUrgency = false;
  5360. entity.LastBillCpCode = "";
  5361. entity.LastBillWaybillCode = "";
  5362. entity.FinishDeliveryTime = DateTime.Now;
  5363. entity.IsReturn = 0;
  5364. entity.MemoOpt = 0;
  5365. entity.UpdateTime = DateTime.Now;
  5366. entity.Update();
  5367. commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
  5368. //还要插入快递信息到 快递信息表
  5369. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5370. exinfo.tid = entity.ctid;
  5371. exinfo.out_sid = entity.OutSid;
  5372. exinfo.company_code = cpCode;
  5373. exinfo.company_name = cpName;
  5374. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5375. exinfo.deliveryType = "发货成功";
  5376. exinfo.print_time = DateTime.Now;
  5377. exinfo.printUser = CurrentUser.UserName;
  5378. exinfo.Create();
  5379. commonHelper.UpdateRelationOrder(entity.ctid);
  5380. CeErpSukuraData.createInfo(ctid, 4);
  5381. commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
  5382. if (entity.SupplierId == 64)
  5383. {
  5384. commonHelper.sendCytExpress(exinfo);
  5385. }
  5386. LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
  5387. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5388. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5389. if (!string.IsNullOrEmpty(isTogether))
  5390. {
  5391. if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
  5392. {
  5393. StringBuilder sqlsb = new StringBuilder();
  5394. 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);
  5395. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5396. }
  5397. }
  5398. if (ceErpDeliverMark != null)
  5399. {
  5400. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5401. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5402. {
  5403. List<string> list = new List<string>();
  5404. foreach (DataRow row in dt1.Rows)
  5405. {
  5406. list.Add("'" + row["ctid"] + "'");
  5407. }
  5408. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5409. }
  5410. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5411. }
  5412. }
  5413. catch (Exception ex)
  5414. {
  5415. XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
  5416. }
  5417. }
  5418. else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
  5419. {
  5420. entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
  5421. if (entity.OrderState == 6)
  5422. {
  5423. entity.OrderState = 7;
  5424. }
  5425. entity.UpdateTime = DateTime.Now;
  5426. entity.FinishDeliveryTime = DateTime.Now;
  5427. btnType = "已发货";
  5428. entity.Update();
  5429. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5430. exinfo.tid = entity.ctid;
  5431. exinfo.out_sid = entity.OutSid;
  5432. exinfo.company_code = cpCode;
  5433. exinfo.company_name = cpName;
  5434. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5435. exinfo.deliveryType = "发货成功";
  5436. exinfo.print_time = DateTime.Now;
  5437. exinfo.printUser = CurrentUser.UserName;
  5438. exinfo.Create();
  5439. commonHelper.UpdateRelationOrder(entity.ctid);
  5440. CeErpSukuraData.createInfo(entity.ctid, 4);
  5441. if (entity.SupplierId == 64)
  5442. {
  5443. commonHelper.sendCytExpress(exinfo);
  5444. }
  5445. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
  5446. if (!string.IsNullOrEmpty(isTogether))
  5447. {
  5448. if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
  5449. {
  5450. StringBuilder sqlsb = new StringBuilder();
  5451. 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);
  5452. DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
  5453. }
  5454. }
  5455. if (ceErpDeliverMark != null)
  5456. {
  5457. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
  5458. if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
  5459. {
  5460. List<string> list = new List<string>();
  5461. foreach (DataRow row in dt1.Rows)
  5462. {
  5463. list.Add("'" + row["ctid"] + "'");
  5464. }
  5465. DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
  5466. }
  5467. DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
  5468. }
  5469. //不处理
  5470. }
  5471. else
  5472. {
  5473. entity.UpdateTime = DateTime.Now;
  5474. entity.LastBillCpCode = cpCode;
  5475. entity.LastBillWaybillCode = curUseWayBillCode;
  5476. entity.Update();
  5477. string errmsg = commonHelper.KeepChinese(apires);
  5478. var res_objz = new
  5479. {
  5480. restype = 0,
  5481. data = "打单后发货失败"
  5482. };
  5483. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5484. returnSuccess(ro_jsonz);
  5485. //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
  5486. XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
  5487. return;
  5488. }
  5489. }
  5490. LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
  5491. var res_obj = new
  5492. {
  5493. restype = 1,
  5494. data = pData_str
  5495. };
  5496. string ro_json = JsonConvert.SerializeObject(res_obj);
  5497. ReturnSuccess(ro_json);
  5498. return;
  5499. }
  5500. }
  5501. private string GetUTF8String(byte[] vs)
  5502. {
  5503. throw new NotImplementedException();
  5504. }
  5505. public void set_erp_printwaybill_cn()
  5506. {
  5507. if (UrlPostParmsCheck("ctid"))
  5508. {
  5509. string ctid = GetPostString("ctid");
  5510. string cpCode = GetPostString("cpcode");
  5511. string cpName = GetPostString("cpname");
  5512. string tempUrl = GetPostString("tempurl");
  5513. //string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5514. string res = cainiaoLink.TMS_WAYBILL_GET(cpCode, cpName, tempUrl, ctid);
  5515. //string res = taobaoHelper.test();
  5516. res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5517. if (res.IndexOf("false") != -1 && res.IndexOf("errorCode") != -1)
  5518. {
  5519. int sidx = res.IndexOf("errorMsg");
  5520. int eidx = res.IndexOf("}");
  5521. string msg = res.Substring(sidx + 11, eidx - 12 - sidx);
  5522. var res_objzxx = new
  5523. {
  5524. restype = 0,
  5525. data = msg
  5526. };
  5527. string ro_jsonzxx = JsonConvert.SerializeObject(res_objzxx);
  5528. returnSuccess(ro_jsonzxx);
  5529. //returnErrorMsg(msg);
  5530. return;
  5531. }
  5532. int idx = res.IndexOf("waybillCode");
  5533. int idx2 = res.IndexOf("printData");
  5534. string outsid = res.Substring(idx + 14, idx2 - idx - 17);
  5535. string eid = GetPostString("ctid");
  5536. CeErpTradeCell entity = null;
  5537. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5538. if (entity != null)
  5539. {
  5540. string osid = entity.OutSid;
  5541. entity.OutSid = osid + "," + outsid;
  5542. entity.FinishDeliveryTime = DateTime.Now;
  5543. entity.OrderState = 7;
  5544. entity.UpdateTime = DateTime.Now;
  5545. entity.IsReturn = 0;
  5546. entity.Update();
  5547. CeErpExpressInfo exinfo = new CeErpExpressInfo();
  5548. exinfo.tid = entity.ctid;
  5549. exinfo.out_sid = outsid;
  5550. exinfo.company_code = cpCode;
  5551. exinfo.company_name = cpName;
  5552. exinfo.supplierUserName = commonHelper.getSupplierNameById(entity.SupplierId);
  5553. exinfo.deliveryType = "发货成功";
  5554. exinfo.print_time = DateTime.Now;
  5555. exinfo.printUser = CurrentUser.UserName;
  5556. exinfo.Create();
  5557. if (entity.SupplierId == 64)
  5558. {
  5559. commonHelper.sendCytExpress(exinfo);
  5560. }
  5561. //CeErpDataSendOrderInfo.createObject(entity.ctid);
  5562. }
  5563. LogHelper.addLog(ctid, CurrentUser.UserID, "菜鸟打单-" + cpCode + "-" + outsid);
  5564. var res_objz = new
  5565. {
  5566. restype = 1,
  5567. data = res
  5568. };
  5569. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  5570. returnSuccess(ro_jsonz);
  5571. //ReturnSuccess(res);
  5572. }
  5573. }
  5574. ////打单,打印面单 获取面单号
  5575. //public void set_erp_printwaybill()
  5576. //{
  5577. // if (UrlPostParmsCheck("ctid"))
  5578. // {
  5579. // string ctid = GetPostString("ctid");
  5580. // string cpCode = GetPostString("cpcode");
  5581. // string tempUrl = GetPostString("tempurl");
  5582. // string res = taobaoHelper.CainiaoWaybillIiGet(cpCode, tempUrl, ctid);
  5583. // //string res = taobaoHelper.test();
  5584. // res = tmcHelper.GetUTF8String(Encoding.UTF8.GetBytes(res));
  5585. // if (res.IndexOf("error_response") != -1)
  5586. // {
  5587. // int sidx = res.IndexOf("sub_msg");
  5588. // int eidx = res.IndexOf("request_id");
  5589. // string msg = res.Substring(sidx + 10, eidx - 13 - sidx);
  5590. // returnErrorMsg(msg);
  5591. // return;
  5592. // }
  5593. // int idx = res.IndexOf("waybill_code");
  5594. // int idx2 = res.IndexOf("}]}");
  5595. // string outsid = res.Substring(idx + 16, idx2 - idx - 17);
  5596. // LogHelper.addLog(ctid, CurrentUser.UserID, "打单-" + cpCode + "-" + outsid);
  5597. // ReturnSuccess(res);
  5598. // }
  5599. //}
  5600. public void cancel_erp_aftersale()
  5601. {
  5602. if (UrlPostParmsCheck("ctid"))
  5603. {
  5604. string eid = GetPostString("ctid");
  5605. CeErpTradeCell entity = null;
  5606. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  5607. if (entity != null)
  5608. {
  5609. //有过处理的售后,取消也不能删除 售 字,保留
  5610. if (entity.AfterSaleUserId > 0 || entity.AfterSaleMethod.Length > 0 || entity.HandleTime != null)
  5611. {
  5612. entity.AfterSaleState = 4;
  5613. }
  5614. else
  5615. entity.AfterSaleState = 0;
  5616. entity.UpdateTime = DateTime.Now;
  5617. entity.Update();
  5618. returnSuccessMsg("操作成功!");
  5619. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消售后移出", entity.OrderState, 1);
  5620. return;
  5621. }
  5622. returnErrorMsg("找不到订单记录");
  5623. }
  5624. }
  5625. public void get_erp_aftersalelist()
  5626. {
  5627. DataStruct dStruct = GetPostStruct();
  5628. List<string> lw = new List<string>();
  5629. int st = GetInt("st");
  5630. string tid = GetPostString("ctid");
  5631. if (st == 3)
  5632. {
  5633. if (tid.Length > 0)
  5634. {
  5635. string select_tid = getTidByCtid(tid);
  5636. lw.Add(string.Format("tid='{0}'", select_tid));
  5637. }
  5638. }
  5639. else
  5640. {
  5641. if (tid.Length > 0)
  5642. {
  5643. string select_tid = getTidByCtid(tid);
  5644. lw.Add(string.Format("tid='{0}'", select_tid));
  5645. }
  5646. }
  5647. string shopname = GetPostString("shopname");
  5648. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5649. string buyernick = GetPostString("buyer_nick");
  5650. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick = '{0}'", buyernick));
  5651. string sellermemo = GetPostString("seller_memo");
  5652. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5653. string orderState = GetPostString("orderState");
  5654. if (orderState.Length > 0) lw.Add(string.Format("OrderState = '{0}'", orderState));
  5655. string afterState = GetPostString("afterstate");
  5656. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5657. string date1 = GetPostString("date1");
  5658. string date2 = GetPostString("date2");
  5659. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5660. if (dw.Length > 0) lw.Add(dw);
  5661. string price1 = GetPostString("price1");
  5662. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5663. string price2 = GetPostString("price2");
  5664. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5665. //lw.Add(string.Format("IsRefund!={0}", 1));
  5666. string reason = GetPostString("reason");
  5667. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5668. string method = GetPostString("method");
  5669. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5670. string handler = GetPostString("handler");
  5671. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5672. string handledate1 = GetPostString("handledate1");
  5673. string handledate2 = GetPostString("handledate2");
  5674. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5675. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5676. string finish1 = GetPostString("finishdate1");
  5677. string finish2 = GetPostString("finishdate2");
  5678. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  5679. if (dwfinish.Length > 0) lw.Add(dwfinish);
  5680. string afterdate1 = GetPostString("afterdate1");
  5681. string afterdate2 = GetPostString("afterdate2");
  5682. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5683. if (afterDate.Length > 0) lw.Add(afterDate);
  5684. string supplier = GetPostString("supplier");
  5685. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5686. string responsible = GetPostString("responsibleman");
  5687. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5688. string customer = GetPostString("customer");
  5689. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5690. string design = GetPostString("design");
  5691. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5692. string afterMemoType = GetPostString("aftermemotype");
  5693. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5694. string posCode = CurrentUser.UserPost.Post.Code;
  5695. //if (st == 3) //3待审核,到售后责任人表里面获取自己的审核列表
  5696. //{
  5697. // string vstate = GetPostString("vstate");
  5698. // if (vstate.Length > 0)
  5699. // {
  5700. // lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  5701. // }
  5702. // if (posCode == "Supplier")
  5703. // {
  5704. // lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  5705. // lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  5706. // dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  5707. // }
  5708. // else
  5709. // {
  5710. // lw.Add(string.Format("AfterSaleState = {0}", st));
  5711. // if (posCode != "Director" && posCode != "SysAdmin" && posCode != "AfterSaleMaster" && posCode != "DesignerMr" && posCode != "AfterSale"
  5712. // && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr")
  5713. // {
  5714. // lw.Add(string.Format("UserId = {0}", CurrentUser.UserID));
  5715. // }
  5716. // else if (CurrentUser.UserPost.Post.Code == "DesignerMr")
  5717. // {
  5718. // int orgid = CurrentUser.UserPost.OrgID;
  5719. // lw.Add(string.Format("( (OrgID={0} and IsArbitrate=1) or UserId={1})", orgid, CurrentUser.UserID));
  5720. // }
  5721. // else if (CurrentUser.UserPost.Post.Code == "Director")
  5722. // {
  5723. // string shopid = CurrentUser.User.pemShop;
  5724. // lw.Add(string.Format("shopId in ({0})", shopid));
  5725. // }
  5726. // //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  5727. // //{
  5728. // // int org_id = CurrentUser.UserPost.OrgID;
  5729. // // lw.Add(string.Format("OrgID={0}", org_id));
  5730. // //}
  5731. // dStruct.Order = "IsArbitrate desc, createdTime desc";
  5732. // }
  5733. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5734. // DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  5735. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5736. //}
  5737. if (st == 5)
  5738. {
  5739. if (posCode != "SysAdmin" && posCode != "Summarize" && posCode != "Finance" && posCode != "PlaceMr") //管理员 组织部 财务部看全部,不需要进来加条件
  5740. {
  5741. if (posCode == "Director" || posCode == "AfterSaleMaster" || posCode == "AfterSale" || posCode == "CustomerMr")//店长、售后 关联店铺
  5742. {
  5743. string shopid = CurrentUser.User.pemShop;
  5744. lw.Add(string.Format("shopId in ({0})", shopid));
  5745. }
  5746. else if (posCode == "DesignerMr" || posCode == "wxDesignerMr") //设计主管、下单主管同部门
  5747. {
  5748. int mrOrgid = CurrentUser.UserPost.OrgID;
  5749. lw.Add(string.Format("DesOrgID={0}", mrOrgid));
  5750. lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", "设计"));
  5751. }
  5752. //else if (posCode == "PlaceMr") //设计主管、下单主管同部门
  5753. //{
  5754. // int mrOrgid = CurrentUser.UserPost.OrgID;
  5755. // lw.Add(string.Format("PlaceOrgID={0}", mrOrgid));
  5756. //}
  5757. else
  5758. {
  5759. string userIdStr = "";
  5760. if (posCode == "CustomerService")
  5761. {
  5762. userIdStr = CurrentUser.UserID + "_k";
  5763. }
  5764. else if (posCode == "Designer" || posCode == "wxDesigner")
  5765. {
  5766. userIdStr = CurrentUser.UserID + "_s";
  5767. }
  5768. else if (posCode == "Place")
  5769. {
  5770. userIdStr = CurrentUser.UserID + "_x";
  5771. }
  5772. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + userIdStr));
  5773. }
  5774. }
  5775. string placedate1 = GetPostString("placedate1");
  5776. string placedate2 = GetPostString("placedate2");
  5777. string dwplace = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  5778. if (dwplace.Length > 0) lw.Add(dwplace);
  5779. string supState = GetPostString("supState");
  5780. if (supState.Length > 0) lw.Add(string.Format("AfterSaleSupplierState='{0}'", supState));
  5781. string searchType = GetPostString("searchType");
  5782. if (searchType.Length > 0 && "moreBack".Equals(searchType))
  5783. {
  5784. lw.Add(string.Format("BackNum>1"));
  5785. }
  5786. lw.Add(string.Format("AfterSaleState>0"));
  5787. if (ex_psize > 0)
  5788. {
  5789. if (CurrentUser.UserPost.Post.Code == "Finance")
  5790. dStruct.Order = "pay_time desc";
  5791. else
  5792. dStruct.Order = "HandleTime desc";
  5793. }
  5794. else
  5795. dStruct.Order = "HandleTime desc";
  5796. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5797. DataTable dt = WebCache.GetData("view_test", dStruct);
  5798. writeGridDataTableJson(dStruct.TotalCount, dt);
  5799. }
  5800. //else if (st == 4)//已完成的售后(客服设计师要看自己已完成的售后)
  5801. //{
  5802. // lw.Add(string.Format("AfterSaleState=4"));
  5803. // string code = CurrentUser.UserPost.Post.Code;
  5804. // if (code == "CustomerService")
  5805. // {
  5806. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  5807. // }
  5808. // else if (code == "Designer" || code == "DesignerMr")
  5809. // {
  5810. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  5811. // }
  5812. // else if (code == "Place" || code == "PlaceMr")
  5813. // {
  5814. // lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  5815. // }
  5816. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5817. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5818. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5819. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5820. //}
  5821. //else //处理中的售后,待处理和处理中合并
  5822. //{
  5823. // if (afterState.Length <= 0)
  5824. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  5825. // dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  5826. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5827. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  5828. // writeGridDataTableJson(dStruct.TotalCount, dt);
  5829. //}
  5830. }
  5831. public void get_erp_disagreeftersalelist()
  5832. {
  5833. DataStruct dStruct = GetPostStruct();
  5834. List<string> lw = new List<string>();
  5835. int st = 2;
  5836. string tid = GetPostString("ctid");
  5837. if (tid.Length > 0)
  5838. {
  5839. string select_tid = getTidByCtid(tid);
  5840. lw.Add(string.Format("tid='{0}'", select_tid));
  5841. }
  5842. string shopname = GetPostString("shopname");
  5843. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5844. string buyernick = GetPostString("buyer_nick");
  5845. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5846. string sellermemo = GetPostString("seller_memo");
  5847. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5848. string orderState = GetPostString("orderState");
  5849. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5850. string afterState = GetPostString("afterstate");
  5851. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5852. string date1 = GetPostString("date1");
  5853. string date2 = GetPostString("date2");
  5854. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5855. if (dw.Length > 0) lw.Add(dw);
  5856. string price1 = GetPostString("price1");
  5857. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5858. string price2 = GetPostString("price2");
  5859. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5860. //lw.Add(string.Format("IsRefund!={0}", 1));
  5861. string reason = GetPostString("reason");
  5862. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5863. string method = GetPostString("method");
  5864. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5865. string handler = GetPostString("handler");
  5866. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5867. string handledate1 = GetPostString("handledate1");
  5868. string handledate2 = GetPostString("handledate2");
  5869. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5870. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5871. string afterdate1 = GetPostString("afterdate1");
  5872. string afterdate2 = GetPostString("afterdate2");
  5873. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5874. if (afterDate.Length > 0) lw.Add(afterDate);
  5875. string backdate1 = GetPostString("backdate1");
  5876. string backdate2 = GetPostString("backdate2");
  5877. string backDate = GetDateMinuteWhere("DisagreeTime", backdate1, backdate2);
  5878. if (backDate.Length > 0) lw.Add(backDate);
  5879. string supplier = GetPostString("supplier");
  5880. if (supplier.Length > 0) lw.Add(string.Format("SupplierName = '{0}'", supplier));
  5881. string responsible = GetPostString("responsibleman");
  5882. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5883. string customer = GetPostString("customer");
  5884. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5885. string design = GetPostString("design");
  5886. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5887. string afterSaleMemo = GetPostString("afterSaleMemo");
  5888. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5889. string afterMemoType = GetPostString("aftermemotype");
  5890. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5891. string aftersakereason = GetPostString("aftersakereason");
  5892. if (aftersakereason.Length > 0)
  5893. {
  5894. if (aftersakereason == "1")
  5895. {
  5896. lw.Add(string.Format("AfterSaleResSupId > 0"));
  5897. }
  5898. if (aftersakereason == "2")
  5899. {
  5900. lw.Add(string.Format("AfterSaleResSupId = 0"));
  5901. }
  5902. }
  5903. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5904. string poscode = CurrentUser.UserPost.Post.Code;
  5905. if (poscode != "SysAdmin")
  5906. {
  5907. string shopid = CurrentUser.User.pemShop;
  5908. lw.Add(string.Format("shopId in ({0})", shopid));
  5909. }
  5910. string searchType = GetPostString("searchType");
  5911. if (searchType == "wait")
  5912. {
  5913. lw.Add(string.Format("HandleTime is null"));
  5914. }
  5915. if (searchType == "handling")
  5916. {
  5917. lw.Add(string.Format("HandleTime is not null "));
  5918. }
  5919. if (searchType == "back" || searchType == "puBack")
  5920. {
  5921. lw.Add(string.Format("AfterSaleBackReason != ''"));
  5922. }
  5923. if (searchType == "reBack")
  5924. {
  5925. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  5926. }
  5927. if (searchType == "moreBack")
  5928. {
  5929. lw.Add(string.Format("backNum > 1"));
  5930. }
  5931. lw.Add(string.Format("(AfterSaleState=5)"));
  5932. dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime asc";
  5933. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  5934. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  5935. writeGridDataTableJson(dStruct.TotalCount, dt);
  5936. }
  5937. public void get_erp_handlingaftersalelist()
  5938. {
  5939. DataStruct dStruct = GetPostStruct();
  5940. List<string> lw = new List<string>();
  5941. int st = 2;
  5942. string tid = GetPostString("ctid");
  5943. if (tid.Length > 0)
  5944. {
  5945. string select_tid = getTidByCtid(tid);
  5946. lw.Add(string.Format("tid='{0}'", select_tid));
  5947. }
  5948. string shopname = GetPostString("shopname");
  5949. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  5950. string buyernick = GetPostString("buyer_nick");
  5951. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  5952. string sellermemo = GetPostString("seller_memo");
  5953. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  5954. string orderState = GetPostString("orderState");
  5955. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  5956. string afterState = GetPostString("afterstate");
  5957. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  5958. string date1 = GetPostString("date1");
  5959. string date2 = GetPostString("date2");
  5960. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  5961. if (dw.Length > 0) lw.Add(dw);
  5962. string price1 = GetPostString("price1");
  5963. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  5964. string price2 = GetPostString("price2");
  5965. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  5966. //lw.Add(string.Format("IsRefund!={0}", 1));
  5967. string reason = GetPostString("reason");
  5968. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  5969. string method = GetPostString("method");
  5970. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  5971. string handler = GetPostString("handler");
  5972. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  5973. string handledate1 = GetPostString("handledate1");
  5974. string handledate2 = GetPostString("handledate2");
  5975. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  5976. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  5977. string afterdate1 = GetPostString("afterdate1");
  5978. string afterdate2 = GetPostString("afterdate2");
  5979. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  5980. if (afterDate.Length > 0) lw.Add(afterDate);
  5981. string supplier = GetPostString("supplier");
  5982. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  5983. string responsible = GetPostString("responsibleman");
  5984. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  5985. string customer = GetPostString("customer");
  5986. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  5987. string design = GetPostString("design");
  5988. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  5989. string afterSaleMemo = GetPostString("afterSaleMemo");
  5990. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  5991. string afterMemoType = GetPostString("aftermemotype");
  5992. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  5993. string afterresult = GetPostString("afterresult");
  5994. if (afterresult.Length > 0) lw.Add(string.Format("TextResult='{0}'", afterresult));
  5995. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  5996. string poscode = CurrentUser.UserPost.Post.Code;
  5997. if (poscode != "SysAdmin")
  5998. {
  5999. string shopid = CurrentUser.User.pemShop;
  6000. lw.Add(string.Format("shopId in ({0})", shopid));
  6001. }
  6002. string searchType = GetPostString("searchType");
  6003. if (searchType == "wait")
  6004. {
  6005. lw.Add(string.Format("HandleTime is null"));
  6006. }
  6007. if (searchType == "documentary")
  6008. {
  6009. lw.Add(string.Format("HandleTime is not null and TextResult in ('重印-转设计师','重印-转下单员') AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' "));
  6010. }
  6011. if (searchType == "handling")
  6012. {
  6013. lw.Add(string.Format("HandleTime is not null AND AfterSaleBackReason = '' AND AfterSaleSupplierMemo = '' and TextResult in ('','联系不上客户','无需售后','退差价','退款','加购','包邮顺丰','退款+退快递费','下单后退款,重拍+包邮顺丰','下单后退款,重拍','待处理','催发货/改快递/改地址','退差价+包邮顺丰')"));
  6014. }
  6015. if (searchType == "back" || searchType == "puBack")
  6016. {
  6017. lw.Add(string.Format("AfterSaleBackReason != ''"));
  6018. }
  6019. if (searchType == "reBack")
  6020. {
  6021. lw.Add(string.Format("AfterSaleSupplierMemo != ''"));
  6022. }
  6023. if (afterState.Length <= 0)
  6024. {
  6025. lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6026. }
  6027. dStruct.Order = "returnVisit desc,case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6028. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6029. DataTable dt = WebCache.GetData("view_AfterSaleList", dStruct);
  6030. writeGridDataTableJson(dStruct.TotalCount, dt);
  6031. }
  6032. //获取退回的处理中的售后列表(朱莉叶、蓝金花用)
  6033. //public void get_erp_back_handlingaftersalelist()
  6034. //{
  6035. // DataStruct dStruct = GetPostStruct();
  6036. // List<string> lw = new List<string>();
  6037. // string tid = GetPostString("ctid");
  6038. // if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  6039. // string shopname = GetPostString("shopname");
  6040. // if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6041. // string buyernick = GetPostString("buyer_nick");
  6042. // if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6043. // string sellermemo = GetPostString("seller_memo");
  6044. // if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6045. // string orderState = GetPostString("orderState");
  6046. // if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6047. // string afterState = GetPostString("afterstate");
  6048. // if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  6049. // string date1 = GetPostString("date1");
  6050. // string date2 = GetPostString("date2");
  6051. // string dw = GetDateMinuteWhere("pay_time", date1, date2);
  6052. // if (dw.Length > 0) lw.Add(dw);
  6053. // string price1 = GetPostString("price1");
  6054. // if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  6055. // string price2 = GetPostString("price2");
  6056. // if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  6057. // //lw.Add(string.Format("IsRefund!={0}", 1));
  6058. // string reason = GetPostString("reason");
  6059. // if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6060. // string method = GetPostString("method");
  6061. // if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6062. // string handler = GetPostString("handler");
  6063. // if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6064. // string handledate1 = GetPostString("handledate1");
  6065. // string handledate2 = GetPostString("handledate2");
  6066. // string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6067. // if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6068. // string afterdate1 = GetPostString("afterdate1");
  6069. // string afterdate2 = GetPostString("afterdate2");
  6070. // string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  6071. // if (afterDate.Length > 0) lw.Add(afterDate);
  6072. // string supplier = GetPostString("supplier");
  6073. // if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6074. // string responsible = GetPostString("responsibleman");
  6075. // if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6076. // string customer = GetPostString("customer");
  6077. // if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6078. // string design = GetPostString("design");
  6079. // if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6080. // string afterMemoType = GetPostString("aftermemotype");
  6081. // if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6082. // lw.Add(string.Format("IsArbitrate = '{0}'", 2));
  6083. // if (afterState.Length <= 0)
  6084. // lw.Add(string.Format("(AfterSaleState=1 or AfterSaleState=2)"));
  6085. // dStruct.Order = "case when AfterSaleSupplierState = 2 then 1 when AfterSaleSupplierState = 0 then 2 when AfterSaleSupplierState = 1 then 3 end asc, AfterSaleTime desc";
  6086. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6087. // DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  6088. // writeGridDataTableJson(dStruct.TotalCount, dt);
  6089. //}
  6090. public void get_erp_aftersaleverifylist()
  6091. {
  6092. DataStruct dStruct = GetPostStruct();
  6093. List<string> lw = new List<string>();
  6094. string tid = GetPostString("ctid");
  6095. if (tid.Length > 0)
  6096. {
  6097. string select_tid = getTidByCtid(tid);
  6098. lw.Add(string.Format("tid='{0}'", select_tid));
  6099. }
  6100. string shopname = GetPostString("shopname");
  6101. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6102. string buyernick = GetPostString("buyer_nick");
  6103. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6104. string sellermemo = GetPostString("seller_memo");
  6105. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6106. string orderState = GetPostString("orderState");
  6107. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6108. //lw.Add(string.Format("IsRefund!={0}", 1));
  6109. string reason = GetPostString("reason");
  6110. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6111. string method = GetPostString("method");
  6112. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6113. string handler = GetPostString("handler");
  6114. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6115. string handledate1 = GetPostString("handledate1");
  6116. string handledate2 = GetPostString("handledate2");
  6117. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6118. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6119. string finish1 = GetPostString("finishdate1");
  6120. string finish2 = GetPostString("finishdate2");
  6121. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6122. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6123. string supplier = GetPostString("supplier");
  6124. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6125. string responsible = GetPostString("responsibleman");
  6126. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6127. string posCode = CurrentUser.UserPost.Post.Code;
  6128. string vstate = GetPostString("vstate");
  6129. if (vstate.Length > 0)
  6130. {
  6131. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6132. }
  6133. if (posCode == "Supplier")
  6134. {
  6135. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6136. lw.Add(string.Format("VerifyState = 0"));
  6137. lw.Add("type = 1");
  6138. lw.Add(string.Format("AfterSaleState={0}", 3));
  6139. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6140. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6141. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6142. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6143. writeGridDataTableJson(dStruct.TotalCount, dt);
  6144. }
  6145. else if (posCode == "logistics")
  6146. {
  6147. lw.Add(string.Format("UserId in ({0})", CurrentUser.User.pemLogistics));
  6148. lw.Add(string.Format("VerifyState = 0"));
  6149. lw.Add("type = 2");
  6150. lw.Add(string.Format("AfterSaleState={0}", 3));
  6151. dStruct.Order = "AfterSaleState asc,HandleTime desc";
  6152. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6153. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6154. writeGridDataTableJson(dStruct.TotalCount, dt);
  6155. }
  6156. else
  6157. {
  6158. lw.Add(string.Format("(AfterSaleState = 3)"));
  6159. string reasonState = GetPostString("reasonState");
  6160. lw.Add("type = 0");
  6161. if (posCode == "SysAdmin" || posCode == "AfterSaleMaster" || posCode == "AfterSale"
  6162. || posCode == "Summarize" || posCode == "Finance")
  6163. {
  6164. if (reasonState == "2")
  6165. {
  6166. lw.Add("VerifyState = 3");
  6167. }
  6168. else if (reasonState == "1")
  6169. {
  6170. lw.Add("VerifyState = 0 and AfterSaleSupplierMemo != ''");
  6171. }
  6172. else
  6173. {
  6174. lw.Add("VerifyState in (0,3)");
  6175. }
  6176. //不加条件,可以看全部
  6177. }
  6178. 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")
  6179. {
  6180. int orgid = CurrentUser.UserPost.OrgID;
  6181. string manageOrgId = CurrentUser.User.ManageOrgIds;
  6182. if (string.IsNullOrEmpty(manageOrgId))
  6183. {
  6184. lw.Add(string.Format("(( OrgID = {0} AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", orgid, CurrentUser.UserID));
  6185. }
  6186. else
  6187. {
  6188. lw.Add(string.Format("(( OrgID in ({0}) AND VerifyState = 0 ) OR ( UserId = {1} AND VerifyState IN ( 0, 3 ) ))", manageOrgId, CurrentUser.UserID));
  6189. }
  6190. if (reasonState == "1")
  6191. {
  6192. lw.Add("VerifyState = 3");
  6193. }
  6194. else if (reasonState == "2")
  6195. {
  6196. lw.Add("VerifyState = 1 and AfterSaleSupplierMemo != ''");
  6197. }
  6198. else
  6199. {
  6200. }
  6201. }
  6202. else
  6203. {
  6204. lw.Add(string.Format("UserId = {0} and VerifyState = 3", CurrentUser.UserID));
  6205. }
  6206. //else if (CurrentUser.UserPost.Post.Code == "PlaceMr")
  6207. //{
  6208. // int org_id = CurrentUser.UserPost.OrgID;
  6209. // lw.Add(string.Format("OrgID={0}", org_id));
  6210. //}
  6211. dStruct.Order = "AfterSaleState asc,IsArbitrate desc, createdTime desc";
  6212. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6213. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6214. writeGridDataTableJson(dStruct.TotalCount, dt);
  6215. }
  6216. }
  6217. public void get_erp_finishaftersalelist()
  6218. {
  6219. DataStruct dStruct = GetPostStruct();
  6220. List<string> lw = new List<string>();
  6221. int st = 4;
  6222. string tid = GetPostString("ctid");
  6223. if (tid.Length > 0)
  6224. {
  6225. string select_tid = getTidByCtid(tid);
  6226. lw.Add(string.Format("tid='{0}'", select_tid));
  6227. }
  6228. string shopname = GetPostString("shopname");
  6229. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6230. //lw.Add(string.Format("IsRefund!={0}", 1));
  6231. string reason = GetPostString("reason");
  6232. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6233. string method = GetPostString("method");
  6234. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6235. string buyernick = GetPostString("buyer_nick");
  6236. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6237. string handler = GetPostString("handler");
  6238. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6239. string handledate1 = GetPostString("handledate1");
  6240. string handledate2 = GetPostString("handledate2");
  6241. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6242. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6243. string finish1 = GetPostString("finishdate1");
  6244. string finish2 = GetPostString("finishdate2");
  6245. string dwfinish = GetDateMinuteWhere("FinishAfterSaleTime", finish1, finish2);
  6246. if (dwfinish.Length > 0) lw.Add(dwfinish);
  6247. string supplier = GetPostString("supplier");
  6248. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6249. string responsible = GetPostString("responsibleman");
  6250. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6251. string vstate = GetPostString("vstate");
  6252. if (vstate.Length > 0)
  6253. {
  6254. if ("3".Equals(vstate))
  6255. {
  6256. lw.Add(string.Format("IsTem=1"));
  6257. }
  6258. else
  6259. {
  6260. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  6261. }
  6262. }
  6263. lw.Add(string.Format("AfterSaleState=4"));
  6264. string code = CurrentUser.UserPost.Post.Code;
  6265. if (code == "SysAdmin" || code == "AfterSaleMaster" || code == "AfterSale" || code == "Summarize" || code == "Finance")
  6266. {
  6267. //不加条件,可以看全部
  6268. }
  6269. else if (code == "Supplier")
  6270. {
  6271. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  6272. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  6273. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6274. }
  6275. else if (code == "logistics")
  6276. {
  6277. lw.Add(string.Format("userId in ({0})", CurrentUser.User.pemLogistics));
  6278. lw.Add("type = 2");
  6279. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  6280. }
  6281. 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")
  6282. {
  6283. int orgid = CurrentUser.UserPost.OrgID;
  6284. string manageOrgIds = CurrentUser.User.ManageOrgIds;
  6285. if (string.IsNullOrEmpty(manageOrgIds))
  6286. {
  6287. lw.Add(string.Format("(( OrgID = {0} ) OR ( UserId = {1} ))", orgid, CurrentUser.UserID));
  6288. }
  6289. else
  6290. {
  6291. lw.Add(string.Format("(( OrgID in ({0}) ) OR ( UserId = {1} ))", manageOrgIds, CurrentUser.UserID));
  6292. }
  6293. }
  6294. else
  6295. {
  6296. lw.Add(string.Format("UserId = {0} ", CurrentUser.UserID));
  6297. }
  6298. dStruct.Order = "HandleTime desc,AfterSaleTime desc";
  6299. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  6300. DataTable dt = WebCache.GetData("view_ErpTradeResponsible", dStruct);
  6301. writeGridDataTableJson(dStruct.TotalCount, dt);
  6302. }
  6303. public void handle_erp_aftersale()
  6304. {
  6305. if (UrlPostParmsCheck("ctid"))
  6306. {
  6307. string eid = GetPostString("ctid");
  6308. string responStr = GetPostString("AfterSaleResponsible");
  6309. if (responStr.Length <= 0)
  6310. {
  6311. returnErrorMsg("售后责任人不能为空");
  6312. return;
  6313. }
  6314. bool isDesign = false;
  6315. double designFree = 0.00;
  6316. int responsibleId = 0;
  6317. CeErpTradeCell entity = null;
  6318. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6319. if (entity != null)
  6320. {
  6321. int isNeedNewOrder = GetPostInt("IsNewOrder");
  6322. string afterMethod = GetPostString("AfterSaleMethod");
  6323. if (isNeedNewOrder == 1)
  6324. {
  6325. CeErpTradeCell newentity = CeErpTradeCell.GetByCtid("S_" + entity.ctid);
  6326. bool ishav = true;
  6327. if (newentity == null)
  6328. {
  6329. newentity = entity.Clone() as CeErpTradeCell;
  6330. ishav = false;
  6331. newentity.ctid = "S_" + entity.ctid;
  6332. newentity.OrderState = 0;
  6333. //唯一标识
  6334. newentity.OrderSn = newentity.ctid;
  6335. string orderSn = dataHelper.getSaleOrderSn();
  6336. if (orderSn != "")
  6337. {
  6338. newentity.OrderSn = orderSn;
  6339. }
  6340. }
  6341. newentity.UpdateTime = DateTime.Now;
  6342. newentity.AfterSaleState = 0;
  6343. newentity.AfterSaleMethod = afterMethod;
  6344. if (!ishav)
  6345. {
  6346. string memo_str = newentity.seller_memo;
  6347. memo_str = memo_str.Replace("(", "(");
  6348. memo_str = memo_str.Replace(")", ")");
  6349. int sIndex = memo_str.IndexOf("(");
  6350. int eIndex = memo_str.IndexOf(")");
  6351. if (sIndex == -1 || eIndex == -1)
  6352. {
  6353. returnErrorMsg("原订单备注中找不到订单号(到“订单列表”查看原单,看备注里面订单号是否被删掉)");
  6354. return;
  6355. }
  6356. string first = memo_str.Substring(0, sIndex + 1);
  6357. string memoCtid = newentity.OrderSn;
  6358. //if (memoCtid.IndexOf("C") != -1)
  6359. //{
  6360. //string CIdx = commonHelper.MidStrEx(memo_str, "[", "]"); //C1
  6361. //if (CIdx.IndexOf("+") != -1)
  6362. //{
  6363. //CIdx = "C" + CIdx.Split('+')[1];
  6364. //}
  6365. //memoCtid = memoCtid.Replace(CIdx + "_", ""); //去掉C1
  6366. //}
  6367. string last = memo_str.Substring(eIndex, memo_str.Length - eIndex);
  6368. //string second = memo_str.Substring(sIndex+1,memo_str.Length-sIndex-1);
  6369. string newMemo = first + memoCtid + last;
  6370. newentity.seller_memo = newMemo;
  6371. newentity.FinishPlaceTime = null;
  6372. newentity.UnusualTag = 0;
  6373. newentity.UnusualCon = "";
  6374. newentity.UnusualTime = null;
  6375. newentity.AfterSaleMemo = "";
  6376. newentity.AfterSaleMethod = afterMethod;
  6377. newentity.AfterSalePreTime = null;
  6378. newentity.AfterSaleReason = "";
  6379. newentity.AfterSaleResponsible = "";
  6380. newentity.AfterSaleState = 0;
  6381. newentity.AfterSaleTime = null;
  6382. newentity.AfterSaleUserId = 0;
  6383. newentity.AfterSaleSupplierState = 0;
  6384. newentity.LastBillWaybillCode = "";
  6385. newentity.LastBillCpCode = "";
  6386. newentity.FinishAfterSaleTime = null;
  6387. newentity.HandleTime = null;
  6388. newentity.IsSF = 0;
  6389. newentity.IsOldCustomer = 0;
  6390. newentity.UrgencyTime = null;
  6391. newentity.ResponsibleUserId = "";
  6392. newentity.IsVerifyToSupplier = false;
  6393. newentity.payment = 0;
  6394. newentity.CheckMemo = "";
  6395. newentity.OutSid = "";
  6396. newentity.CheckOrderTime = null;
  6397. LogHelper.addLog(newentity.ctid, CurrentUser.UserID, "售后处理生成:" + newMemo, entity.OrderState, 1);
  6398. }
  6399. newentity.isAfterSaleOrder = 1;
  6400. newentity.IsRefund = 0;
  6401. string receiveMobile = GetPostString("receiver_mobile");
  6402. if (receiveMobile.Length > 0)
  6403. {
  6404. CeErpTrade trade = CeErpTrade.Get(newentity.tid);
  6405. if (trade != null)
  6406. {
  6407. trade.receiver_name = GetPostString("receiver_name");
  6408. trade.receiver_mobile = receiveMobile;
  6409. trade.receiver_state = GetPostString("receiver_state");
  6410. trade.receiver_city = GetPostString("receiver_city");
  6411. trade.receiver_district = GetPostString("receiver_district");
  6412. trade.receiver_address = GetPostString("receiver_address");
  6413. newentity.IsOffLineOrder = 1;
  6414. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改地址", entity.OrderState, 1);
  6415. }
  6416. }
  6417. string st = GetPostString("ToState");
  6418. if (st.Length > 0)
  6419. {
  6420. if (newentity.OrderState <= 3)
  6421. {
  6422. newentity.WaitDesignTime = DateTime.Now;
  6423. newentity.StartDesignTime = null;
  6424. newentity.FinishDesignTime = null;
  6425. newentity.OrderState = 3;
  6426. if (st == "下单员")
  6427. {
  6428. newentity.DesignUserId = Convert.ToInt32(webConfig.PlaceDesigner_id); //下单不林春鸿;//下单部设计师林春鸿
  6429. if (newentity.seller_memo.IndexOf("封酒贴") != -1)//封酒贴的售后单直接指派给得力
  6430. {
  6431. newentity.SupplierId = commonHelper.getSupplierIDByName("得力");
  6432. }
  6433. }
  6434. else
  6435. {
  6436. newentity.WaitDesignTime = DateTime.Now;
  6437. string sql1 = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE ID = {0}", entity.DesignUserId);
  6438. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6439. if (dt1 != null && dt1.Rows.Count > 0 && !string.IsNullOrEmpty(dt1.Rows[0]["OrgID"].ToString()))
  6440. {
  6441. DataRow user = dt1.Rows[0];
  6442. //找主管
  6443. string sql = string.Format("SELECT * FROM [dbo].[view_ErpUser] WHERE OrgId={0} and PostCode in ('wxDesignerhd','wxDesignerMr','DesignerMr','Designerhd') and isOpen = 1", user["OrgID"]);
  6444. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6445. if (dt != null && dt.Rows.Count > 0)
  6446. {
  6447. int designMr = Convert.ToInt32(dt.Rows[0]["ID"]);
  6448. newentity.DesignUserId = designMr;
  6449. string key = "aftersale_order_" + designMr;
  6450. if (RedisHelper.HasKey(key))
  6451. {
  6452. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6453. list.Add(newentity.ctid);
  6454. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6455. }
  6456. }
  6457. //账号正常
  6458. if (user["State"].ToString() == "0")
  6459. {
  6460. newentity.DesignUserId = entity.DesignUserId;
  6461. string key = "aftersale_order_" + entity.DesignUserId;
  6462. if (RedisHelper.HasKey(key))
  6463. {
  6464. List<string> list = Convert.ToString(RedisHelper.StringGet(key)).Split(',').ToList();
  6465. list.Add(newentity.ctid);
  6466. RedisHelper.StringSet(key, string.Join(",", list.Distinct().ToList()));
  6467. }
  6468. }
  6469. }
  6470. }
  6471. }
  6472. if (entity.IsXianHuo == 1)
  6473. {
  6474. newentity.OrderState = 6;
  6475. entity.FinishPlaceTime = DateTime.Now;
  6476. }
  6477. }
  6478. if (ishav)
  6479. {
  6480. newentity.Update();
  6481. }
  6482. else
  6483. {
  6484. newentity.Create();
  6485. CeErpTradeCellExtend newCellExtend = new CeErpTradeCellExtend();
  6486. newCellExtend.ctid = newentity.ctid;
  6487. newCellExtend.orderFrom = 20;
  6488. newCellExtend.orderType = 30;
  6489. if (st == "下单员")
  6490. {
  6491. }
  6492. else
  6493. {
  6494. newCellExtend.ReprintTime = DateTime.Now;
  6495. }
  6496. newCellExtend.Create();
  6497. }
  6498. if (st != "下单员")
  6499. {
  6500. designHelper.API_GetPrintData_CreateOrder(newentity);
  6501. }
  6502. }
  6503. //处理售后扩展
  6504. string resIdStr = GetPostString("ResponsibleUserId");
  6505. string refundFees = GetPostString("refundFrees");
  6506. int IsComplain = GetPostInt("isComplain");
  6507. int IsBad = GetPostInt("isBad");
  6508. string IsOriginal = GetPostString("isOriginal");
  6509. double diffResultPrice = GetPostDouble("diffResultPrice");
  6510. string textResult = GetPostString("textResult");
  6511. string supplierResponsible = GetPostString("supplierResponsible");
  6512. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(eid);
  6513. if (ceErpTradeAfterSaleExtend == null)
  6514. {
  6515. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  6516. ceErpTradeAfterSaleExtend.tid = eid;
  6517. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6518. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6519. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6520. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6521. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6522. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6523. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6524. ceErpTradeAfterSaleExtend.Create();
  6525. }
  6526. else
  6527. {
  6528. if (!entity.ResponsibleUserId.Equals(resIdStr) && entity.AfterSaleSupplierState > 0)
  6529. {
  6530. ceErpTradeAfterSaleExtend.ChangeNum += 1;
  6531. }
  6532. ceErpTradeAfterSaleExtend.RefundFees = refundFees;
  6533. ceErpTradeAfterSaleExtend.IsComplain = IsComplain;
  6534. ceErpTradeAfterSaleExtend.TextResult = textResult;
  6535. ceErpTradeAfterSaleExtend.diffResultPrice = diffResultPrice;
  6536. ceErpTradeAfterSaleExtend.supplierResponsible = supplierResponsible;
  6537. ceErpTradeAfterSaleExtend.IsOriginal = Convert.ToBoolean(IsOriginal);
  6538. ceErpTradeAfterSaleExtend.IsBad = IsBad;
  6539. ceErpTradeAfterSaleExtend.Update();
  6540. }
  6541. int gysid = GetPostInt("ResponsibleSupId");
  6542. if (entity.AfterSaleUserId == 0)
  6543. {
  6544. entity.AfterSaleUserId = CurrentUser.UserID;
  6545. }
  6546. entity.ResponsibleUserId = resIdStr;
  6547. entity.AfterSaleResponsible = GetPostString("AfterSaleResponsible");
  6548. entity.AfterSaleResSupId = GetPostInt("ResponsibleSupId");
  6549. if (entity.ResponsibleUserId.Length > 0 && entity.AfterSaleResponsible.Length > 0)
  6550. {
  6551. CeErpTradeResponsible.DelByTid(eid, -1);
  6552. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  6553. int backNum = 0;
  6554. if (number != null)
  6555. {
  6556. backNum = number.BackNum;
  6557. }
  6558. char[] separator = { ',' };
  6559. string[] sArray = resIdStr.Split(separator);
  6560. string[] refundFreeList = { };
  6561. if (refundFees.Length > 0)
  6562. {
  6563. refundFreeList = refundFees.Split(separator);
  6564. }
  6565. int index = -1;
  6566. foreach (string i in sArray)
  6567. {
  6568. index++;
  6569. if (i.Length <= 0) continue;
  6570. char[] separator2 = { '_' };
  6571. string idstr = i.Split(separator2)[0];
  6572. string idtype = i.Split(separator2)[1];
  6573. double refudFree = 0;
  6574. if (refundFreeList.Length > 0)
  6575. {
  6576. refudFree = Convert.ToDouble(refundFreeList[index] == "" ? "0" : refundFreeList[index]);
  6577. }
  6578. if (idtype == "s")
  6579. {
  6580. isDesign = true;
  6581. designFree = refudFree;
  6582. }
  6583. int userId = Convert.ToInt32(idstr);
  6584. int type = 0;
  6585. if (idtype == "g")
  6586. {
  6587. type = 1;
  6588. }
  6589. if (idtype == "w")
  6590. {
  6591. type = 2;
  6592. }
  6593. if (idtype == "t")
  6594. {
  6595. type = 3;
  6596. }
  6597. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetByUserIdType(eid, userId, type);
  6598. if (ceErpTradeResponsible == null)
  6599. {
  6600. ceErpTradeResponsible = new CeErpTradeResponsible();
  6601. ceErpTradeResponsible.tid = eid;
  6602. ceErpTradeResponsible.UserId = userId;
  6603. ceErpTradeResponsible.createdTime = DateTime.Now;
  6604. ceErpTradeResponsible.type = type;
  6605. if (type == 1)
  6606. {
  6607. ceErpTradeResponsible.IsSup = 1;
  6608. }
  6609. if (type == 2)
  6610. {
  6611. ceErpTradeResponsible.IsFlow = 1;
  6612. }
  6613. }
  6614. ceErpTradeResponsible.RefundFee = refudFree;
  6615. ceErpTradeResponsible.VerifyState = 0;
  6616. if (userId == 2125 || idtype == "w")
  6617. {
  6618. ceErpTradeResponsible.VerifyState = 1;
  6619. }
  6620. if (idtype == "w" && userId == 101)
  6621. {
  6622. ceErpTradeResponsible.VerifyState = 0;
  6623. }
  6624. if (ceErpTradeResponsible.ID > 0)
  6625. {
  6626. ceErpTradeResponsible.Update();
  6627. }
  6628. else
  6629. {
  6630. ceErpTradeResponsible.Create();
  6631. }
  6632. if (isDesign)
  6633. {
  6634. responsibleId = ceErpTradeResponsible.ID;
  6635. }
  6636. }
  6637. CeErpTradeResponsible.NumByTid(backNum, eid);
  6638. }
  6639. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  6640. if (ceErpTradeCellExtend != null)
  6641. {
  6642. ceErpTradeCellExtend.returnVisit = 0;
  6643. ceErpTradeCellExtend.Update();
  6644. }
  6645. if (entity.HandleTime != null)
  6646. {
  6647. if (entity.AfterSaleState == 1)
  6648. {
  6649. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后", entity.OrderState, 1);
  6650. }
  6651. else
  6652. {
  6653. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "修改售后信息" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 2);
  6654. }
  6655. }
  6656. else
  6657. {
  6658. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "开始处理售后:" + GetPostString("AfterSaleResponsible") + resIdStr, entity.OrderState, 1);
  6659. entity.HandleTime = DateTime.Now;
  6660. }
  6661. bool isCompale = false;
  6662. if (entity.AfterSaleState == 5)
  6663. {
  6664. isCompale = true;
  6665. entity.AfterSaleState = 3;
  6666. }
  6667. entity.AfterSaleSupplierState = 0;
  6668. if (entity.AfterSaleResponsible.IndexOf("供应商") != -1)
  6669. {
  6670. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后处理:" + entity.AfterSaleResponsible + ",id:" + entity.AfterSaleResSupId, entity.OrderState, 2);
  6671. }
  6672. string sImgs = GetPostString("img");
  6673. entity.AfterSaleSupplierImg = sImgs;
  6674. entity.supRefundType = GetPostString("supRefundType");
  6675. entity.AfterSaleReason = GetPostString("AfterSaleReason");
  6676. entity.AfterSaleMethod = GetPostString("AfterSaleMethod");
  6677. entity.AfterSaleMemo = GetPostString("AfterSaleMemo");
  6678. entity.AfterSaleMemoType = GetPostString("MemoType");
  6679. if (entity.supRefundType == "正常损耗" || entity.supRefundType == "无需扣款" || entity.supRefundType == "不理赔" || entity.supRefundType == "不售后")
  6680. {
  6681. //entity.AfterSaleSupplierState = 2;
  6682. }
  6683. string df = GetPostString("DeductFee");
  6684. if (df == "")
  6685. {
  6686. df = "0";
  6687. }
  6688. string rf = GetPostString("RefundFee");
  6689. if (rf == "")
  6690. {
  6691. rf = "0";
  6692. }
  6693. string pm = GetPostString("AfterSalePayment");
  6694. if (pm == "")
  6695. {
  6696. pm = "0";
  6697. }
  6698. entity.AfterSalePayment = Convert.ToDouble(pm);
  6699. entity.DeductFee = Convert.ToDouble(df);
  6700. entity.RefundFee = Convert.ToDouble(rf);
  6701. entity.UpdateTime = DateTime.Now;
  6702. entity.Update();
  6703. string toState = GetPostString("ToState");
  6704. string original = GetPostString("isOriginal");
  6705. ApiVo apiVo = new ApiVo();
  6706. apiVo.orderNumber = entity.ctid;
  6707. apiVo.actionName = "afterDesign";
  6708. apiVo.orderRemarks = entity.AfterSaleMethod;
  6709. apiVo.reasonRemarks = entity.AfterSaleReason;
  6710. apiVo.isDesign = isDesign;
  6711. apiVo.designFree = designFree;
  6712. apiVo.responsibleId = responsibleId;
  6713. apiVo.afterFiles = entity.AfterSaleSupplierImg;
  6714. if (toState == "设计师")
  6715. {
  6716. apiVo.isOriginal = Convert.ToBoolean(original);
  6717. }
  6718. designHelper.API_WorkCore(apiVo);//afterDesign
  6719. CeErpMethod methodSql = new CeErpMethod();
  6720. methodSql.con = entity.AfterSaleMethod;
  6721. methodSql.addTime = DateTime.Now;
  6722. methodSql.Create();
  6723. string delsql = "delete from ce_erpmethod where id not in (select top 50 id from ce_erpmethod order by id desc);";
  6724. CeErpMethod.ExecuteNonQuery(delsql);
  6725. if (isCompale)
  6726. {
  6727. aftersale_data_change(entity.ctid);
  6728. }
  6729. returnSuccessMsg("操作成功!");
  6730. return;
  6731. }
  6732. returnErrorMsg("找不到订单记录");
  6733. }
  6734. }
  6735. public void ins_erp_toresponsible()
  6736. {
  6737. if (UrlPostParmsCheck("ctid"))
  6738. {
  6739. string eid = GetPostString("ctid");
  6740. CeErpTradeCell entity = null;
  6741. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6742. if (entity != null)
  6743. {
  6744. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  6745. if (ceErpTradeAfterSaleExtend == null || string.IsNullOrEmpty(ceErpTradeAfterSaleExtend.TextResult) || ceErpTradeAfterSaleExtend.TextResult == "待处理")
  6746. {
  6747. returnErrorMsg("客户售后结果不能为空或不能为待处理!");
  6748. return;
  6749. }
  6750. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", entity.ctid);
  6751. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  6752. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  6753. if (entity.AfterSalePreTime == null)
  6754. {
  6755. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)entity.AfterSaleTime) >= 0)
  6756. {
  6757. ceErpTradeAfterSaleExtend.PreTimeOut += 1;
  6758. }
  6759. }
  6760. entity.AfterSalePreTime = DateTime.Now;
  6761. //预完成给售后主管审核客户问题直接完成
  6762. if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
  6763. {
  6764. if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
  6765. {
  6766. ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
  6767. }
  6768. }
  6769. ceErpTradeAfterSaleExtend.Update();
  6770. entity.AfterSaleState = 2;
  6771. entity.UpdateTime = DateTime.Now;
  6772. entity.Update();
  6773. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "售后‘预完成’给售后主管审核", entity.OrderState, 2);
  6774. aftersale_data_change(entity.ctid);
  6775. returnSuccessMsg("操作成功!");
  6776. return;
  6777. }
  6778. returnErrorMsg("找不到订单记录");
  6779. }
  6780. }
  6781. public void cancel_erp_aftersaleanddelnew()
  6782. {
  6783. if (UrlPostParmsCheck("ctid"))
  6784. {
  6785. string eid = GetPostString("ctid");
  6786. CeErpTradeCell entity = null;
  6787. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  6788. if (entity != null)
  6789. {
  6790. entity.AfterSaleState = 0;
  6791. entity.AfterSaleReason = "";
  6792. entity.AfterSaleMethod = "";
  6793. entity.AfterSaleMemo = "";
  6794. entity.AfterSaleResponsible = "";
  6795. entity.ResponsibleUserId = "";
  6796. entity.DeductFee = 0;
  6797. entity.RefundFee = 0;
  6798. entity.IsArbitrate = 0;
  6799. CeErpTradeResponsible.DelByTid(eid, -1);
  6800. entity.Update();
  6801. CeErpTradeCell after = CeErpTradeCell.GetByCtid("S_" + eid);
  6802. if (after != null)
  6803. {
  6804. if (after.OrderState < 5)
  6805. CeErpTradeCell.DelByCtid("S_" + eid);
  6806. }
  6807. returnSuccessMsg("操作成功!");
  6808. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "取消删除售后", entity.OrderState, 2);
  6809. return;
  6810. }
  6811. returnErrorMsg("找不到订单记录");
  6812. }
  6813. }
  6814. public void get_erp_aftersale_pregather()
  6815. {
  6816. List<string> lw = new List<string>();
  6817. int st = GetInt("st");
  6818. string tid = GetPostString("ctid");
  6819. if (tid.Length > 0)
  6820. {
  6821. string select_tid = getTidByCtid(tid);
  6822. lw.Add(string.Format("tid='{0}'", select_tid));
  6823. }
  6824. string shopname = GetPostString("shopname");
  6825. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  6826. string buyernick = GetPostString("buyer_nick");
  6827. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  6828. string sellermemo = GetPostString("seller_memo");
  6829. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  6830. string orderState = GetPostString("orderState");
  6831. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  6832. string reason = GetPostString("reason");
  6833. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  6834. string method = GetPostString("method");
  6835. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  6836. string handler = GetPostString("handler");
  6837. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  6838. string handledate1 = GetPostString("handledate1");
  6839. string handledate2 = GetPostString("handledate2");
  6840. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  6841. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  6842. string supplier = GetPostString("supplier");
  6843. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  6844. string responsible = GetPostString("responsibleman");
  6845. if (responsible.Length > 0) lw.Add(string.Format("AfterSaleResponsible like '%{0}%'", responsible));
  6846. string customer = GetPostString("customer");
  6847. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  6848. string design = GetPostString("design");
  6849. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  6850. string afterMemoType = GetPostString("aftermemotype");
  6851. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  6852. string afterSaleMemo = GetPostString("afterSaleMemo");
  6853. if (afterSaleMemo.Length > 0) lw.Add(string.Format("afterSaleMemo like '%{0}%'", afterSaleMemo));
  6854. string afterresult = GetPostString("afterresult");
  6855. if (afterresult.Length > 0) lw.Add(string.Format("TextResult = '{0}'", afterresult));
  6856. string poscode = CurrentUser.UserPost.Post.Code;
  6857. if (poscode != "SysAdmin" && poscode != "AfterSaleMaster")
  6858. {
  6859. string shopid = CurrentUser.User.pemShop;
  6860. lw.Add(string.Format("shopId in ({0})", shopid));
  6861. }
  6862. var mainwhere = string.Join(" and ", lw.ToArray());
  6863. string ro_json = "";
  6864. string type = GetPostString("gather_type");
  6865. int number = 0;
  6866. if (poscode == "AfterSale")
  6867. {
  6868. //处理中
  6869. if (type == "Handling")
  6870. {
  6871. 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) : ""));
  6872. DataTable dt = null;
  6873. try
  6874. {
  6875. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6876. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6877. }
  6878. catch (Exception e)
  6879. {
  6880. dt = new DataTable();
  6881. }
  6882. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  6883. return;
  6884. }
  6885. if (type == "Wait")
  6886. {
  6887. //待处理
  6888. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6889. DataTable dt1 = null;
  6890. try
  6891. {
  6892. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6893. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6894. }
  6895. catch (Exception e)
  6896. {
  6897. dt1 = new DataTable();
  6898. }
  6899. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  6900. return;
  6901. }
  6902. if (type == "back")
  6903. {
  6904. //打回
  6905. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != '' " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6906. DataTable dt2 = null;
  6907. try
  6908. {
  6909. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  6910. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  6911. }
  6912. catch (Exception e)
  6913. {
  6914. dt2 = new DataTable();
  6915. }
  6916. returnSuccess(JsonConvert.SerializeObject(new { back = number }));
  6917. return;
  6918. }
  6919. if (type == "preCompletion")
  6920. {
  6921. //预完成
  6922. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6923. DataTable dt3 = null;
  6924. try
  6925. {
  6926. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  6927. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  6928. }
  6929. catch (Exception e)
  6930. {
  6931. dt3 = new DataTable();
  6932. }
  6933. returnSuccess(JsonConvert.SerializeObject(new { preCompletion = number }));
  6934. return;
  6935. }
  6936. if (type == "documentary")
  6937. {
  6938. //跟单中
  6939. 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) : ""));
  6940. DataTable dt4 = null;
  6941. try
  6942. {
  6943. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  6944. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  6945. }
  6946. catch (Exception e)
  6947. {
  6948. dt4 = new DataTable();
  6949. }
  6950. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  6951. return;
  6952. }
  6953. if (type == "reBack")
  6954. {
  6955. //被打回
  6956. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6957. DataTable dt1 = null;
  6958. try
  6959. {
  6960. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6961. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6962. }
  6963. catch (Exception e)
  6964. {
  6965. dt1 = new DataTable();
  6966. }
  6967. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  6968. return;
  6969. }
  6970. }
  6971. if (poscode == "SysAdmin" || poscode == "AfterSaleMaster")
  6972. {
  6973. if (type == "puBack")
  6974. {
  6975. //退回
  6976. string sql = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleBackReason != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6977. DataTable dt = null;
  6978. try
  6979. {
  6980. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  6981. number = Convert.ToInt32(dt.Rows[0]["number"]);
  6982. }
  6983. catch (Exception e)
  6984. {
  6985. dt = new DataTable();
  6986. }
  6987. returnSuccess(JsonConvert.SerializeObject(new { puBack = number }));
  6988. return;
  6989. }
  6990. if (type == "reBack")
  6991. {
  6992. //打回
  6993. string sql1 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and AfterSaleSupplierMemo != ''" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  6994. DataTable dt1 = null;
  6995. try
  6996. {
  6997. dt1 = DbHelper.DbConn.ExecuteDataset(sql1).Tables[0];
  6998. number = Convert.ToInt32(dt1.Rows[0]["number"]);
  6999. }
  7000. catch (Exception e)
  7001. {
  7002. dt1 = new DataTable();
  7003. }
  7004. returnSuccess(JsonConvert.SerializeObject(new { reBack = number }));
  7005. return;
  7006. }
  7007. if (type == "examEd")
  7008. {
  7009. //已审核
  7010. string sql2 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=3 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7011. DataTable dt2 = null;
  7012. try
  7013. {
  7014. dt2 = DbHelper.DbConn.ExecuteDataset(sql2).Tables[0];
  7015. number = Convert.ToInt32(dt2.Rows[0]["number"]);
  7016. }
  7017. catch (Exception e)
  7018. {
  7019. dt2 = new DataTable();
  7020. }
  7021. returnSuccess(JsonConvert.SerializeObject(new { examEd = number }));
  7022. return;
  7023. }
  7024. if (type == "waitExam")
  7025. {
  7026. //待审核
  7027. string sql3 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=2 " + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7028. DataTable dt3 = null;
  7029. try
  7030. {
  7031. dt3 = DbHelper.DbConn.ExecuteDataset(sql3).Tables[0];
  7032. number = Convert.ToInt32(dt3.Rows[0]["number"]);
  7033. }
  7034. catch (Exception e)
  7035. {
  7036. dt3 = new DataTable();
  7037. }
  7038. returnSuccess(JsonConvert.SerializeObject(new { waitExam = number }));
  7039. return;
  7040. }
  7041. if (type == "Handling")
  7042. {
  7043. //处理中
  7044. 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) : ""));
  7045. DataTable dt4 = null;
  7046. try
  7047. {
  7048. dt4 = DbHelper.DbConn.ExecuteDataset(sql4).Tables[0];
  7049. number = Convert.ToInt32(dt4.Rows[0]["number"]);
  7050. }
  7051. catch (Exception e)
  7052. {
  7053. dt4 = new DataTable();
  7054. }
  7055. returnSuccess(JsonConvert.SerializeObject(new { Handling = number }));
  7056. return;
  7057. }
  7058. if (type == "Wait")
  7059. {
  7060. //待处理
  7061. string sql5 = string.Format("select count(*) as number from view_AfterSaleList where aftersalestate=1 and HandleTime is null" + (mainwhere.Length > 0 ? (" and " + mainwhere) : ""));
  7062. DataTable dt5 = null;
  7063. try
  7064. {
  7065. dt5 = DbHelper.DbConn.ExecuteDataset(sql5).Tables[0];
  7066. number = Convert.ToInt32(dt5.Rows[0]["number"]);
  7067. }
  7068. catch (Exception e)
  7069. {
  7070. dt5 = new DataTable();
  7071. }
  7072. returnSuccess(JsonConvert.SerializeObject(new { Wait = number }));
  7073. return;
  7074. }
  7075. if (type == "documentary")
  7076. {
  7077. //跟单中
  7078. 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) : ""));
  7079. DataTable dt6 = null;
  7080. try
  7081. {
  7082. dt6 = DbHelper.DbConn.ExecuteDataset(sql6).Tables[0];
  7083. number = Convert.ToInt32(dt6.Rows[0]["number"]);
  7084. }
  7085. catch (Exception e)
  7086. {
  7087. dt6 = new DataTable();
  7088. }
  7089. returnSuccess(JsonConvert.SerializeObject(new { documentary = number }));
  7090. return;
  7091. }
  7092. }
  7093. returnSuccess(ro_json);
  7094. }
  7095. public void end_erp_aftersale()
  7096. {
  7097. if (UrlPostParmsCheck("ctid"))
  7098. {
  7099. string eid = GetPostString("ctid");
  7100. CeErpTradeCell entity = null;
  7101. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7102. if (entity != null)
  7103. {
  7104. string stype = GetPostString("stype");
  7105. string typeStr = stype;
  7106. entity.AfterSaleState = 4;
  7107. entity.FinishAfterSaleTime = DateTime.Now;
  7108. entity.AfterSaleMethod = (entity.AfterSaleMethod + "-" + typeStr);
  7109. entity.Update();
  7110. ApiVo apiVo = new ApiVo();
  7111. apiVo.orderNumber = entity.ctid;
  7112. apiVo.actionName = "afterOver";
  7113. designHelper.API_WorkCore(apiVo); //afterOver
  7114. string sqlupd = "update ce_erptraderesponsible WITH(ROWLOCK) set VerifyState=1,VerifyTime=getdate(),IsTem=1 where VerifyState > -1 and tid='" + entity.ctid + "'";
  7115. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7116. CeErpSukuraData.createInfo(entity.ctid, 8);
  7117. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "点击售后终止,此单售后完成", 0, 3);
  7118. returnSuccessMsg("操作成功!");
  7119. return;
  7120. }
  7121. returnErrorMsg("找不到订单记录");
  7122. }
  7123. }
  7124. public void ins_erp_finishaftersale()
  7125. {
  7126. if (UrlPostParmsCheck("id"))
  7127. {
  7128. string eid = GetPostString("id");
  7129. CeErpTradeResponsible entity = null;
  7130. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7131. if (entity != null)
  7132. {
  7133. entity.VerifyState = 1;
  7134. entity.VerifyTime = DateTime.Now;
  7135. entity.Update();
  7136. LogHelper.addLog(entity.tid, CurrentUser.UserID, "责任人完成审核", 0, 3);
  7137. string sql = "select * from ce_erptraderesponsible where tid='" + entity.tid + "' and VerifyState=0";
  7138. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  7139. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(entity.tid);
  7140. if (dt.Rows.Count <= 0)
  7141. {
  7142. string sqlupd = "update ce_erptradecell WITH(ROWLOCK) set AfterSaleState=4,FinishAfterSaleTime=getdate(),UpdateTime=getdate() where ctid='" + entity.tid + "'";
  7143. DbHelper.DbConn.ExecuteNonQuery(sqlupd);
  7144. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7145. CeErpSukuraData.createInfo(entity.tid, 8);
  7146. if (ceErpTradeCell.AfterSaleReason.IndexOf("设计") > 0 || ceErpTradeCell.AfterSalePayment > 0)
  7147. {
  7148. CeErpDesignerBill.Del(entity.tid);
  7149. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7150. }
  7151. }
  7152. returnSuccessMsg("操作成功!");
  7153. return;
  7154. }
  7155. returnErrorMsg("找不到订单记录");
  7156. }
  7157. }
  7158. public void upd_erp_arbitrateaftersale()
  7159. {
  7160. if (UrlPostParmsCheck("id"))
  7161. {
  7162. string eid = GetPostString("id");
  7163. CeErpTradeResponsible entity = null;
  7164. if (eid != "") entity = CeErpTradeResponsible.Get(eid);
  7165. if (entity != null)
  7166. {
  7167. entity.IsArbitrate = 1;
  7168. entity.ArbitradeMemo = GetPostString("reason");
  7169. entity.VerifyState = 2;
  7170. entity.Update();
  7171. CeErpTradeCell tradecell = CeErpTradeCell.GetByCtid(entity.tid);
  7172. if (tradecell != null)
  7173. {
  7174. tradecell.AfterSaleSupplierMemo = "申请仲裁:" + entity.ArbitradeMemo;
  7175. tradecell.IsArbitrate = 1;
  7176. tradecell.Update();
  7177. }
  7178. LogHelper.addLog(entity.tid, CurrentUser.UserID, "申请仲裁", 0, 3);
  7179. returnSuccessMsg("操作成功!");
  7180. return;
  7181. }
  7182. returnErrorMsg("找不到订单记录");
  7183. }
  7184. }
  7185. public void upd_erp_backaftersale()
  7186. {
  7187. if (UrlPostParmsCheck("tid"))
  7188. {
  7189. string eid = GetPostString("tid");
  7190. CeErpTradeResponsible number = CeErpTradeResponsible.GetByCtid(eid);
  7191. int backNum = 0;
  7192. if (number != null)
  7193. {
  7194. backNum = number.BackNum;
  7195. }
  7196. CeErpTradeResponsible.NumByTid(backNum + 1, eid);
  7197. CeErpTradeCell entity = null;
  7198. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7199. if (entity != null)
  7200. {
  7201. entity.AfterSaleBackReason = GetPostString("backreason");
  7202. entity.AfterSaleState = 1;
  7203. entity.AfterSaleSupplierState = 0;
  7204. entity.UpdateTime = DateTime.Now;
  7205. entity.Update();
  7206. returnSuccessMsg("操作成功!");
  7207. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "退回到售后中", 0, 0);
  7208. return;
  7209. }
  7210. returnErrorMsg("找不到订单记录");
  7211. }
  7212. }
  7213. public void get_erp_supplieraftersalelist()
  7214. {
  7215. DataStruct dStruct = GetPostStruct();
  7216. List<string> lw = new List<string>();
  7217. string tid = GetPostString("ctid");
  7218. if (tid.Length > 0) lw.Add(string.Format("ctid like '%{0}%'", tid));
  7219. string shopname = GetPostString("shopname");
  7220. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7221. string buyernick = GetPostString("buyer_nick");
  7222. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7223. string sellermemo = GetPostString("seller_memo");
  7224. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7225. string orderState = GetPostString("orderState");
  7226. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  7227. string afterState = GetPostString("afterstate");
  7228. if (afterState.Length > 0) lw.Add(string.Format("AfterSaleState={0}", afterState));
  7229. string date1 = GetPostString("date1");
  7230. string date2 = GetPostString("date2");
  7231. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7232. if (dw.Length > 0) lw.Add(dw);
  7233. string price1 = GetPostString("price1");
  7234. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7235. string price2 = GetPostString("price2");
  7236. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7237. string reason = GetPostString("reason");
  7238. if (reason.Length > 0) lw.Add(string.Format("AfterSaleReason like '%{0}%'", reason));
  7239. string method = GetPostString("method");
  7240. if (method.Length > 0) lw.Add(string.Format("AfterSaleMethod like '%{0}%'", method));
  7241. string handledate1 = GetPostString("handledate1");
  7242. string handledate2 = GetPostString("handledate2");
  7243. string dwhandledate = GetDateMinuteWhere("HandleTime", handledate1, handledate2);
  7244. if (dwhandledate.Length > 0) lw.Add(dwhandledate);
  7245. string handler = GetPostString("handler");
  7246. if (handler.Length > 0) lw.Add(string.Format("AfterSaleName='{0}'", handler));
  7247. string afterdate1 = GetPostString("afterdate1");
  7248. string afterdate2 = GetPostString("afterdate2");
  7249. string afterDate = GetDateMinuteWhere("AfterSaleTime", afterdate1, afterdate2);
  7250. if (afterDate.Length > 0) lw.Add(afterDate);
  7251. string customer = GetPostString("customer");
  7252. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7253. string design = GetPostString("design");
  7254. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7255. string afterMemoType = GetPostString("aftermemotype");
  7256. if (afterMemoType.Length > 0) lw.Add(string.Format("AfterSaleMemoType='{0}'", afterMemoType));
  7257. string vstate = GetPostString("vstate");
  7258. if (vstate.Length > 0)
  7259. {
  7260. lw.Add(string.Format("AfterSaleSupplierState={0}", Convert.ToInt32(vstate)));
  7261. }
  7262. lw.Add(string.Format("AfterSaleState>={0}", 2));
  7263. string supplier = GetPostString("supplier");
  7264. int supid = commonHelper.getSupplierIDByName(supplier);
  7265. if (supplier.Length > 0) lw.Add(string.Format("AfterSaleResSupId={0}", supid));
  7266. string posCode = CurrentUser.UserPost.Post.Code;
  7267. if (posCode == "Supplier")
  7268. {
  7269. lw.Add(string.Format("AfterSaleResSupId in ({0})", CurrentUser.User.pemVend));
  7270. }
  7271. else if (posCode == "AfterSale" || posCode == "AfterSaleMaster")
  7272. {
  7273. lw.Add(string.Format("AfterSaleUserId={0}", CurrentUser.UserID));
  7274. }
  7275. else
  7276. {
  7277. lw.Add(string.Format("AfterSaleResSupId != 0"));
  7278. }
  7279. lw.Add(string.Format("IsSupNeedAfterSale=1")); //特定的供应商才需要供应商审核;
  7280. dStruct.Order = "AfterSaleSupplierState asc,HandleTime desc";
  7281. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7282. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  7283. writeGridDataTableJson(dStruct.TotalCount, dt);
  7284. }
  7285. public void upd_erp_supverifyaftersale()
  7286. {
  7287. if (UrlPostParmsCheck("id"))
  7288. {
  7289. string id = GetPostString("id");
  7290. int st = GetPostInt("afterstate");
  7291. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7292. CeErpTradeCell entity = null;
  7293. if (ceErpTradeResponsible != null)
  7294. {
  7295. entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7296. }
  7297. string afmemo = GetPostString("supmemo");
  7298. string image = GetPostString("image");
  7299. if (entity != null)
  7300. {
  7301. entity.AfterSaleSupplierState = st;
  7302. entity.AfterSaleSupplierMemo = afmemo;
  7303. if (st == 1)
  7304. {
  7305. ceErpTradeResponsible.VerifyState = 1;
  7306. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7307. ceErpTradeResponsible.Update();
  7308. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7309. if (isAll)
  7310. {
  7311. entity.AfterSaleState = 4;
  7312. entity.FinishAfterSaleTime = DateTime.Now;
  7313. }
  7314. }
  7315. else
  7316. {
  7317. CeErpTradeResponsible.dateByTid(entity.ctid);
  7318. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7319. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7320. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7321. if (num <= 1)
  7322. {
  7323. entity.AfterSaleState = 1;
  7324. }
  7325. else
  7326. {
  7327. entity.AfterSaleState = 5;
  7328. }
  7329. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7330. if (ceErpTradeAfterSaleExtend != null)
  7331. {
  7332. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7333. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7334. ceErpTradeAfterSaleExtend.Update();
  7335. }
  7336. else
  7337. {
  7338. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7339. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7340. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7341. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7342. ceErpTradeAfterSaleExtend.Create();
  7343. }
  7344. }
  7345. if (entity.AfterSaleState == 4)
  7346. {
  7347. LogHelper.addLog(entity.tid, CurrentUser.UserID, "完成售后", 0, 3);
  7348. if (entity.AfterSaleReason.IndexOf("设计") > 0 || entity.AfterSalePayment > 0)
  7349. {
  7350. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "售后取消设计费", CurrentUser.UserName, 1);
  7351. }
  7352. ApiVo apiVo = new ApiVo();
  7353. apiVo.orderNumber = entity.ctid;
  7354. apiVo.actionName = "afterOver";
  7355. designHelper.API_WorkCore(apiVo); //afterOver
  7356. }
  7357. entity.UpdateTime = DateTime.Now;
  7358. entity.Update();
  7359. returnSuccessMsg("操作成功!");
  7360. CeErpSukuraData.createInfo(entity.ctid, 8);
  7361. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7362. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "供应商" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7363. return;
  7364. }
  7365. returnErrorMsg("找不到订单记录");
  7366. }
  7367. }
  7368. public void upd_erp_masteraftersale()
  7369. {
  7370. if (UrlPostParmsCheck("id"))
  7371. {
  7372. string id = GetPostString("id");
  7373. int st = GetPostInt("afterstate");
  7374. string afmemo = GetPostString("supmemo");
  7375. string image = GetPostString("image");
  7376. string textResult = GetPostString("textResult");
  7377. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7378. if (ceErpTradeResponsible != null)
  7379. {
  7380. ceErpTradeResponsible.VerifyState = st == 1 ? 3 : 0;
  7381. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7382. ceErpTradeResponsible.Update();
  7383. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7384. if (entity != null)
  7385. {
  7386. entity.AfterSaleSupplierState = st;
  7387. entity.AfterSaleSupplierMemo = afmemo;
  7388. if (st == 1)
  7389. {
  7390. }
  7391. else
  7392. {
  7393. CeErpTradeResponsible.dateByTid(entity.ctid);
  7394. //退回到售后
  7395. string numSql = string.Format("SELECT COUNT ( * ) AS BackNum FROM dbo.Ce_ErpTradeAfterSaleLog WHERE tid = '{0}' AND Con in ('责任主管不认可','供应商不认可')", ceErpTradeResponsible.tid);
  7396. DataTable dt = DbHelper.DbConn.ExecuteDataset(numSql).Tables[0];
  7397. int num = Convert.ToInt32(dt.Rows[0]["BackNum"]);
  7398. if (num <= 1)
  7399. {
  7400. entity.AfterSaleState = 1;
  7401. }
  7402. else
  7403. {
  7404. entity.AfterSaleState = 5;
  7405. }
  7406. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7407. if (ceErpTradeAfterSaleExtend != null)
  7408. {
  7409. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7410. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7411. ceErpTradeAfterSaleExtend.Update();
  7412. }
  7413. else
  7414. {
  7415. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7416. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7417. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7418. ceErpTradeAfterSaleExtend.DisagreeTime = DateTime.Now;
  7419. ceErpTradeAfterSaleExtend.Create();
  7420. }
  7421. }
  7422. entity.UpdateTime = DateTime.Now;
  7423. entity.Update();
  7424. returnSuccessMsg("操作成功!");
  7425. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任主管" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7426. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任主管" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7427. return;
  7428. }
  7429. }
  7430. returnErrorMsg("找不到订单记录");
  7431. }
  7432. }
  7433. public void upd_erp_personaftersale()
  7434. {
  7435. if (UrlPostParmsCheck("id"))
  7436. {
  7437. string id = GetPostString("id");
  7438. int st = GetPostInt("afterstate");
  7439. string afmemo = GetPostString("supmemo");
  7440. string image = GetPostString("image");
  7441. CeErpTradeResponsible ceErpTradeResponsible = CeErpTradeResponsible.GetById(id);
  7442. if (ceErpTradeResponsible != null)
  7443. {
  7444. ceErpTradeResponsible.VerifyState = st == 1 ? 1 : 0;
  7445. ceErpTradeResponsible.VerifyTime = DateTime.Now;
  7446. ceErpTradeResponsible.Update();
  7447. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceErpTradeResponsible.tid);
  7448. if (entity != null)
  7449. {
  7450. entity.AfterSaleSupplierMemo = afmemo;
  7451. entity.AfterSaleSupplierState = st;
  7452. if (st == 1)
  7453. {
  7454. bool isAll = commonHelper.tradeResponsibleAll(entity);
  7455. if (isAll)
  7456. {
  7457. entity.AfterSaleState = 4;
  7458. entity.FinishAfterSaleTime = DateTime.Now;
  7459. }
  7460. }
  7461. else
  7462. {
  7463. CeErpTradeResponsible.dateByTid(entity.ctid);
  7464. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(entity.ctid);
  7465. if (ceErpTradeAfterSaleExtend != null)
  7466. {
  7467. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7468. ceErpTradeAfterSaleExtend.Update();
  7469. }
  7470. else
  7471. {
  7472. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  7473. ceErpTradeAfterSaleExtend.tid = entity.ctid;
  7474. ceErpTradeAfterSaleExtend.AfterSaleBackImg = image;
  7475. ceErpTradeAfterSaleExtend.Create();
  7476. }
  7477. //退回到主管
  7478. //entity.AfterSaleState = 2;
  7479. }
  7480. if (entity.AfterSaleState == 4)
  7481. {
  7482. ApiVo apiVo = new ApiVo();
  7483. apiVo.orderNumber = entity.ctid;
  7484. apiVo.actionName = "afterOver";
  7485. designHelper.API_WorkCore(apiVo); //afterOver
  7486. }
  7487. entity.UpdateTime = DateTime.Now;
  7488. entity.Update();
  7489. returnSuccessMsg("操作成功!");
  7490. CeErpSukuraData.createInfo(entity.ctid, 8);
  7491. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "责任人" + (st == 1 ? "认可" : ("不认可," + afmemo)), 0, 3);
  7492. LogHelper.AddAfterSaleLog(entity.ctid, Convert.ToInt32(id), "责任人" + (st == 1 ? "认可" : "不认可"), CurrentUser.UserID, st == 1 ? 0 : 1, afmemo, image);
  7493. return;
  7494. }
  7495. }
  7496. returnErrorMsg("找不到订单记录");
  7497. }
  7498. }
  7499. public void set_erp_supplierrefundtag()
  7500. {
  7501. if (UrlPostParmsCheck("ctid"))
  7502. {
  7503. string eid = GetPostString("ctid");
  7504. CeErpTradeCell entity = null;
  7505. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  7506. if (entity != null)
  7507. {
  7508. entity.IsSupplierRefund = GetPostInt("tag");
  7509. entity.Update();
  7510. returnSuccessMsg("操作成功!");
  7511. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记供应商是否退款" + entity.IsSupplierRefund, 0, 3);
  7512. return;
  7513. }
  7514. returnErrorMsg("找不到订单记录");
  7515. }
  7516. }
  7517. public void get_erp_refundlist()
  7518. {
  7519. DataStruct dStruct = GetPostStruct();
  7520. List<string> lw = new List<string>();
  7521. string tid = GetPostString("tid");
  7522. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7523. //string rid = GetPostString("refund_id");
  7524. //if (rid.Length > 0) lw.Add(string.Format("refund_id like '%{0}%'", rid));
  7525. string shopname = GetPostString("shopname");
  7526. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7527. string buyernick = GetPostString("buyer_nick");
  7528. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7529. string customer = GetPostString("customer");
  7530. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7531. string design = GetPostString("design");
  7532. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7533. string sellermemo = GetPostString("seller_memo");
  7534. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7535. //string date1 = GetPostString("date1");
  7536. //string date2 = GetPostString("date2");
  7537. //string dateType = GetPostString("dateType");
  7538. //if (dateType.Length > 0)
  7539. //{
  7540. // if (dateType == "1001") dateType = "0";
  7541. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(dateType);
  7542. // if (searchDT.Count == 2)
  7543. // {
  7544. // date1 = searchDT[0].ToString();
  7545. // date2 = searchDT[1].ToString();
  7546. // }
  7547. //}
  7548. //string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7549. //if (dw.Length > 0) lw.Add(dw);
  7550. string redate1 = GetPostString("refunddate1");
  7551. string redate2 = GetPostString("refunddate2");
  7552. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7553. if (dwdate.Length > 0) lw.Add(dwdate);
  7554. string price1 = GetPostString("price1");
  7555. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7556. string price2 = GetPostString("price2");
  7557. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7558. string ispartrefund = GetPostString("ispartrefund");
  7559. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7560. string refundState = GetPostString("refundvstate");
  7561. if (refundState.Length > 0) lw.Add(string.Format("RefundState={0}", refundState));
  7562. int st = GetInt("st");
  7563. if (st == 2) //待确认列表中,把state=3已确认的也显示
  7564. {
  7565. string responsible = GetPostString("responsibleman");
  7566. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7567. lw.Add(string.Format("RefundState>={0}", st));
  7568. string code = CurrentUser.UserPost.Post.Code;
  7569. if (code == "CustomerService")
  7570. {
  7571. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_k"));
  7572. }
  7573. else if (code == "Designer" || code == "DesignerMr" || code == "wxDesignerMr")
  7574. {
  7575. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_s"));
  7576. }
  7577. else if (code == "Place" || code == "PlaceMr")
  7578. {
  7579. lw.Add(string.Format("','+ResponsibleUserId+',' like '%{0}%'", "," + CurrentUser.UserID.ToString() + "_x"));
  7580. }
  7581. dStruct.Order = "RefundState asc,created desc";
  7582. }
  7583. else if (st == 10)
  7584. {
  7585. string responsible = GetPostString("responsibleman");
  7586. if (responsible == "空白")
  7587. {
  7588. lw.Add(string.Format("ResponsibleUserName = ''"));
  7589. }
  7590. else if (responsible.Length > 0)
  7591. {
  7592. lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7593. }
  7594. lw.Add(string.Format("RefundState>=0"));
  7595. dStruct.Order = "created desc";
  7596. }
  7597. else
  7598. {
  7599. string responsible = GetPostString("responsibleman");
  7600. if (responsible.Length > 0) lw.Add(string.Format("ResponsibleUserName like '%{0}%'", responsible));
  7601. lw.Add(string.Format("RefundState={0}", st));
  7602. dStruct.Order = "created desc";
  7603. }
  7604. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7605. DataTable dt = WebCache.GetData("view_ErpTradeRefund", dStruct);
  7606. dt.Columns.Add("refund_fees");
  7607. foreach (DataRow dr in dt.Rows)
  7608. {
  7609. String status = dr["status"].ToString();
  7610. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7611. {
  7612. dr["refund_fees"] = dr["refund_fee"];
  7613. }
  7614. else
  7615. {
  7616. dr["refund_fees"] = "0.0";
  7617. }
  7618. }
  7619. writeGridDataTableJson(dStruct.TotalCount, dt);
  7620. }
  7621. public void get_erp_refunddesignlist()
  7622. {
  7623. DataStruct dStruct = GetPostStruct();
  7624. List<string> lw = new List<string>();
  7625. string tid = GetPostString("tid");
  7626. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7627. string shopname = GetPostString("shopname");
  7628. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7629. string buyernick = GetPostString("buyer_nick");
  7630. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7631. string customer = GetPostString("customer");
  7632. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7633. string design = GetPostString("design");
  7634. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  7635. string sellermemo = GetPostString("seller_memo");
  7636. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  7637. string redate1 = GetPostString("refunddate1");
  7638. string redate2 = GetPostString("refunddate2");
  7639. string dwdate = GetDateMinuteWhere("created", redate1, redate2);
  7640. if (dwdate.Length > 0) lw.Add(dwdate);
  7641. string price1 = GetPostString("price1");
  7642. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7643. string price2 = GetPostString("price2");
  7644. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7645. string ispartrefund = GetPostString("ispartrefund");
  7646. if (ispartrefund.Length > 0) lw.Add(string.Format("IsPartRefund={0}", ispartrefund));
  7647. string designerorg = GetPostString("designerorg");
  7648. if (designerorg.Length > 0) lw.Add(string.Format("DesOrgID={0}", designerorg));
  7649. string refundState = GetPostString("refundState");
  7650. if (refundState.Length > 0) lw.Add(string.Format("restatus='{0}'", refundState));
  7651. int myOrgid = CurrentUser.UserPost.OrgID;
  7652. string myOrgCode = CurrentUser.UserPost.Post.Code;
  7653. if ("Designer".Equals(myOrgCode))//设计师能看到的
  7654. {
  7655. if (CurrentUser.User.TeamIds.Length > 0)
  7656. {
  7657. lw.Add(string.Format(" DesignUserId in ({1})", CurrentUser.UserID, CurrentUser.User.TeamIds));
  7658. }
  7659. else
  7660. {
  7661. lw.Add(string.Format("DesignUserId = {0} ", CurrentUser.UserID));
  7662. }
  7663. }
  7664. else if ("SysAdmin".Equals(myOrgCode))
  7665. {
  7666. }
  7667. else
  7668. {
  7669. if (CurrentUser.User.ManageOrgIds.Length > 0)
  7670. {
  7671. lw.Add(string.Format("DesOrgID in ({0})", CurrentUser.User.ManageOrgIds));
  7672. }
  7673. else
  7674. {
  7675. lw.Add(string.Format("DesOrgID = {0}", myOrgid));
  7676. }
  7677. }
  7678. lw.Add("OrderState in (3,4,5,9) and CONVERT ( numeric, refund_fee ) > 0");
  7679. dStruct.Order = "created desc";
  7680. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7681. DataTable dt = WebCache.GetData("view_ErpTradeCellRefund", dStruct);
  7682. dt.Columns.Add("refund_fees");
  7683. foreach (DataRow dr in dt.Rows)
  7684. {
  7685. String status = dr["status"].ToString();
  7686. if (status.Equals("SUCCESS") || status.Equals("REFUNDED"))
  7687. {
  7688. dr["refund_fees"] = dr["refund_fee"];
  7689. }
  7690. else
  7691. {
  7692. dr["refund_fees"] = "0.0";
  7693. }
  7694. }
  7695. writeGridDataTableJson(dStruct.TotalCount, dt);
  7696. }
  7697. public void handle_erp_refundtag()
  7698. {
  7699. if (UrlPostParmsCheck("refund_id"))
  7700. {
  7701. string eid = GetPostString("refund_id");
  7702. string respMan = GetPostString("ResponsibleName");
  7703. if (respMan.Length <= 0)
  7704. {
  7705. returnErrorMsg("责任人不能为空");
  7706. return;
  7707. }
  7708. CeErpTradeRefund entity = null;
  7709. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7710. if (entity != null)
  7711. {
  7712. entity.ResponsibleUserName = respMan;
  7713. string userid = GetPostString("ResponsibleUserId");
  7714. if (userid.Length > 0)
  7715. {
  7716. entity.ResponsibleUserId = userid;
  7717. }
  7718. entity.Memo = GetPostString("Memo");
  7719. if (respMan.IndexOf("客服") != -1 ||
  7720. respMan.IndexOf("设计师") != -1 ||
  7721. respMan.IndexOf("下单员") != -1)
  7722. {
  7723. entity.RefundState = 2;
  7724. }
  7725. else
  7726. {
  7727. entity.RefundState = 3;
  7728. }
  7729. entity.modified = DateTime.Now;
  7730. entity.Update();
  7731. LogHelper.addLog(entity.tid, CurrentUser.UserID, "标记退款责任人");
  7732. returnSuccessMsg("操作成功!");
  7733. return;
  7734. }
  7735. returnErrorMsg("找不到订单记录");
  7736. }
  7737. }
  7738. public void handle_erp_designrefundtag()
  7739. {
  7740. if (UrlPostParmsCheck("refund_id"))
  7741. {
  7742. string eid = GetPostString("refund_id");
  7743. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(eid);
  7744. if (ceErpTradeCellExtend == null)
  7745. {
  7746. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  7747. ceErpTradeCellExtend.ctid = eid;
  7748. }
  7749. ceErpTradeCellExtend.RefundMemo = GetPostString("Memo");
  7750. if (ceErpTradeCellExtend.ID > 0)
  7751. {
  7752. ceErpTradeCellExtend.Update();
  7753. }
  7754. else
  7755. {
  7756. ceErpTradeCellExtend.Create();
  7757. }
  7758. LogHelper.addLog(ceErpTradeCellExtend.ctid, CurrentUser.UserID, "退款标记:" + ceErpTradeCellExtend.RefundMemo);
  7759. returnSuccessMsg("操作成功!");
  7760. return;
  7761. }
  7762. returnErrorMsg("找不到订单记录");
  7763. }
  7764. public void upd_erp_refundverify()
  7765. {
  7766. if (UrlPostParmsCheck("refund_id"))
  7767. {
  7768. string eid = GetPostString("refund_id");
  7769. CeErpTradeRefund entity = null;
  7770. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7771. if (entity != null)
  7772. {
  7773. if (entity.ResponsibleUserName.IndexOf("客服") != -1 ||
  7774. entity.ResponsibleUserName.IndexOf("设计师") != -1 ||
  7775. entity.ResponsibleUserName.IndexOf("下单员") != -1)
  7776. {
  7777. entity.RefundState = 2;
  7778. }
  7779. else
  7780. {
  7781. entity.RefundState = 3;
  7782. }
  7783. entity.Update();
  7784. LogHelper.addLog(entity.tid, CurrentUser.UserID, "处理标记退款责任人");
  7785. returnSuccessMsg("操作成功!");
  7786. return;
  7787. }
  7788. returnErrorMsg("找不到订单记录");
  7789. }
  7790. }
  7791. public void upd_erp_refundapprove()
  7792. {
  7793. if (UrlPostParmsCheck("refund_id"))
  7794. {
  7795. string eid = GetPostString("refund_id");
  7796. CeErpTradeRefund entity = null;
  7797. if (eid != "") entity = CeErpTradeRefund.Get(eid);
  7798. if (entity != null)
  7799. {
  7800. int apr = GetPostInt("approve");
  7801. if (apr == 0)
  7802. {
  7803. entity.RefundState = 1;
  7804. LogHelper.addLog(entity.tid, CurrentUser.UserID, "不认可责任");
  7805. }
  7806. else if (apr == 1)
  7807. {
  7808. entity.RefundState = 3;
  7809. LogHelper.addLog(entity.tid, CurrentUser.UserID, "认可责任");
  7810. }
  7811. entity.modified = DateTime.Now;
  7812. entity.Update();
  7813. returnSuccessMsg("操作成功!");
  7814. return;
  7815. }
  7816. returnErrorMsg("找不到订单记录");
  7817. }
  7818. }
  7819. public void get_erp_billlist()
  7820. {
  7821. DataStruct dStruct = GetPostStruct();
  7822. List<string> lw = new List<string>();
  7823. string title = GetPostString("title");
  7824. if (title.Length > 0) lw.Add(string.Format("title like '%{0}%'", title));
  7825. string tid = GetPostString("tid");
  7826. string tids = GetPostString("tids");
  7827. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  7828. if (tids.Length > 0)
  7829. {
  7830. tids = "'" + tids + "'";
  7831. tids = tids.Replace(",", "','");
  7832. lw.Add(string.Format("tid in ({0})", tids));
  7833. }
  7834. string shopname = GetPostString("shopname");
  7835. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  7836. string buyernick = GetPostString("buyer_nick");
  7837. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  7838. string customer = GetPostString("customer");
  7839. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  7840. string date1 = GetPostString("date1");
  7841. string date2 = GetPostString("date2");
  7842. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  7843. if (dw.Length > 0) lw.Add(dw);
  7844. string price1 = GetPostString("price1");
  7845. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  7846. string price2 = GetPostString("price2");
  7847. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  7848. string returndate1 = GetPostString("returndate1");
  7849. string returndate2 = GetPostString("returndate2");
  7850. string dw1 = GetDateMinuteWhere("createTime", returndate1, returndate2);
  7851. if (dw1.Length > 0) lw.Add(dw1);
  7852. string billtype = GetPostString("billtype");
  7853. if (billtype.Length > 0) lw.Add(string.Format("sendType = '{0}'", billtype));
  7854. string billstate = GetPostString("billstate");
  7855. if (billstate.Length > 0) lw.Add(string.Format("state = {0}", Convert.ToInt32(billstate)));
  7856. string usershop = CurrentUser.User.pemShop;
  7857. lw.Add(string.Format("seller_nick in (select shopname from ce_erpshop where id in ({0}))", usershop));
  7858. dStruct.Order = "createTime desc";
  7859. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  7860. DataTable dt = WebCache.GetData("view_ErpBill", dStruct);
  7861. //foreach (DataRow dr in dt.Rows)
  7862. //{
  7863. // dr["title"] = dr["title"].ToString() + "|" + dr["tax"].ToString() + "|" + dr["ProductName"].ToString() + "|" + dr["bank"].ToString() + "|" + dr["bankac"].ToString() + "|" + dr["address"].ToString();
  7864. //}
  7865. writeGridDataTableJson(dStruct.TotalCount, dt);
  7866. }
  7867. public void modify_erp_billinfo()
  7868. {
  7869. if (UrlPostParmsCheck("ID"))
  7870. {
  7871. string eid = GetPostString("ID");
  7872. CeErpBill bill_entity = null;
  7873. if (eid != "") bill_entity = CeErpBill.Get(eid);
  7874. if (bill_entity != null)
  7875. {
  7876. bill_entity.tid = GetPostString("tid");
  7877. bill_entity.title = GetPostString("title");
  7878. bill_entity.tax = GetPostString("tax");
  7879. bill_entity.bank = GetPostString("bank");
  7880. bill_entity.bankac = GetPostString("bankac");
  7881. bill_entity.address = GetPostString("address");
  7882. bill_entity.phone = GetPostString("phone");
  7883. bill_entity.price = GetPostString("price");
  7884. bill_entity.productId = GetPostInt("ProductName");
  7885. bill_entity.num = GetPostInt("num");
  7886. bill_entity.unit = GetPostString("unit");
  7887. bill_entity.type = GetPostString("type");
  7888. bill_entity.sendType = GetPostString("SendType");
  7889. bill_entity.email = GetPostString("email");
  7890. bill_entity.buyer_nick = GetPostString("buyer_nick");
  7891. bill_entity.shopName = GetPostString("ShopName");
  7892. bill_entity.applymemo = GetPostString("applymemo");
  7893. bill_entity.modifyTime = DateTime.Now;
  7894. bill_entity.createTime = DateTime.Now;
  7895. bill_entity.state = 0;
  7896. bill_entity.Update();
  7897. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "修改发票", 0, 1);
  7898. returnSuccessMsg("发票修改成功!");
  7899. return;
  7900. }
  7901. returnErrorMsg("找不到对应记录");
  7902. }
  7903. }
  7904. public void set_erp_invoicing()
  7905. {
  7906. if (UrlPostParmsCheck("id"))
  7907. {
  7908. try
  7909. {
  7910. string eid = GetPostString("id");
  7911. CeErpBill bill_entity = null;
  7912. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  7913. if (bill_entity != null)
  7914. {
  7915. int ComId = GetPostInt("ComId");
  7916. //string memo = GetPostString("Memo");
  7917. int allInfo = GetPostInt("allinfo");
  7918. string clert = CurrentUser.User.Name;
  7919. //string detailValue = GetPostString("detailvalue");
  7920. string billId = bill_entity.billOrderId;
  7921. string[] billIdList = billId.Split(',');
  7922. CeErpInvoicingInfo comInfo = CeErpInvoicingInfo.Get(ComId);
  7923. int billCount = (int)Math.Floor(Convert.ToDouble(bill_entity.price) / Convert.ToDouble(comInfo.LimitPrice));
  7924. if (Convert.ToDouble(bill_entity.price) % Convert.ToDouble(comInfo.LimitPrice) > 0.00001)
  7925. {
  7926. billCount += 1;
  7927. }
  7928. if (billId.Length <= 0 || billIdList.Length != billCount)
  7929. {
  7930. bill_entity.billOrderId = "";
  7931. string prebill = "ltb";
  7932. for (int idx = 1; idx <= billCount; idx++)
  7933. {
  7934. string dtstr = DateTime.Now.ToString("yyyyMMddHHmmss");
  7935. string billoid = prebill + idx + dtstr;
  7936. bill_entity.billOrderId += billoid;
  7937. if (idx < billCount)
  7938. {
  7939. bill_entity.billOrderId += ",";
  7940. }
  7941. }
  7942. }
  7943. string[] billOrderList = bill_entity.billOrderId.Split(',');
  7944. if (bill_entity.state == 5)
  7945. {
  7946. string errMsg = bill_entity.failerror;
  7947. string[] errlist = errMsg.Split('|');
  7948. string[] errTags = new string[errlist.Length];
  7949. for (int itag = 0; itag < errlist.Length; itag++)
  7950. {
  7951. if (errlist[itag].Length <= 0) continue;
  7952. errTags[itag] = errlist[itag].Split('&')[0];
  7953. }
  7954. for (int iii = 0; iii < errTags.Length; iii++)
  7955. {
  7956. if (errTags[iii] == null || errTags[iii].Length <= 0) continue;
  7957. int erroBillOrderTag = Convert.ToInt32(errTags[iii]);
  7958. if (billOrderList.Length >= erroBillOrderTag)
  7959. {
  7960. string needModifyBillId = billOrderList[erroBillOrderTag - 1];
  7961. if (needModifyBillId.Length <= 19)
  7962. {
  7963. needModifyBillId = needModifyBillId + "1";
  7964. }
  7965. else
  7966. {
  7967. int last = Convert.ToInt32(needModifyBillId.Substring(needModifyBillId.Length - 1, 1));
  7968. last = last + 1;
  7969. needModifyBillId = needModifyBillId.Substring(0, needModifyBillId.Length - 1) + Convert.ToString(last);
  7970. }
  7971. billOrderList[erroBillOrderTag - 1] = needModifyBillId;
  7972. }
  7973. }
  7974. }
  7975. bool isHaveBillSucces = false;
  7976. string totalRes = "";
  7977. bill_entity.failerror = "";
  7978. for (int ii = 1; ii <= billOrderList.Length; ii++)
  7979. {
  7980. string res = taobaoHelper.invoicing(eid, ComId, clert, billOrderList[ii - 1], ii - 1, billOrderList.Length, allInfo);
  7981. totalRes += res;
  7982. if (res.IndexOf("同步成功") != -1 && res.IndexOf("0000") != -1 && res.IndexOf("失败") == -1 && res.IndexOf("null") == -1)
  7983. {
  7984. isHaveBillSucces = true;
  7985. bill_entity.comId = ComId;
  7986. bill_entity.state = 1;
  7987. bill_entity.executeTime = DateTime.Now;
  7988. bill_entity.executeUser = clert;
  7989. }
  7990. else
  7991. {
  7992. bill_entity.state = 5;
  7993. bill_entity.failerror = bill_entity.failerror + (ii + "&" + commonHelper.KeepChinese(res) + "|");
  7994. }
  7995. }
  7996. bill_entity.billOrderId = string.Join(",", billOrderList.ToArray());
  7997. bill_entity.Update();
  7998. if (isHaveBillSucces)
  7999. {
  8000. StringBuilder sql = new StringBuilder();
  8001. sql.AppendFormat("insert into S_BuChaJia(ctid,addtime,dotype) values('{0}',getdate(),'billres'); ", eid);
  8002. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8003. }
  8004. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "开具发票", 0, 1);
  8005. if (totalRes.IndexOf("失败") != -1 || totalRes.IndexOf("null") != -1)
  8006. {
  8007. returnErrorMsg("开票失败");
  8008. }
  8009. else
  8010. returnSuccessMsg("发票开具中,稍后刷新查看!");
  8011. return;
  8012. }
  8013. returnErrorMsg("找不到对应记录");
  8014. }
  8015. catch (Exception ex)
  8016. {
  8017. XLog.SaveLog(0, "开票失败,发生错误," + ex.Message);
  8018. returnErrorMsg("操作失败");
  8019. }
  8020. }
  8021. }
  8022. public void get_erp_invoicing_back()
  8023. {
  8024. if (UrlPostParmsCheck("id"))
  8025. {
  8026. try
  8027. {
  8028. string id = GetPostString("id");
  8029. CeErpBill entiy = CeErpBill.Get(id);
  8030. if (entiy != null)
  8031. {
  8032. if (entiy.state == 0)
  8033. {
  8034. returnErrorMsg("发票还未开具");
  8035. return;
  8036. }
  8037. string[] billOrderList = entiy.billOrderId.Split(',');
  8038. int iTag = 0;
  8039. entiy.fplsh = "";
  8040. entiy.fpdm = "";
  8041. entiy.fphm = "";
  8042. foreach (string billOrderId in billOrderList)
  8043. {
  8044. iTag++;
  8045. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8046. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8047. {
  8048. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8049. try
  8050. {
  8051. Invoicing_get_response_Obj iObj = null;
  8052. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8053. if (iObj != null)
  8054. {
  8055. entiy.state = 2;
  8056. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8057. entiy.fpdm += iObj.list[0].c_fpdm;
  8058. entiy.fphm += iObj.list[0].c_fphm;
  8059. if (iTag < billOrderList.Length)
  8060. {
  8061. entiy.fplsh += ",";
  8062. entiy.fpdm += ",";
  8063. entiy.fphm += ",";
  8064. }
  8065. entiy.Update();
  8066. }
  8067. StringBuilder sql = new StringBuilder();
  8068. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8069. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8070. returnSuccessMsg("开票成功");
  8071. }
  8072. catch (Exception ex)
  8073. {
  8074. XLog.SaveLog(0, "查看开票结果,更新状态失败" + ex.Message + res);
  8075. }
  8076. return;
  8077. }
  8078. else if (res.IndexOf("success") != -1 && res.IndexOf("开票中") != -1)
  8079. {
  8080. var res_obj = new
  8081. {
  8082. data = "开票中"
  8083. };
  8084. string ro_json = JsonConvert.SerializeObject(res_obj);
  8085. returnSuccess(ro_json);
  8086. return;
  8087. }
  8088. else
  8089. {
  8090. int eidx = res.IndexOf("c_resultmsg");
  8091. int lidx = res.IndexOf("c_status");
  8092. string emsg = commonHelper.KeepChinese(res.Substring(eidx, lidx - eidx));
  8093. entiy.state = 5;
  8094. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8095. entiy.Update();
  8096. returnErrorMsg("开票失败");
  8097. return;
  8098. }
  8099. }
  8100. }
  8101. }
  8102. catch (Exception ex)
  8103. {
  8104. XLog.SaveLog(0, "查看发票发生错误," + ex.Message);
  8105. }
  8106. return;
  8107. }
  8108. }
  8109. public void get_erp_invoicing()
  8110. {
  8111. if (UrlPostParmsCheck("id"))
  8112. {
  8113. try
  8114. {
  8115. string id = GetPostString("id");
  8116. CeErpBill entiy = CeErpBill.Get(id);
  8117. if (entiy != null)
  8118. {
  8119. if (entiy.state == 0)
  8120. {
  8121. returnErrorMsg("发票还未开具");
  8122. return;
  8123. }
  8124. if (entiy.sendType == "纸质发票")
  8125. {
  8126. if (entiy.img.Length <= 0)
  8127. {
  8128. returnErrorMsg("查无纸质发票");
  8129. return;
  8130. }
  8131. string returnres = "{\"result\":\"success\",\"list\":[{\"c_url\":\"" + entiy.img.ToString() + "\"}]}";
  8132. returnSuccess(returnres);
  8133. return;
  8134. }
  8135. string[] billOrderList = entiy.billOrderId.Split(',');
  8136. int iTag = 0;
  8137. string fpUrl = "";
  8138. entiy.fplsh = "";
  8139. entiy.fpdm = "";
  8140. entiy.fphm = "";
  8141. foreach (string billOrderId in billOrderList)
  8142. {
  8143. iTag++;
  8144. string res = taobaoHelper.get_invoicing(id, billOrderId);
  8145. if (res.IndexOf("success") != -1 && (res.IndexOf("开票成功") != -1 || res.IndexOf("开票完成") != -1))
  8146. {
  8147. //res = GetUTF8String2(Encoding.UTF8.GetBytes(res));
  8148. Invoicing_get_response_Obj iObj = null;
  8149. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(res);
  8150. if (iObj != null)
  8151. {
  8152. //entiy.state = 2;
  8153. entiy.fplsh += iObj.list[0].c_fpqqlsh;
  8154. entiy.fpdm += iObj.list[0].c_fpdm;
  8155. entiy.fphm += iObj.list[0].c_fphm;
  8156. if (iTag < billOrderList.Length)
  8157. {
  8158. entiy.fplsh += ",";
  8159. entiy.fpdm += ",";
  8160. entiy.fphm += ",";
  8161. }
  8162. entiy.Update();
  8163. fpUrl += iObj.list[0].c_url + ",";
  8164. }
  8165. //returnSuccess(res);
  8166. StringBuilder sql = new StringBuilder();
  8167. sql.AppendFormat("update CE_ErpTradeCell set IsNeedBill=2 where tid='{0}';", entiy.tid);
  8168. DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
  8169. }
  8170. else
  8171. {
  8172. int eidx = res.IndexOf("c_resultmsg");
  8173. //int lidx = res.IndexOf("c_status");
  8174. string emsg = commonHelper.KeepChinese(res.Substring(eidx, res.Length - eidx));
  8175. //开票失败
  8176. entiy.state = 5;
  8177. entiy.failerror = entiy.failerror + (iTag + "&" + emsg + "|");
  8178. entiy.Update();
  8179. returnErrorMsg("开票失败");
  8180. return;
  8181. }
  8182. }
  8183. var returnObj = new
  8184. {
  8185. data = fpUrl
  8186. };
  8187. string ro_json = JsonConvert.SerializeObject(returnObj);
  8188. returnSuccess(ro_json);
  8189. }
  8190. }
  8191. catch (Exception ex)
  8192. {
  8193. XLog.SaveLog(0, "下载查看发票发生错误," + ex.Message);
  8194. }
  8195. return;
  8196. }
  8197. }
  8198. public void save_erp_billimg()
  8199. {
  8200. if (UrlPostParmsCheck("id"))
  8201. {
  8202. string eid = GetPostString("id");
  8203. CeErpBill bill_entity = null;
  8204. if (eid.Length > 0) bill_entity = CeErpBill.Get(eid);
  8205. if (bill_entity != null)
  8206. {
  8207. bill_entity.img = GetPostString("img");
  8208. bill_entity.executeTime = DateTime.Now;
  8209. bill_entity.state = 2;
  8210. bill_entity.Update();
  8211. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "上传纸质发票", 0, 1);
  8212. returnSuccessMsg("保存成功");
  8213. }
  8214. return;
  8215. }
  8216. }
  8217. public void upd_erp_billreturnback()
  8218. {
  8219. if (UrlPostParmsCheck("id"))
  8220. {
  8221. int eid = GetPostInt("id");
  8222. CeErpBill bill_entity = null;
  8223. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8224. if (bill_entity != null)
  8225. {
  8226. bill_entity.state = 3;
  8227. bill_entity.returnReason = GetPostString("reason");
  8228. bill_entity.Update();
  8229. returnSuccessMsg("驳回成功!");
  8230. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票驳回", 0, 1);
  8231. }
  8232. return;
  8233. }
  8234. }
  8235. public void cancel_erp_bill()
  8236. {
  8237. if (UrlPostParmsCheck("id"))
  8238. {
  8239. int eid = GetPostInt("id");
  8240. int detailValue = GetPostInt("detailvalue");
  8241. CeErpBill bill_entity = null;
  8242. if (eid != 0) bill_entity = CeErpBill.Get(eid);
  8243. string cres = "";
  8244. string gres = "";
  8245. if (bill_entity != null)
  8246. {
  8247. string[] billOrderList = bill_entity.billOrderId.Split(',');
  8248. if (bill_entity.fpdm == "" && bill_entity.sendType == "电子发票")
  8249. {
  8250. int iTag = 0;
  8251. bill_entity.fplsh = "";
  8252. bill_entity.fpdm = "";
  8253. bill_entity.fphm = "";
  8254. foreach (string billOrderId in billOrderList)
  8255. {
  8256. iTag++;
  8257. gres = taobaoHelper.get_invoicing(bill_entity.ID.ToString(), billOrderId);
  8258. if (gres.IndexOf("success") != -1)
  8259. {
  8260. //gres = GetUTF8String2(Encoding.UTF8.GetBytes(gres));
  8261. Invoicing_get_response_Obj iObj = null;
  8262. iObj = JsonConvert.DeserializeObject<Invoicing_get_response_Obj>(gres);
  8263. if (iObj != null)
  8264. {
  8265. bill_entity.fplsh += iObj.list[0].c_fpqqlsh;
  8266. bill_entity.fpdm += iObj.list[0].c_fpdm;
  8267. bill_entity.fphm += iObj.list[0].c_fphm;
  8268. if (iTag < billOrderList.Length)
  8269. {
  8270. bill_entity.fplsh += ",";
  8271. bill_entity.fpdm += ",";
  8272. bill_entity.fphm += ",";
  8273. }
  8274. bill_entity.Update();
  8275. }
  8276. }
  8277. else
  8278. {
  8279. returnErrorMsg(gres);
  8280. return;
  8281. }
  8282. }
  8283. }
  8284. if (bill_entity.sendType == "纸质发票")
  8285. {
  8286. //作废
  8287. //DateTime extime = DateTime.Parse(bill_entity.executeTime.ToString());
  8288. //if (DateTime.Now.Month == extime.Month)
  8289. //{
  8290. //cres = taobaoHelper.cancel_invoicing(eid);
  8291. //if (cres.IndexOf("同步成功") != -1 && cres.IndexOf("0000") != -1 && cres.IndexOf("失败") == -1)
  8292. //{
  8293. bill_entity.state = 4;//已作废
  8294. bill_entity.Update();
  8295. returnSuccessMsg("发票已作废");
  8296. return;
  8297. //}
  8298. //else
  8299. //{
  8300. // bill_entity.failerror = bill_entity.failerror + "##||##" + cres;
  8301. // bill_entity.Update();
  8302. // returnErrorMsg(cres);
  8303. // return;
  8304. //}
  8305. //}
  8306. //else
  8307. //{
  8308. // returnErrorMsg("纸质发票只能作废本月的发票");
  8309. // return;
  8310. //}
  8311. }
  8312. //红冲
  8313. int redTag = 0;
  8314. string[] fpdmList = bill_entity.fpdm.Split(',');
  8315. string[] fphmList = bill_entity.fphm.Split(',');
  8316. if (fpdmList.Length != billOrderList.Length || fphmList.Length != billOrderList.Length)
  8317. {
  8318. returnErrorMsg("发票代码、号码个数跟发票订单ID数不一致");
  8319. return;
  8320. }
  8321. foreach (string billOrderId in billOrderList)
  8322. {
  8323. redTag++;
  8324. string onecres = taobaoHelper.invoicing_red(bill_entity.ID, CurrentUser.User.Name, billOrderId, fpdmList[redTag - 1], fphmList[redTag - 1], redTag - 1, billOrderList.Length);
  8325. cres += onecres;
  8326. cres += ",";
  8327. if (onecres.IndexOf("同步成功") != -1 && onecres.IndexOf("失败") == -1)
  8328. {
  8329. bill_entity.state = 4;//已作废
  8330. //bill_entity.Update();
  8331. //returnSuccessMsg("发票已红冲");
  8332. }
  8333. else if (onecres.IndexOf("重复冲红") != -1)
  8334. {
  8335. bill_entity.state = 4;//已作废
  8336. //bill_entity.Update();
  8337. //returnSuccessMsg("发票已红冲");
  8338. }
  8339. else
  8340. {
  8341. string errmsg = commonHelper.KeepChinese(onecres);
  8342. bill_entity.failerror += redTag + "&" + errmsg + "|";
  8343. }
  8344. }
  8345. bill_entity.Update();
  8346. if (cres.IndexOf("失败") != -1)
  8347. returnErrorMsg("红冲失败");
  8348. else
  8349. returnSuccessMsg("发票已红冲");
  8350. LogHelper.addLog(bill_entity.tid, CurrentUser.UserID, "发票红冲", 0, 1);
  8351. return;
  8352. }
  8353. return;
  8354. }
  8355. }
  8356. public void del_erp_billorder()
  8357. {
  8358. if (UrlPostParmsCheck("id"))
  8359. {
  8360. string eid = GetPostString("id");
  8361. CeErpBill.Del(eid);
  8362. CeErpBill bill = CeErpBill.Get(eid);
  8363. if (bill != null)
  8364. {
  8365. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票删除", 0, 1);
  8366. }
  8367. returnSuccessMsg("删除成功");
  8368. }
  8369. }
  8370. public void finish_erp_bill()
  8371. {
  8372. if (UrlPostParmsCheck("ids"))
  8373. {
  8374. string eids = GetPostString("ids");
  8375. string[] list = eids.Split(',');
  8376. foreach (string eid in list)
  8377. {
  8378. CeErpBill bill = CeErpBill.Get(eid);
  8379. if (bill != null)
  8380. {
  8381. bill.state = 2;
  8382. bill.Update();
  8383. LogHelper.addLog(bill.tid, CurrentUser.UserID, "发票标记成“已完成”", 0, 1);
  8384. }
  8385. }
  8386. returnSuccessMsg("操作成功");
  8387. }
  8388. }
  8389. public void get_erp_returncash()
  8390. {
  8391. DataStruct dStruct = GetPostStruct();
  8392. List<string> lw = new List<string>();
  8393. string tid = GetPostString("tid");
  8394. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8395. string shopname = GetPostString("shopname");
  8396. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  8397. string buyernick = GetPostString("buyer_nick");
  8398. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  8399. string customer = GetPostString("customer");
  8400. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  8401. string returndate1 = GetPostString("returndate1");
  8402. string returndate2 = GetPostString("returndate2");
  8403. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  8404. if (dw.Length > 0) lw.Add(dw);
  8405. string finishDate1 = GetPostString("finishdate1");
  8406. string finishDate2 = GetPostString("finishdate2");
  8407. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  8408. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8409. string returntype = GetPostString("returntype");
  8410. if (returntype.Length > 0) lw.Add(string.Format("rtype = '{0}'", returntype));
  8411. string returnvstate = GetPostString("returnvstate");
  8412. if (returnvstate.Length > 0) lw.Add(string.Format("cashstate = {0}", Convert.ToInt32(returnvstate)));
  8413. dStruct.Order = "created desc";
  8414. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8415. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  8416. writeGridDataTableJson(dStruct.TotalCount, dt);
  8417. }
  8418. public void get_erp_staygoods()
  8419. {
  8420. DataStruct dStruct = GetPostStruct();
  8421. List<string> lw = new List<string>();
  8422. string tid = GetPostString("tid");
  8423. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  8424. string shopname = GetPostString("shopname");
  8425. if (shopname.Length > 0) lw.Add(string.Format("shop_name like '%{0}%'", shopname));
  8426. string wangwang = GetPostString("wangwang");
  8427. if (wangwang.Length > 0) lw.Add(string.Format("wangwang like '%{0}%'", wangwang));
  8428. string customer = GetPostString("customer");
  8429. if (customer.Length > 0) lw.Add(string.Format("create_u_name like '%{0}%'", customer));
  8430. string returndate1 = GetPostString("returndate1");
  8431. string returndate2 = GetPostString("returndate2");
  8432. string dw = GetDateMinuteWhere("creata_time", returndate1, returndate2);
  8433. if (dw.Length > 0) lw.Add(dw);
  8434. string finishDate1 = GetPostString("finishdate1");
  8435. string finishDate2 = GetPostString("finishdate2");
  8436. string dw_finish = GetDateMinuteWhere("audit_time", finishDate1, finishDate2);
  8437. if (dw_finish.Length > 0) lw.Add(dw_finish);
  8438. string returnvstate = GetPostString("returnvstate");
  8439. if (returnvstate.Length > 0) lw.Add(string.Format("audit_type={0}", Convert.ToInt32(returnvstate)));
  8440. string persuadetype = GetPostString("persuadetype");
  8441. if (persuadetype.Length > 0) lw.Add(string.Format("stay_type like '%{0}%'", persuadetype));
  8442. string customerOrg = GetPostString("customerOrg");
  8443. if (customerOrg.Length > 0)
  8444. {
  8445. lw.Add(string.Format("OrgID = {0}", customerOrg));
  8446. }
  8447. dStruct.Order = "creata_time desc";
  8448. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8449. DataTable dt = WebCache.GetData("view_ErpStayGoods", dStruct);
  8450. writeGridDataTableJson(dStruct.TotalCount, dt);
  8451. }
  8452. public void upd_erp_staygoods()
  8453. {
  8454. if (UrlPostParmsCheck("id"))
  8455. {
  8456. int eid = GetPostInt("id");
  8457. CeErpStayGoods entity = null;
  8458. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8459. if (entity != null)
  8460. {
  8461. entity.audit_type = 1;
  8462. entity.audit_time = DateTime.Now;
  8463. entity.audit_u_id = CurrentUser.UserID;
  8464. entity.audit_u_name = CurrentUser.UserName;
  8465. entity.Update();
  8466. returnSuccessMsg("审核成功!");
  8467. return;
  8468. }
  8469. returnErrorMsg("找不到订单记录");
  8470. }
  8471. }
  8472. public void upd_erp_stayGoodsback()
  8473. {
  8474. if (UrlPostParmsCheck("id"))
  8475. {
  8476. int eid = GetPostInt("id");
  8477. CeErpStayGoods entity = null;
  8478. if (eid != 0) entity = CeErpStayGoods.GetStayId(eid);
  8479. if (entity != null)
  8480. {
  8481. entity.audit_text = GetPostString("reason");
  8482. entity.audit_type = 2;
  8483. entity.audit_time = DateTime.Now;
  8484. entity.audit_u_id = CurrentUser.UserID;
  8485. entity.audit_u_name = CurrentUser.UserName;
  8486. entity.Update();
  8487. returnSuccessMsg("退回成功!");
  8488. return;
  8489. }
  8490. returnErrorMsg("找不到订单记录");
  8491. }
  8492. }
  8493. public void upd_erp_returncashverify()
  8494. {
  8495. if (UrlPostParmsCheck("ID"))
  8496. {
  8497. int eid = GetPostInt("ID");
  8498. CeErpReturnCash entity = null;
  8499. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8500. if (entity != null)
  8501. {
  8502. entity.cashstate = 1;
  8503. entity.verifytime = DateTime.Now;
  8504. entity.verifyuserid = CurrentUser.UserID;
  8505. entity.Update();
  8506. returnSuccessMsg("审核成功!");
  8507. return;
  8508. }
  8509. returnErrorMsg("找不到订单记录");
  8510. }
  8511. }
  8512. public void upd_all_erp_returncashverify()
  8513. {
  8514. if (UrlPostParmsCheck("ID"))
  8515. {
  8516. String[] list = GetPostString("ID").Split(',');
  8517. CeErpReturnCash entity = null;
  8518. for (int i = 0; i < list.Length; i++)
  8519. {
  8520. if (list[i] != "") entity = CeErpReturnCash.Get(list[i]);
  8521. if (entity != null)
  8522. {
  8523. if (entity.cashstate == 1)
  8524. {
  8525. returnErrorMsg("已审核过的订单不需要在审核!");
  8526. return;
  8527. }
  8528. entity.cashstate = 1;
  8529. entity.verifytime = DateTime.Now;
  8530. entity.verifyuserid = CurrentUser.UserID;
  8531. entity.Update();
  8532. }
  8533. }
  8534. returnSuccessMsg("审核成功!");
  8535. return;
  8536. }
  8537. }
  8538. public void upd_erp_returncashback()
  8539. {
  8540. if (UrlPostParmsCheck("ID"))
  8541. {
  8542. int eid = GetPostInt("ID");
  8543. CeErpReturnCash entity = null;
  8544. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8545. if (entity != null)
  8546. {
  8547. entity.backreason = GetPostString("reason");
  8548. entity.cashstate = 2;
  8549. entity.verifytime = DateTime.Now;
  8550. entity.verifyuserid = CurrentUser.UserID;
  8551. entity.Update();
  8552. returnSuccessMsg("退回成功!");
  8553. return;
  8554. }
  8555. returnErrorMsg("找不到订单记录");
  8556. }
  8557. }
  8558. public void upd_erp_returnprice()
  8559. {
  8560. if (UrlPostParmsCheck("ID"))
  8561. {
  8562. int eid = GetPostInt("ID");
  8563. CeErpReturnCash entity = null;
  8564. if (eid != 0) entity = CeErpReturnCash.Get(eid);
  8565. if (entity != null)
  8566. {
  8567. if (entity.cashstate == 1)
  8568. {
  8569. returnErrorMsg("审核通过了不能改");
  8570. return;
  8571. }
  8572. entity.returnprice = GetPostDouble("returnprice");
  8573. entity.Update();
  8574. returnSuccessMsg("修改成功!");
  8575. return;
  8576. }
  8577. returnErrorMsg("找不到订单记录");
  8578. }
  8579. }
  8580. public void del_erp_returncash()
  8581. {
  8582. if (UrlPostParmsCheck("ID"))
  8583. {
  8584. int eid = GetPostInt("ID");
  8585. CeErpReturnCash.Del(eid);
  8586. returnSuccessMsg("操作成功");
  8587. return;
  8588. }
  8589. }
  8590. public void test_for_do_sql()
  8591. {
  8592. string sql = GetPostString("sqlstr");
  8593. if (sql.Length > 0)
  8594. {
  8595. try
  8596. {
  8597. DbHelper.DbConn.ExecuteNonQuery(sql);
  8598. var res_obj = new
  8599. {
  8600. data = "成功",
  8601. };
  8602. string ro_json = JsonConvert.SerializeObject(res_obj);
  8603. returnSuccess(ro_json);
  8604. }
  8605. catch (Exception ex)
  8606. {
  8607. var res_obj = new
  8608. {
  8609. data = ex.Message,
  8610. };
  8611. string ro_json = JsonConvert.SerializeObject(res_obj);
  8612. returnSuccess(ro_json);
  8613. }
  8614. }
  8615. }
  8616. public void get_user_info()
  8617. {
  8618. DataTable dtUser = DbHelper.DbConn.ExecuteDataset(string.Format("select * from view_ErpUser where id={0};", CurrentUser.UserID)).Tables[0];
  8619. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dtUser));
  8620. }
  8621. public void get_total_data()
  8622. {
  8623. int userId = CurrentUser.UserID;
  8624. string sql = "";
  8625. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8626. {
  8627. 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);
  8628. }
  8629. else
  8630. {
  8631. 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 " +
  8632. "(select ID from CE_ErpUser where ID = {0}) d " +
  8633. "left join " +
  8634. "(select CustomerUserId as id, count(CustomerUserId) as orderCount, SUM(payment) as orderAmount from[view_ErpTradeCell] where OrderState = 8 group by CustomerUserId " +
  8635. ") a on d.ID = a.id left join " +
  8636. "(select CustomerUserId as id1, count(CustomerUserId) as refundCount, SUM(payment) as refundAmount from[view_ErpTradeCell] where IsRefund > 1 group by CustomerUserId " +
  8637. ") b on a.id = b.id1 left join" +
  8638. "(select CustomerUserId as id2, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from[view_ErpTradeCell] where AfterSaleState>0 group by CustomerUserId " +
  8639. ") c on a.id = c.id2;", userId);
  8640. }
  8641. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8642. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8643. }
  8644. public void get_date_area_total_data2()
  8645. {
  8646. int userId = CurrentUser.UserID;
  8647. string date_type = GetPostString("timetype");
  8648. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8649. string sql = "";
  8650. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8651. {
  8652. sql = string.Format("select e.id, isnull(a.unBeginCount, 0) as unBeginCount,isnull(a.unBeginAmount, 0) as unBeginAmount, " +
  8653. "isnull(b.unFinishCount, 0) as unFinishCount, isnull(b.unFinishAmount, 0) as unFinishAmount, " +
  8654. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8655. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8656. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8657. "(select DesignUserId as id, count(DesignUserId) as unBeginCount, SUM(payment) as unBeginAmount from [view_ErpTradeCell] " +
  8658. " where OrderState = 3 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8659. ") a on e.ID = a.id left join " +
  8660. "(select DesignUserId as id1, count(DesignUserId) as unFinishCount, SUM(payment) as unFinishAmount from [view_ErpTradeCell] " +
  8661. " where OrderState = 4 and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8662. ") b on a.id = b.id1 " +
  8663. "left join " +
  8664. "(select DesignUserId as id2, count(DesignUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8665. " where WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}' group by DesignUserId " +
  8666. ") c on a.id = c.id2 " +
  8667. "left join " +
  8668. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8669. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8670. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,' ; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8671. }
  8672. else
  8673. {
  8674. sql = string.Format("select e.id, isnull(a.afterCount, 0) as afterCount,isnull(a.afterAmount, 0) as afterAmount, " +
  8675. "isnull(c.totalCount, 0) as totalCount, isnull(c.totalAmount, 0) as totalAmount, " +
  8676. "isnull(d.refundCount, 0) as refundCount, isnull(d.refundAmount, 0) as refundAmount from " +
  8677. "(select ID from CE_ErpUser where ID = {0}) e left join " +
  8678. "(select CustomerUserId as id, count(CustomerUserId) as afterCount, SUM(payment) as afterAmount from [view_ErpTradeCell] " +
  8679. " where AfterSaleState>0 and AfterSaleTime >= '{1}' and AfterSaleTime <= '{2}' group by CustomerUserId " +
  8680. ") a on e.ID = a.id left join " +
  8681. "(select CustomerUserId as id2, count(CustomerUserId) as totalCount, SUM(payment) as totalAmount from [view_ErpTradeCell] " +
  8682. " where pay_time >= '{1}' and pay_time <= '{2}' group by CustomerUserId " +
  8683. ") c on a.id = c.id2 " +
  8684. "left join " +
  8685. "(select ResponsibleUserId as id3, count(ResponsibleUserId) as refundCount, SUM(cast(refund_fee as numeric(8,2))) as refundAmount from [CE_ErpTradeRefund] " +
  8686. " where created >= '{1}' and created <= '{2}' group by ResponsibleUserId " +
  8687. ") d on ','+d.id3+',' like ','+CONVERT(nvarchar , a.id)+'_s,'; ", userId, searchDT[0].ToString(), searchDT[1].ToString());
  8688. }
  8689. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8690. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  8691. }
  8692. public void get_date_area_total_data()
  8693. {
  8694. int userId = CurrentUser.UserID;
  8695. string date_type = GetPostString("timetype");
  8696. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8697. string date1 = searchDT[0].ToString();
  8698. string date2 = searchDT[1].ToString();
  8699. if (CurrentUser.UserPost.Post.Code == "Designer" || CurrentUser.UserPost.Post.Code == "DesignerMr")
  8700. {
  8701. SqlParameter[] sqlParameter ={
  8702. new SqlParameter("@userId", SqlDbType.Int,4),
  8703. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8704. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8705. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8706. };
  8707. sqlParameter[0].Value = userId;
  8708. sqlParameter[1].Value = date1;
  8709. sqlParameter[2].Value = date2;
  8710. sqlParameter[3].Direction = ParameterDirection.Output;
  8711. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_des", sqlParameter);
  8712. string res = sqlParameter[3].Value.ToString();
  8713. var res_obj = new
  8714. {
  8715. data = res
  8716. };
  8717. string ro_json = JsonConvert.SerializeObject(res_obj);
  8718. returnSuccess(ro_json);
  8719. }
  8720. else
  8721. {
  8722. SqlParameter[] sqlParameter ={
  8723. new SqlParameter("@userId", SqlDbType.Int,4),
  8724. new SqlParameter("@sDisDate", SqlDbType.DateTime, 20),
  8725. new SqlParameter("@eDisDate", SqlDbType.DateTime, 20),
  8726. new SqlParameter("@res", SqlDbType.VarChar, 4000)
  8727. };
  8728. sqlParameter[0].Value = userId;
  8729. sqlParameter[1].Value = date1;
  8730. sqlParameter[2].Value = date2;
  8731. sqlParameter[3].Direction = ParameterDirection.Output;
  8732. DbHelper.DbConn.ExecuteNonQuery(CommandType.StoredProcedure, "sp_get_center_cus", sqlParameter);
  8733. string res = sqlParameter[3].Value.ToString();
  8734. var res_obj = new
  8735. {
  8736. data = res
  8737. };
  8738. string ro_json = JsonConvert.SerializeObject(res_obj);
  8739. returnSuccess(ro_json);
  8740. }
  8741. //writeGridDataViewJson(dt.Rows.Count, dv);
  8742. }
  8743. public void get_order_list()
  8744. {
  8745. string strFields = GetPostString("paraFields");
  8746. string strOrder = GetPostString("paraOrder");
  8747. string strWhere = GetPostString("paraWhere");
  8748. string strPageSize = GetPostString("paraPageSize");
  8749. DataStruct dStruct = GetPostStruct();
  8750. dStruct.PageSize = int.Parse(strPageSize);
  8751. dStruct.Fileds = strFields;
  8752. dStruct.Order = strOrder;
  8753. dStruct.MainWhere = strWhere;
  8754. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8755. writeGridDataTableJson(dStruct.TotalCount, dt);
  8756. }
  8757. ////获取待开始订单列表
  8758. //public void get_wait_design_order_list()
  8759. //{
  8760. // string date_type = GetPostString("date_type");
  8761. // List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8762. // DataStruct dStruct = GetPostStruct();
  8763. // dStruct.PageSize = 1000;
  8764. // dStruct.Fileds = "ctid, WaitDesignTime,payment,IsAutoDispatch";
  8765. // List<string> lw = new List<string>();
  8766. // lw.Add(string.Format("OrderState = 3 and DesignUserId = {0} and WaitDesignTime >= '{1}' and WaitDesignTime <= '{2}'",
  8767. // CurrentUser.UserID, searchDT[0].ToString(), searchDT[1].ToString()));
  8768. // dStruct.Order = "WaitDesignTime asc";
  8769. // dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8770. // DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  8771. // writeGridDataTableJson(dStruct.TotalCount, dt);
  8772. //}
  8773. //获取完成单量排名
  8774. public void get_finish_order_count_ranking()
  8775. {
  8776. /* string date_type = GetPostString("date_type");
  8777. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8778. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8779. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8780. "left join(select DesignUserId, COUNT(tid) as orderCount from view_ErpTradeCell " +
  8781. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8782. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8783. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8784. writeGridDataTableJson(0, new DataTable());
  8785. }
  8786. public void get_finish_order_amount_ranking()
  8787. {
  8788. /*string date_type = GetPostString("date_type");
  8789. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8790. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8791. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8792. "left join(select DesignUserId, SUM(payment) as orderAmount from view_ErpTradeCell " +
  8793. "where OrderState > 6 and OrderState < 9 and FinishDesignTime >= '{0}' and FinishDesignTime <= '{1}' group by DesignUserId) b on a.ID = b.DesignUserId " +
  8794. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8795. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];*/
  8796. writeGridDataTableJson(0, new DataTable());
  8797. }
  8798. public void get_finish_refund_count_ranking()
  8799. {
  8800. string date_type = GetPostString("date_type");
  8801. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8802. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderCount, 0) as orderCount " +
  8803. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8804. "left join(select ResponsibleUserId, COUNT(cast(refund_fee as numeric(8,2))) as orderCount from CE_ErpTradeRefund " +
  8805. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8806. "order by orderCount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8807. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8808. writeGridDataTableJson(dt.Rows.Count, dt);
  8809. }
  8810. public void get_finish_refund_amount_ranking()
  8811. {
  8812. string date_type = GetPostString("date_type");
  8813. List<DateTime> searchDT = WebHelper.GetStartEndDateTime(date_type);
  8814. string sql = string.Format("select a.Name,a.OrgName,ISNULL(b.orderAmount, 0) as orderAmount " +
  8815. "from(select * from view_ErpUser where PostCode = 'Designer' or PostCode='DesignerMr') a " +
  8816. "left join(select ResponsibleUserId, sum(cast(refund_fee as numeric(8,2))) as orderAmount from CE_ErpTradeRefund " +
  8817. "where created >= '{0}' and created <= '{1}' group by ResponsibleUserId) b on ','+b.ResponsibleUserId+',' like ','+CONVERT(nvarchar , a.ID)+'_s,' " +
  8818. "order by orderAmount desc", searchDT[0].ToString(), searchDT[1].ToString());
  8819. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  8820. writeGridDataTableJson(dt.Rows.Count, dt);
  8821. }
  8822. public void set_erp_finishorder_director()
  8823. {
  8824. if (UrlPostParmsCheck("ctid"))
  8825. {
  8826. string eid = GetPostString("ctid");
  8827. CeErpTradeCell entity = null;
  8828. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  8829. if (entity != null)
  8830. {
  8831. entity.OrderState = 8;
  8832. entity.Update();
  8833. LogHelper.addLog(eid, CurrentUser.UserID, "电子稿直接完成设计到已完成", 4, 0);
  8834. returnSuccessMsg("操作成功!");
  8835. return;
  8836. }
  8837. returnErrorMsg("找不到记录");
  8838. }
  8839. }
  8840. public void get_erp_placeregistlist()
  8841. {
  8842. DataStruct dStruct = GetPostStruct();
  8843. List<string> lw = new List<string>();
  8844. string outsid = GetPostString("outsid");
  8845. if (outsid.Length > 0) lw.Add(string.Format("OutSid like '%{0}%'", outsid));
  8846. string memo = GetPostString("memo");
  8847. if (memo.Length > 0) lw.Add(string.Format("Memo like '%{0}%'", memo));
  8848. string filename = GetPostString("filename");
  8849. if (filename.Length > 0) lw.Add(string.Format("FileName like '%{0}%'", filename));
  8850. string islate = GetPostString("islate");
  8851. if (islate.Length > 0)
  8852. {
  8853. if (islate == "1")
  8854. lw.Add(string.Format("OutLate>0"));
  8855. else
  8856. lw.Add(string.Format("OutLate=0"));
  8857. }
  8858. string placedate1 = GetPostString("placedate1");
  8859. string placedate2 = GetPostString("placedate2");
  8860. string dw = GetDateMinuteWhere("PlactTime", placedate1, placedate2);
  8861. if (dw.Length > 0) lw.Add(dw);
  8862. string deliveryDate1 = GetPostString("deliverydate1");
  8863. string deliveryDate2 = GetPostString("deliverydate2");
  8864. string dw_deli = GetDateMinuteWhere("DeliveryTime", deliveryDate1, deliveryDate2);
  8865. if (dw_deli.Length > 0) lw.Add(dw_deli);
  8866. dStruct.Order = "ID desc";
  8867. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  8868. DataTable dt = WebCache.GetData("View_ErpPlaceRegister", dStruct);
  8869. writeGridDataTableJson(dStruct.TotalCount, dt);
  8870. }
  8871. public void ins_erp_placeregist()
  8872. {
  8873. if (UrlPostParmsCheck("id"))
  8874. {
  8875. string eid = GetPostString("id");
  8876. CeErpPlaceRegister entity = null;
  8877. if (eid == "0")//新增
  8878. {
  8879. entity = new CeErpPlaceRegister();
  8880. string xdTime = GetPostString("placeTime");
  8881. if (xdTime.Length > 0)
  8882. {
  8883. entity.PlactTime = Convert.ToDateTime(xdTime);
  8884. }
  8885. string fhTime = GetPostString("deliveryTime");
  8886. if (fhTime.Length > 0)
  8887. {
  8888. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8889. }
  8890. string preTime = GetPostString("preOutTime");
  8891. if (preTime.Length > 0)
  8892. {
  8893. entity.PreOutTime = Convert.ToDateTime(preTime);
  8894. }
  8895. entity.DeliveryCount = GetPostInt("deliveryCount");
  8896. entity.ReceiveCount = GetPostInt("receiveCount");
  8897. entity.OutSid = GetPostString("outSid");
  8898. entity.FileName = GetPostString("fileName");
  8899. entity.Memo = GetPostString("memo");
  8900. entity.AddUserId = CurrentUser.UserID;
  8901. entity.CreateTime = DateTime.Now;
  8902. entity.Img = GetPostString("img");
  8903. entity.Supplier = GetPostInt("supplier");
  8904. entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8905. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8906. {
  8907. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8908. DateTime dt2 = (DateTime)entity.PreOutTime;
  8909. TimeSpan span = dt1.Subtract(dt2);
  8910. if (span.Days > 0)
  8911. {
  8912. entity.OutLate = span.Days;
  8913. }
  8914. }
  8915. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8916. entity.Create();
  8917. returnSuccessMsg("添加成功!");
  8918. return;
  8919. }
  8920. else //修改
  8921. {
  8922. entity = CeErpPlaceRegister.Get(eid);
  8923. if (entity != null)
  8924. {
  8925. string xdTime = GetPostString("placeTime");
  8926. if (xdTime.Length > 0)
  8927. {
  8928. entity.PlactTime = Convert.ToDateTime(xdTime);
  8929. }
  8930. string fhTime = GetPostString("deliveryTime");
  8931. if (fhTime.Length > 0)
  8932. {
  8933. entity.DeliveryTime = Convert.ToDateTime(fhTime);
  8934. }
  8935. string preTime = GetPostString("preOutTime");
  8936. if (preTime.Length > 0)
  8937. {
  8938. entity.PreOutTime = Convert.ToDateTime(preTime);
  8939. }
  8940. entity.DeliveryCount = GetPostInt("deliveryCount");
  8941. entity.ReceiveCount = GetPostInt("receiveCount");
  8942. if (entity.DeliveryCount == entity.ReceiveCount)
  8943. {
  8944. entity.CurState = "已完成";
  8945. }
  8946. else
  8947. {
  8948. entity.CurState = "未完成";
  8949. }
  8950. entity.OutSid = GetPostString("outSid");
  8951. entity.FileName = GetPostString("fileName");
  8952. entity.Memo = GetPostString("memo");
  8953. entity.Img = GetPostString("img");
  8954. entity.Supplier = GetPostInt("supplier");
  8955. //entity.Did = DateTime.Now.ToString("yyyyMMddHHmmss");
  8956. if (entity.PreOutTime != null && entity.DeliveryTime != null)
  8957. {
  8958. DateTime dt1 = (DateTime)entity.DeliveryTime;
  8959. DateTime dt2 = (DateTime)entity.PreOutTime;
  8960. TimeSpan span = dt1.Subtract(dt2);
  8961. if (span.Days > 0)
  8962. {
  8963. entity.OutLate = span.Days;
  8964. }
  8965. }
  8966. entity.Surplus = entity.DeliveryCount - entity.ReceiveCount;
  8967. entity.Update();
  8968. returnSuccessMsg("修改成功");
  8969. return;
  8970. }
  8971. returnErrorMsg("找不到对应的记录");
  8972. return;
  8973. }
  8974. }
  8975. returnErrorMsg("缺少必要参数");
  8976. }
  8977. public void del_erp_placeregist()
  8978. {
  8979. string eid = GetPostString("id");
  8980. CeErpPlaceRegister.Del(eid);
  8981. returnSuccessMsg("删除成功!");
  8982. return;
  8983. }
  8984. public void ins_erp_placeregistbyorder()
  8985. {
  8986. string ctid = GetPostString("ctid");
  8987. if (ctid.Length > 0)
  8988. {
  8989. StringBuilder sql = new StringBuilder();
  8990. sql.AppendFormat("select * from view_erptradecell where (ctid='{0}' or tid='{0}') and isAfterSaleOrder=0;", ctid);
  8991. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  8992. if (dt.Rows.Count > 0)
  8993. {
  8994. foreach (DataRow dr in dt.Rows)
  8995. {
  8996. CeErpPlaceRegister entity = new CeErpPlaceRegister();
  8997. entity.PlactTime = Convert.ToDateTime(dr["pay_time"]);
  8998. entity.AddUserId = CurrentUser.UserID;
  8999. entity.tid = dr["tid"].ToString();
  9000. entity.Did = Convert.ToString(dr["ctid"]);
  9001. entity.splitTag = dr["SplitTag"].ToString();
  9002. string sellmemo = Convert.ToString(dr["seller_memo"]);
  9003. string pre_ctid = commonHelper.MidStrEx(sellmemo, "[", "]"); //C1
  9004. if (pre_ctid.Length > 0)
  9005. {
  9006. sellmemo = sellmemo.Replace(pre_ctid, "");
  9007. }
  9008. sellmemo = sellmemo.Replace("[", "");
  9009. sellmemo = sellmemo.Replace("]", "");
  9010. entity.FileName = sellmemo;
  9011. string count = dr["ProductCount"].ToString();
  9012. int usecount = commonHelper.getIntCountFromString(count);
  9013. entity.DeliveryCount = usecount;
  9014. entity.CurState = "未完成";
  9015. if (Convert.ToInt32(dr["SupplierId"]) == 0)
  9016. {
  9017. entity.Supplier = 24;//dl手提袋定制
  9018. }
  9019. else
  9020. entity.Supplier = Convert.ToInt32(dr["SupplierId"]);
  9021. entity.CreateTime = DateTime.Now;
  9022. entity.Create();
  9023. }
  9024. returnSuccessMsg("操作成功");
  9025. return;
  9026. }
  9027. returnErrorMsg("没有找到对应订单");
  9028. return;
  9029. }
  9030. returnErrorMsg("缺少订单编号");
  9031. return;
  9032. }
  9033. public void get_erp_persuadelist()
  9034. {
  9035. DataStruct dStruct = GetPostStruct();
  9036. List<string> lw = new List<string>();
  9037. string ctid = GetPostString("ctid");
  9038. if (ctid.Length > 0) lw.Add(string.Format("(ctid like '%{0}%' or orderSn like '%{0}%')", ctid));
  9039. string shopname = GetPostString("shopname");
  9040. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9041. string buyernick = GetPostString("buyer_nick");
  9042. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9043. string customer = GetPostString("customer");
  9044. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  9045. string returndate1 = GetPostString("returndate1");
  9046. string returndate2 = GetPostString("returndate2");
  9047. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  9048. if (dw.Length > 0) lw.Add(dw);
  9049. string finishDate1 = GetPostString("finishdate1");
  9050. string finishDate2 = GetPostString("finishdate2");
  9051. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  9052. if (dw_finish.Length > 0) lw.Add(dw_finish);
  9053. string persuadetype = GetPostString("persuadetype");
  9054. if (persuadetype.Length > 0) lw.Add(string.Format("wechatTag={0}", Convert.ToInt32(persuadetype)));
  9055. string returnvstate = GetPostString("returnvstate");
  9056. if (returnvstate.Length > 0) lw.Add(string.Format("pstate = {0}", Convert.ToInt32(returnvstate)));
  9057. dStruct.Order = "created desc";
  9058. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9059. DataTable dt = WebCache.GetData("view_Erppersuade", dStruct);
  9060. writeGridDataTableJson(dStruct.TotalCount, dt);
  9061. }
  9062. public void upd_erp_returnpersuadeback()
  9063. {
  9064. if (UrlPostParmsCheck("ID"))
  9065. {
  9066. int eid = GetPostInt("ID");
  9067. CeErpPersuade entity = null;
  9068. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9069. if (entity != null)
  9070. {
  9071. entity.backreason = GetPostString("reason");
  9072. entity.pstate = 2;
  9073. entity.verifytime = DateTime.Now;
  9074. entity.verifyuserid = CurrentUser.UserID;
  9075. entity.Update();
  9076. returnSuccessMsg("退回成功!");
  9077. return;
  9078. }
  9079. returnErrorMsg("找不到订单记录");
  9080. }
  9081. }
  9082. public void upd_erp_returnpersuadeverify()
  9083. {
  9084. if (UrlPostParmsCheck("ID"))
  9085. {
  9086. if (CurrentUser.UserPost.Post.Code != "Summarize")
  9087. {
  9088. returnErrorMsg("暂无权限审核");
  9089. return;
  9090. }
  9091. int eid = GetPostInt("ID");
  9092. CeErpPersuade entity = null;
  9093. if (eid != 0) entity = CeErpPersuade.Get(eid);
  9094. if (entity != null)
  9095. {
  9096. entity.pstate = 1;
  9097. entity.verifytime = DateTime.Now;
  9098. entity.verifyuserid = CurrentUser.UserID;
  9099. entity.Update();
  9100. returnSuccessMsg("审核成功!");
  9101. return;
  9102. }
  9103. returnErrorMsg("找不到订单记录");
  9104. }
  9105. }
  9106. public void del_erp_persuade()
  9107. {
  9108. if (UrlPostParmsCheck("ID"))
  9109. {
  9110. int eid = GetPostInt("ID");
  9111. CeErpPersuade.Del(eid);
  9112. returnSuccessMsg("操作成功");
  9113. return;
  9114. }
  9115. }
  9116. public void get_erp_oldcustoupload()
  9117. {
  9118. DataStruct dStruct = GetPostStruct();
  9119. List<string> lw = new List<string>();
  9120. string buyernick = GetPostString("buyer_nick");
  9121. if (buyernick.Length > 0)
  9122. {
  9123. lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  9124. }
  9125. else
  9126. return;
  9127. dStruct.Order = "pay_time desc";
  9128. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9129. DataTable dt = null;
  9130. dt = WebCache.GetData("view_erptradecell", dStruct);
  9131. writeGridDataTableJson(dStruct.TotalCount, dt);
  9132. }
  9133. public void get_erp_checkorderlist()
  9134. {
  9135. DataStruct dStruct = GetPostStruct();
  9136. List<string> lw = new List<string>();
  9137. string tid = GetPostString("ctid");
  9138. if (tid.Length > 0)
  9139. {
  9140. string select_tid = getTidByCtid(tid);
  9141. lw.Add(string.Format("tid='{0}'", select_tid));
  9142. }
  9143. string shopname = GetPostString("shopname");
  9144. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  9145. string buyernick = GetPostString("buyer_nick");
  9146. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  9147. string customer = GetPostString("customer");
  9148. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  9149. string design = GetPostString("design");
  9150. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  9151. string orderState = GetPostString("orderState");
  9152. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  9153. string address = GetPostString("address");
  9154. if (address.Length > 0) lw.Add(string.Format("address like '%{0}%'", address));
  9155. string sellermemo = GetPostString("seller_memo");
  9156. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  9157. string supplier = GetPostString("supplier");
  9158. if (CurrentUser.UserPost.Post.Code == "Supplier")
  9159. {
  9160. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  9161. }
  9162. else
  9163. {
  9164. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  9165. }
  9166. string date1 = GetPostString("date1");
  9167. string date2 = GetPostString("date2");
  9168. string dw = GetDateMinuteWhere("pay_time", date1, date2);
  9169. if (dw.Length > 0) lw.Add(dw);
  9170. string placedate1 = GetPostString("placedate1");
  9171. string placedate2 = GetPostString("placedate2");
  9172. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  9173. if (fdw.Length > 0) lw.Add(fdw);
  9174. string price1 = GetPostString("price1");
  9175. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  9176. string price2 = GetPostString("price2");
  9177. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  9178. string checkst = GetPostString("checkstate");
  9179. if (checkst.Length > 0 && "10".Equals(checkst))
  9180. {
  9181. lw.Add(string.Format("CheckOut>0"));
  9182. }
  9183. else
  9184. {
  9185. if (checkst.Length > 0) lw.Add(string.Format("MemoOpt={0}", checkst));
  9186. lw.Add(string.Format("(MemoOpt=3 or MemoOpt=4)"));
  9187. }
  9188. dStruct.Order = "MemoOpt, CheckOrderTime desc, pay_time desc";
  9189. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9190. DataTable dt = WebCache.GetData("view_ErpCheckOrder", dStruct);
  9191. writeGridDataTableJson(dStruct.TotalCount, dt);
  9192. }
  9193. public void ins_erp_startCheck()
  9194. {
  9195. if (UrlPostParmsCheck("ctid"))
  9196. {
  9197. string eid = GetPostString("ctid");
  9198. CeErpTradeCell entity = null;
  9199. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9200. if (entity != null)
  9201. {
  9202. entity.MemoOpt = 4;
  9203. entity.UpdateTime = DateTime.Now;
  9204. entity.Update();
  9205. LogHelper.addLog(eid, CurrentUser.UserID, "开始查货", 4, 0);
  9206. CeErpSukuraData.createInfo(entity.ctid, 6);
  9207. returnSuccessMsg("操作成功!");
  9208. return;
  9209. }
  9210. returnErrorMsg("找不到记录");
  9211. }
  9212. }
  9213. public void upd_erp_sendXlw()
  9214. {
  9215. if (UrlPostParmsCheck("ctid"))
  9216. {
  9217. string eid = GetPostString("ctid");
  9218. CeErpTradeCell entity = null;
  9219. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9220. if (entity != null)
  9221. {
  9222. if (entity.IsSendGift == 1)
  9223. {
  9224. returnErrorMsg("请勿重复标记");
  9225. return;
  9226. }
  9227. entity.IsSendGift = 1;
  9228. entity.Update();
  9229. LogHelper.addLog(eid, CurrentUser.UserID, "送小礼物");
  9230. returnSuccessMsg("操作成功!");
  9231. return;
  9232. }
  9233. returnErrorMsg("找不到记录");
  9234. }
  9235. }
  9236. public void cancel_sendXlw()
  9237. {
  9238. if (UrlPostParmsCheck("ctid"))
  9239. {
  9240. string eid = GetPostString("ctid");
  9241. CeErpTradeCell entity = null;
  9242. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9243. if (entity != null)
  9244. {
  9245. if (entity.IsSendGift == 0)
  9246. {
  9247. returnErrorMsg("未标记小礼物");
  9248. return;
  9249. }
  9250. entity.IsSendGift = 0;
  9251. entity.Update();
  9252. LogHelper.addLog(eid, CurrentUser.UserID, "取消小礼物标记");
  9253. returnSuccessMsg("操作成功!");
  9254. return;
  9255. }
  9256. returnErrorMsg("找不到记录");
  9257. }
  9258. }
  9259. public void get_erp_designbill()
  9260. {
  9261. DataStruct dStruct = GetPostStruct();
  9262. List<string> lw = new List<string>();
  9263. int isMy = GetInt("my");
  9264. if (isMy == 1)
  9265. {
  9266. lw.Add(string.Format("uid = '{0}'", CurrentUser.UserID));
  9267. }
  9268. string tid = GetPostString("tid");
  9269. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  9270. string userName = GetPostString("design");
  9271. if (userName.Length > 0) lw.Add(string.Format("userName like '%{0}%'", userName));
  9272. string price1 = GetPostString("price1");
  9273. if (price1.Length > 0) lw.Add(string.Format("price >= '{0}'", price1));
  9274. string price2 = GetPostString("price2");
  9275. if (price2.Length > 0) lw.Add(string.Format("price <= '{0}'", price2));
  9276. string rePrice1 = GetPostString("rePrice1");
  9277. if (rePrice1.Length > 0) lw.Add(string.Format("rePrice >= '{0}'", rePrice1));
  9278. string rePrice2 = GetPostString("rePrice2");
  9279. if (rePrice2.Length > 0) lw.Add(string.Format("rePrice <= '{0}'", rePrice2));
  9280. string designerType = GetPostString("designerType");
  9281. if (designerType.Length > 0) lw.Add(string.Format("designerType = '{0}'", designerType));
  9282. string orderState = GetPostString("orderState");
  9283. if (orderState.Length > 0) lw.Add(string.Format("OrderState = {0}", Convert.ToInt32(orderState)));
  9284. string endTime1 = GetPostString("endTime1");
  9285. string endTime2 = GetPostString("endTime2");
  9286. string dw = GetDateMinuteWhere("end_time", endTime1, endTime2);
  9287. if (dw.Length > 0) lw.Add(dw);
  9288. string isDk = GetPostString("isDk");
  9289. if (isDk == "1")
  9290. {
  9291. lw.Add(string.Format("(designNum > {0} or modifyNum > {0} or (designNum = 1 and modifyNum = 1))", 1));
  9292. }
  9293. else if (isDk == "0")
  9294. {
  9295. lw.Add(string.Format("((designNum = {0} and modifyNum = {1}) or (modifyNum = {0} and designNum = {1}))", 1, 0));
  9296. }
  9297. dStruct.Order = "oid, create_time desc";
  9298. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9299. DataTable dt = WebCache.GetData("view_erpdesignerbill", dStruct);
  9300. writeGridDataTableJson(dStruct.TotalCount, dt);
  9301. }
  9302. public void upd_erp_designerbill()
  9303. {
  9304. if (UrlPostParmsCheck("ID"))
  9305. {
  9306. string eid = GetPostString("ID");
  9307. CeErpDesignerBill entity = null;
  9308. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9309. if (entity != null)
  9310. {
  9311. if (GetPostDouble("designerpirce") > 0)
  9312. {
  9313. entity.realPrice = GetPostDouble("designerpirce");
  9314. entity.update_time = DateTime.Now;
  9315. entity.update_u_id = CurrentUser.UserID;
  9316. entity.update_u_name = CurrentUser.UserName;
  9317. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改实际金额", CurrentUser.UserName, 1);
  9318. entity.Update();
  9319. returnSuccessMsg("操作成功!");
  9320. return;
  9321. }
  9322. else
  9323. {
  9324. entity.price = GetPostDouble("price");
  9325. entity.update_time = DateTime.Now;
  9326. entity.update_u_id = CurrentUser.UserID;
  9327. entity.update_u_name = CurrentUser.UserName;
  9328. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "修改预估金额", CurrentUser.UserName, 1);
  9329. entity.Update();
  9330. returnSuccessMsg("操作成功!");
  9331. return;
  9332. }
  9333. }
  9334. returnErrorMsg("找不到记录");
  9335. }
  9336. }
  9337. public void audit_erp_designerbill()
  9338. {
  9339. if (UrlPostParmsCheck("ID"))
  9340. {
  9341. string eid = GetPostString("ID");
  9342. CeErpDesignerBill entity = null;
  9343. if (eid != "") entity = CeErpDesignerBill.Get(eid);
  9344. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(eid);
  9345. if (entity != null)
  9346. {
  9347. entity.realPrice = GetPostDouble("designerpirce");
  9348. entity.update_time = DateTime.Now;
  9349. entity.update_u_id = CurrentUser.UserID;
  9350. entity.update_u_name = CurrentUser.UserName;
  9351. entity.isAudit = 1;
  9352. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9353. entity.Update();
  9354. if (orderEntity != null)
  9355. {
  9356. orderEntity.IsReadTag = 3;
  9357. orderEntity.Update();
  9358. }
  9359. returnSuccessMsg("操作成功!");
  9360. return;
  9361. }
  9362. returnErrorMsg("找不到记录");
  9363. }
  9364. }
  9365. public void all_audit_erp_designerbill()
  9366. {
  9367. if (UrlPostParmsCheck("idList"))
  9368. {
  9369. string[] list = GetPostString("idList").Split(',');
  9370. CeErpDesignerBill entity = null;
  9371. for (int i = 0; i < list.Length; i++)
  9372. {
  9373. if (list[i] != "") entity = CeErpDesignerBill.Get(list[i]);
  9374. if (entity == null) return;
  9375. CeErpTradeCell orderEntity = CeErpTradeCell.GetByCtid(entity.tid);
  9376. if (orderEntity == null) return;
  9377. if (entity.realPrice == 0) entity.realPrice = entity.price;
  9378. entity.update_time = DateTime.Now;
  9379. entity.update_u_id = CurrentUser.UserID;
  9380. entity.update_u_name = CurrentUser.UserName;
  9381. entity.isAudit = 1;
  9382. LogHelper.addDesignerBillLog(entity.tid, CurrentUser.UserID, "审批设计费", CurrentUser.UserName, 1);
  9383. entity.Update();
  9384. orderEntity.IsReadTag = 3;
  9385. orderEntity.Update();
  9386. }
  9387. returnSuccessMsg("操作成功!");
  9388. return;
  9389. }
  9390. }
  9391. public void get_erp_sameorders()
  9392. {
  9393. if (UrlPostParmsCheck("ctid"))
  9394. {
  9395. string eid = GetPostString("ctid");
  9396. CeErpTradeCell entity = null;
  9397. entity = CeErpTradeCell.GetByCtid(eid);
  9398. if (entity != null)
  9399. {
  9400. StringBuilder sql = new StringBuilder();
  9401. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  9402. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9403. var res = new
  9404. {
  9405. data = dt.Rows.Count
  9406. };
  9407. string ro_jsond = JsonConvert.SerializeObject(res);
  9408. returnSuccess(ro_jsond);
  9409. return;
  9410. }
  9411. returnErrorMsg("未找到订单");
  9412. return;
  9413. }
  9414. returnErrorMsg("缺少必要的参数");
  9415. }
  9416. public void get_erp_islasthavesameorder()
  9417. {
  9418. if (UrlPostParmsCheck("ctid"))
  9419. {
  9420. string eid = GetPostString("ctid");
  9421. string[] ctidList = eid.Split(',');
  9422. StringBuilder sql = new StringBuilder();
  9423. string tisCtid = "";
  9424. foreach (string ctid in ctidList)
  9425. {
  9426. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ctid);
  9427. if (entity != null)
  9428. {
  9429. sql = new StringBuilder();
  9430. sql.AppendFormat("select * from ce_erptradecell where orderstate=6 and tid='{0}' and SupplierId!={1};", entity.tid, entity.SupplierId);
  9431. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9432. if (dth.Rows.Count > 0)
  9433. {
  9434. tisCtid += entity.ctid;
  9435. tisCtid += ",";
  9436. }
  9437. }
  9438. }
  9439. if (tisCtid.Length > 0)
  9440. {
  9441. var res = new
  9442. {
  9443. data = tisCtid
  9444. };
  9445. string ro_jsond = JsonConvert.SerializeObject(res);
  9446. returnSuccess(ro_jsond);
  9447. }
  9448. else
  9449. {
  9450. var res = new
  9451. {
  9452. data = ""
  9453. };
  9454. string ro_jsond = JsonConvert.SerializeObject(res);
  9455. returnSuccess(ro_jsond);
  9456. }
  9457. return;
  9458. }
  9459. returnErrorMsg("缺少必要的参数");
  9460. }
  9461. public void file_client_down_url()
  9462. {
  9463. if (!UrlPostParmsCheck("userId"))
  9464. {
  9465. returnErrorMsg("缺少必要的参数");
  9466. }
  9467. returnSuccess("\"" + webConfig.ltDownLoadUrl + "\"");
  9468. }
  9469. public void checkout_form_data()
  9470. {
  9471. if (!UrlPostParmsCheck("tid"))
  9472. {
  9473. returnErrorMsg("缺少必要的参数");
  9474. }
  9475. string tid = GetPostString("tid");
  9476. CeErpOrderFormData ceErpOrderFormData = CeErpOrderFormData.GetByTid(tid);
  9477. if (ceErpOrderFormData != null)
  9478. {
  9479. string ro_jsond = JsonConvert.SerializeObject(ceErpOrderFormData);
  9480. returnSuccess(ro_jsond);
  9481. return;
  9482. }
  9483. returnErrorMsg("尚未有文件!");
  9484. }
  9485. public void back_supplier_audit()
  9486. {
  9487. int userId = CurrentUser.UserID;
  9488. StringBuilder sql = new StringBuilder();
  9489. 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);
  9490. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9491. if (dt.Rows.Count > 0)
  9492. {
  9493. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9494. }
  9495. else
  9496. {
  9497. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9498. }
  9499. }
  9500. public void back_supplier_query()
  9501. {
  9502. string eid = GetPostString("ctid");
  9503. if (eid != "")
  9504. {
  9505. StringBuilder sql = new StringBuilder();
  9506. sql.AppendFormat("select * from CE_ErpTradeCell WHERE ctid= '{0}';", eid);
  9507. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9508. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9509. }
  9510. else
  9511. {
  9512. returnErrorMsg("找不到订单记录");
  9513. return;
  9514. }
  9515. }
  9516. public void verified_to_order()
  9517. {
  9518. int userId = CurrentUser.UserID;
  9519. StringBuilder sql = new StringBuilder();
  9520. sql.AppendFormat("SELECT tid FROM CE_Withdraw WHERE userid ='{0}' and status = -1;", userId);
  9521. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9522. if (dt.Rows.Count > 0)
  9523. {
  9524. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9525. }
  9526. else
  9527. {
  9528. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  9529. }
  9530. }
  9531. public void upd_supplier_audit()
  9532. {
  9533. if (UrlPostParmsCheck("ctid"))
  9534. {
  9535. string eid = GetPostString("ctid");
  9536. string reason = GetPostString("returnreason");
  9537. CeErpTradeCell entity = null;
  9538. CeWithdraw withdraw = null;
  9539. withdraw = CeWithdraw.GetByTid(eid);
  9540. if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
  9541. if (!string.IsNullOrEmpty(eid) && eid[0] == 'N')
  9542. {
  9543. if (withdraw != null)
  9544. {
  9545. if (!withdraw.userid.Equals(CurrentUser.UserID))
  9546. {
  9547. returnSuccessMsg("您没有权限操作!");
  9548. return;
  9549. }
  9550. else
  9551. {
  9552. if (reason.Equals("1"))
  9553. {
  9554. if (entity.OrderState == -1)
  9555. {
  9556. if (entity.FinishPlaceTime == null)
  9557. {
  9558. entity.OrderState = 2;
  9559. }
  9560. else
  9561. {
  9562. entity.OrderState = 6;
  9563. }
  9564. }
  9565. entity.Update();
  9566. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9567. if (withdraw != null)
  9568. {
  9569. withdraw.status = int.Parse(reason);
  9570. withdraw.Update();
  9571. }
  9572. returnSuccessMsg("操作成功!");
  9573. return;
  9574. }
  9575. else
  9576. {
  9577. withdraw.status = int.Parse(reason);
  9578. withdraw.acknowledgingtime = DateTime.Now;
  9579. withdraw.Update();
  9580. returnSuccessMsg("查看详细请点击线下订单查询");
  9581. return;
  9582. }
  9583. }
  9584. }
  9585. // 第一个字符是 'N'
  9586. }
  9587. if (eid[0] != 'N')
  9588. {
  9589. }
  9590. if (entity != null && int.Parse(reason) == 1 && entity.OrderState > 4)
  9591. {
  9592. entity.IsVerifyToSupplier = false;
  9593. entity.IsReturn = 1;
  9594. entity.ReturnTime = DateTime.Now;
  9595. entity.ReturnReason = reason;
  9596. if (entity.OrderState == 6)
  9597. {
  9598. entity.OrderState = 5;
  9599. }
  9600. entity.Update();
  9601. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "供应商退回下单:" + reason, entity.OrderState);
  9602. if (withdraw != null)
  9603. {
  9604. withdraw.status = int.Parse(reason);
  9605. withdraw.Update();
  9606. }
  9607. returnSuccessMsg("操作成功!");
  9608. return;
  9609. }
  9610. else if (int.Parse(reason) == 2 && entity.OrderState > 2)
  9611. {
  9612. ;
  9613. if (withdraw != null)
  9614. {
  9615. withdraw.status = int.Parse(reason);
  9616. withdraw.acknowledgingtime = DateTime.Now;
  9617. withdraw.Update();
  9618. returnSuccessMsg("供应商取消撤回!");
  9619. return;
  9620. }
  9621. }
  9622. else if (entity != null && int.Parse(reason) == 1 && entity.OrderState < 0)
  9623. {
  9624. if (entity.OrderState == -1)
  9625. {
  9626. if (entity.FinishPlaceTime == null)
  9627. {
  9628. entity.OrderState = 2;
  9629. }
  9630. else
  9631. {
  9632. entity.OrderState = 3;
  9633. }
  9634. commonHelper.getCytPrice(entity);
  9635. }
  9636. entity.Update();
  9637. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "审核通过", entity.OrderState);
  9638. if (withdraw != null)
  9639. {
  9640. withdraw.status = int.Parse(reason);
  9641. withdraw.Update();
  9642. }
  9643. returnSuccessMsg("操作成功!");
  9644. return;
  9645. }
  9646. else if (int.Parse(reason) == 2 && entity.OrderState < 0)
  9647. {
  9648. if (withdraw == null)
  9649. {
  9650. returnSuccessMsg("驳回操作成功!可重新发起审核!");
  9651. return;
  9652. }
  9653. }
  9654. else if (int.Parse(reason) == 4 && entity.OrderState < 0)
  9655. {
  9656. if (withdraw != null)
  9657. {
  9658. withdraw.status = int.Parse(reason);
  9659. withdraw.acknowledgingtime = DateTime.Now;
  9660. withdraw.Update();
  9661. returnSuccessMsg("查看详细请点击线下订单查询");
  9662. return;
  9663. }
  9664. }
  9665. return;
  9666. }
  9667. }
  9668. //校验报价
  9669. public void refund_order_tip()
  9670. {
  9671. int userid = CurrentUser.UserID;
  9672. int sectionId = CurrentUser.UserPost.OrgID;
  9673. StringBuilder sql = new StringBuilder();
  9674. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' or sectionId = '{1}') and isVisit = 0 and type = 1;", userid, sectionId);
  9675. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9676. List<string> ids = new List<string>();
  9677. if (dth.Rows.Count > 0)
  9678. {
  9679. foreach (DataRow dr in dth.Rows)
  9680. {
  9681. ids.Add(dr["ID"].ToString());
  9682. }
  9683. try
  9684. {
  9685. /*string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '"+ userid + "'";
  9686. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());*/
  9687. }
  9688. catch (Exception ex)
  9689. {
  9690. }
  9691. }
  9692. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9693. }
  9694. public void refund_order_Design()
  9695. {
  9696. int userid = CurrentUser.UserID;
  9697. int sectionId = CurrentUser.UserPost.OrgID;
  9698. StringBuilder sql = new StringBuilder();
  9699. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}' ) and isVisit = 0 and type = 1;", userid);
  9700. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9701. List<string> ids = new List<string>();
  9702. if (dth.Rows.Count > 0)
  9703. {
  9704. foreach (DataRow dr in dth.Rows)
  9705. {
  9706. ids.Add(dr["ID"].ToString());
  9707. }
  9708. try
  9709. {
  9710. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where ID in ('" + string.Join(",", ids) + "');";
  9711. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9712. }
  9713. catch (Exception ex)
  9714. {
  9715. }
  9716. }
  9717. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));
  9718. }
  9719. public void change_order_info()
  9720. {
  9721. int userid = CurrentUser.UserID;
  9722. StringBuilder sql = new StringBuilder();
  9723. 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);
  9724. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9725. returnSuccess(JsonString.DataTable2MiniAjaxJson(dth));
  9726. }
  9727. public void change_win_mome()
  9728. {
  9729. if (UrlPostParmsCheck("id,ctid"))
  9730. {
  9731. string id = GetPostString("id");
  9732. string ctid = GetPostString("ctid");
  9733. CeErpMessageTip ceErpMessageTip = CeErpMessageTip.Get(id);
  9734. CeErpTradeCell ce = CeErpTradeCell.GetByCtid(ctid);
  9735. if (ce == null || ceErpMessageTip == null)
  9736. {
  9737. returnSuccessMsg("未找到对应的订单!");
  9738. return;
  9739. }
  9740. if (ce.OrderState >= 5)
  9741. {
  9742. returnSuccessMsg("已上传文件无法修改!");
  9743. return;
  9744. }
  9745. int type = GetPostInt("type");
  9746. string content = GetPostString("content");
  9747. if (type == 0)
  9748. {
  9749. content = content.Replace("(", "(");
  9750. content = content.Replace(")", ")");
  9751. string check = MidStrEx(content, "(", ")").Trim();
  9752. if (string.IsNullOrEmpty(check))
  9753. {
  9754. returnSuccessMsg("文件名格式不正确");
  9755. return;
  9756. }
  9757. }
  9758. ce.seller_memo = content;
  9759. ce.Update();
  9760. ceErpMessageTip.isVisit = true;
  9761. ceErpMessageTip.Update();
  9762. string text = type == 0 ? "同意修改:" + content : "不同意修改";
  9763. LogHelper.addLog(ce.ctid, CurrentUser.UserID, text, ce.OrderState, 1);
  9764. ApiVo apiVo = new ApiVo();
  9765. apiVo.orderNumber = ce.ctid;
  9766. apiVo.actionName = "demandDesign";
  9767. apiVo.orderRemarks = content;
  9768. apiVo.demandExamine = type + 1;
  9769. designHelper.API_WorkCore(apiVo);//demandDesign
  9770. returnSuccessMsg("修改成功!");
  9771. }
  9772. }
  9773. public static string MidStrEx(string sourse, string startstr, string endstr)
  9774. {
  9775. string result = string.Empty;
  9776. int startindex, endindex;
  9777. try
  9778. {
  9779. startindex = sourse.IndexOf(startstr);
  9780. if (startindex == -1)
  9781. return result;
  9782. string tmpstr = sourse.Substring(startindex + startstr.Length);
  9783. endindex = tmpstr.IndexOf(endstr);
  9784. if (endindex == -1)
  9785. return result;
  9786. result = tmpstr.Remove(endindex);
  9787. }
  9788. catch (Exception ex)
  9789. {
  9790. Console.WriteLine("MidStrEx Err:" + ex.Message);
  9791. }
  9792. return result;
  9793. }
  9794. public void refund_order_list()
  9795. {
  9796. int userid = CurrentUser.UserID;
  9797. int sectionId = CurrentUser.UserPost.OrgID;
  9798. StringBuilder sql = new StringBuilder();
  9799. sql.AppendFormat("select * from CE_ErpMessageTip where (userId = '{0}') and isVisit = 0;", userid, sectionId);
  9800. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  9801. DataStruct dStruct = GetPostStruct();
  9802. DataTable dt = null;
  9803. List<string> ids = new List<string>();
  9804. List<string> tids = new List<string>();
  9805. if (dth.Rows.Count > 0)
  9806. {
  9807. foreach (DataRow dr in dth.Rows)
  9808. {
  9809. tids.Add("'" + dr["tid"].ToString() + "'");
  9810. ids.Add(dr["id"].ToString());
  9811. }
  9812. try
  9813. {
  9814. string sql_pay = "update CE_ErpMessageTip set isVisit=1 where userId = '" + userid + "';";
  9815. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9816. List<string> lw = new List<string>();
  9817. lw.Add(string.Format("( tid in ({0}) )", string.Join(",", tids)));
  9818. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  9819. dt = WebCache.GetData("view_orderlist", dStruct);
  9820. }
  9821. catch (Exception ex)
  9822. {
  9823. }
  9824. }
  9825. writeGridDataTableJson(dStruct.TotalCount, dt);
  9826. /*returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dth));*/
  9827. }
  9828. //新增
  9829. public void order_batch_downloads()
  9830. {
  9831. string ceid = GetPostString("tid");
  9832. String[] tid = ceid.Split(',');
  9833. order_batch_caiyingtong(tid);
  9834. /* (string success, string errors) = UploadFiles(tid);
  9835. returnSuccessMsg(success + errors);*/
  9836. return;
  9837. }
  9838. //报价接口
  9839. public void Get_To_Quote()
  9840. {
  9841. string ceid = GetPostString("ctid");
  9842. if (ceid != null)
  9843. {
  9844. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(ceid);
  9845. if (entity != null)
  9846. {
  9847. if (entity.seller_memo.IndexOf("种子纸") > -1)
  9848. {
  9849. return;
  9850. }
  9851. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  9852. double price = 0;
  9853. if (cp == null)
  9854. {
  9855. JObject jsonObject12 = new JObject
  9856. {
  9857. { "UserId", "77886" },
  9858. { "Pwd", "lt666888" },
  9859. { "Filename", entity.seller_memo }
  9860. };
  9861. string response1 = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject12.ToString());
  9862. JObject jsonObjects1 = JObject.Parse(response1);
  9863. string ms1g = (string)jsonObjects1["msg"];
  9864. if (ms1g == "报价成功")
  9865. {
  9866. JObject jsonObject1 = (JObject)jsonObjects1["data"];
  9867. string data = (string)jsonObject1["price"];
  9868. 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 + "');";
  9869. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9870. returnSuccessMsg("获取报价成功:" + data);
  9871. price = Convert.ToDouble(data);
  9872. }
  9873. else
  9874. {
  9875. returnErrorMsg("获取报价失败,检查备注格式" + ms1g);
  9876. return;
  9877. }
  9878. }
  9879. String[] beizhu = entity.seller_memo.Split('-');
  9880. String chanp = "";
  9881. if (beizhu.Length > 0)
  9882. {
  9883. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft + "-备注:" + beizhu[1];
  9884. }
  9885. else
  9886. {
  9887. chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  9888. }
  9889. JObject jsonObject = new JObject
  9890. {
  9891. { "UserId", "77886" },
  9892. { "Pwd", "lt666888" },
  9893. { "Filename", chanp }
  9894. };
  9895. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  9896. JObject jsonObjects = JObject.Parse(response);
  9897. string msg = (string)jsonObjects["msg"];
  9898. if (msg == "报价成功")
  9899. {
  9900. JObject jsonObject1 = (JObject)jsonObjects["data"];
  9901. string data = (string)jsonObject1["price"];
  9902. 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 + "');";
  9903. CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
  9904. returnSuccessMsg("获取报价成功:" + data);
  9905. price = Convert.ToDouble(data);
  9906. }
  9907. else
  9908. {
  9909. returnErrorMsg("获取报价失败,检查备注格式" + msg);
  9910. return;
  9911. }
  9912. if (price > 0)
  9913. {
  9914. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(entity.ctid);
  9915. if (ceErpTradeCellExtend == null)
  9916. {
  9917. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  9918. ceErpTradeCellExtend.ctid = entity.ctid;
  9919. ceErpTradeCellExtend.payment_cyt = price;
  9920. ceErpTradeCellExtend.Create();
  9921. }
  9922. else
  9923. {
  9924. ceErpTradeCellExtend.payment_cyt = price;
  9925. ceErpTradeCellExtend.Update();
  9926. }
  9927. }
  9928. return;
  9929. }
  9930. }
  9931. else
  9932. {
  9933. returnErrorMsg("请至少选择一条数据");
  9934. return;
  9935. }
  9936. }
  9937. //新增
  9938. public void order_To_Supplier()
  9939. {
  9940. string ceid = GetPostString("tid");
  9941. String[] tid = ceid.Split(',');
  9942. if (tid.Length > 0)
  9943. {
  9944. try
  9945. {
  9946. for (int i = 0; i < tid.Length; i++)
  9947. {
  9948. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid[i]);
  9949. int suid = commonHelper.autoDistributeToSupplier(entity); //自动分配供应商
  9950. entity.SupplierId = suid;
  9951. string suname = commonHelper.getSupplierNameById(entity.SupplierId);
  9952. LogHelper.addLog(entity.ctid, 0, "匹配供应商:" + suname, entity.OrderState);
  9953. entity.Update();
  9954. }
  9955. }
  9956. catch (Exception ex)
  9957. {
  9958. returnErrorMsg("自动匹配供应商失败");
  9959. return;
  9960. }
  9961. }
  9962. else
  9963. {
  9964. returnErrorMsg("请至少选择一条数据");
  9965. return;
  9966. }
  9967. returnSuccessMsg("自动匹配供应商成功");
  9968. return;
  9969. }
  9970. public (string, string) UploadFiles(string[] urls)
  9971. {
  9972. string success = "";
  9973. string errors = "";
  9974. int userid = CurrentUser.UserID;
  9975. foreach (string url in urls)
  9976. {
  9977. String url1 = "http://183.250.143.56:8088/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid;
  9978. (string fileName, string base64FileContent) = DownloadAndConvertToBase64(url1);
  9979. if (!string.IsNullOrEmpty(fileName) && !string.IsNullOrEmpty(base64FileContent))
  9980. {
  9981. JObject jsonObject = new JObject
  9982. {
  9983. { "Userid", "77886" },
  9984. { "pwd", "cyt86435015" },
  9985. { "content", base64FileContent },
  9986. { "ext", Path.GetExtension(fileName) }
  9987. };
  9988. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/NewUploadFiles", jsonObject.ToString());
  9989. JObject jsonObjects = JObject.Parse(response);
  9990. string msg = (string)jsonObjects["msg"];
  9991. if (msg.Equals("上传成功"))
  9992. {
  9993. success += url + " 上传成功";
  9994. }
  9995. else
  9996. {
  9997. errors += url + " 上传失败";
  9998. }
  9999. }
  10000. else
  10001. {
  10002. errors += url + " 格式出现问题";
  10003. }
  10004. }
  10005. if (urls.Length == 0)
  10006. {
  10007. return (success, errors);
  10008. }
  10009. return (success, errors);
  10010. }
  10011. private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  10012. {
  10013. return true; //总是接受
  10014. }
  10015. public static string HttpPost(string url, string param = null)
  10016. {
  10017. HttpWebRequest request;
  10018. //如果是发送HTTPS请求
  10019. if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
  10020. {
  10021. ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  10022. request = WebRequest.Create(url) as HttpWebRequest;
  10023. request.ProtocolVersion = HttpVersion.Version10;
  10024. }
  10025. else
  10026. {
  10027. request = WebRequest.Create(url) as HttpWebRequest;
  10028. }
  10029. request.Method = "POST";
  10030. request.ContentType = "application/json";
  10031. request.Accept = "*/*";
  10032. request.Timeout = 120000;
  10033. request.AllowAutoRedirect = false;
  10034. StreamWriter requestStream = null;
  10035. WebResponse response = null;
  10036. string responseStr = null;
  10037. try
  10038. {
  10039. requestStream = new StreamWriter(request.GetRequestStream());
  10040. requestStream.Write(param);
  10041. requestStream.Close();
  10042. response = request.GetResponse();
  10043. if (response != null)
  10044. {
  10045. StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
  10046. responseStr = reader.ReadToEnd();
  10047. reader.Close();
  10048. }
  10049. }
  10050. catch (Exception ex)
  10051. {
  10052. return ex.Message;
  10053. }
  10054. finally
  10055. {
  10056. request = null;
  10057. requestStream = null;
  10058. response = null;
  10059. }
  10060. return responseStr;
  10061. }
  10062. public (string, string) DownloadAndConvertToBase64(string downloadUrl)
  10063. {
  10064. string base64FileContent;
  10065. string fileName;
  10066. using (WebClient webClient = new WebClient())
  10067. {
  10068. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(downloadUrl);
  10069. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  10070. {
  10071. using (Stream stream = response.GetResponseStream())
  10072. {
  10073. using (MemoryStream memoryStream = new MemoryStream())
  10074. {
  10075. stream.CopyTo(memoryStream);
  10076. byte[] fileBytes = memoryStream.ToArray();
  10077. base64FileContent = Convert.ToBase64String(fileBytes);
  10078. fileName = response.Headers["Content-Disposition"];
  10079. if (!string.IsNullOrEmpty(fileName))
  10080. {
  10081. int index = fileName.IndexOf("filename=", StringComparison.OrdinalIgnoreCase);
  10082. if (index >= 0)
  10083. {
  10084. fileName = fileName.Substring(index + 9).Trim('\"');
  10085. }
  10086. }
  10087. else
  10088. {
  10089. fileName = Path.GetFileName(downloadUrl);
  10090. }
  10091. }
  10092. }
  10093. }
  10094. }
  10095. return (fileName, base64FileContent);
  10096. }
  10097. //新增
  10098. public void order_batch_caiyingtong(string[] downloadUrls)
  10099. {
  10100. try
  10101. {
  10102. //遍历文件
  10103. DataStruct dStruct = GetPostStruct();
  10104. DataTable dt = null;
  10105. int userid = CurrentUser.UserID;
  10106. List<string> ids = new List<string>();//失败组
  10107. List<string> tids = new List<string>();
  10108. using (WebClient webClient = new WebClient())
  10109. {
  10110. foreach (var url in downloadUrls)
  10111. {
  10112. try
  10113. {
  10114. tids.Add("'" + url + "'");
  10115. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(url);
  10116. if (entity != null)
  10117. {
  10118. CeErpProduct cp = CeErpProduct.GetById(entity.ProductId);
  10119. if (cp == null)
  10120. {
  10121. JObject jsonObject = new JObject
  10122. {
  10123. { "Userid", "77886" },
  10124. { "pwd", "lt666888" },
  10125. { "Filename",entity.seller_memo }
  10126. };
  10127. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10128. JObject jsonObjects = JObject.Parse(response);
  10129. string msg = (string)jsonObjects["msg"];
  10130. if (msg == "报价成功")
  10131. {
  10132. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10133. DownloadAndConvertToBase64(url1);
  10134. }
  10135. else
  10136. {
  10137. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10138. }
  10139. }
  10140. else
  10141. {
  10142. String chanp = "(" + entity.ctid + ")-" + entity.ProductSize + "-" + entity.ProductCount + "-" + entity.Material + cp.PSupType + entity.Craft;
  10143. JObject jsonObject = new JObject
  10144. {
  10145. { "Userid", "77886" },
  10146. { "pwd", "lt666888" },
  10147. { "Filename",chanp }
  10148. };
  10149. string response = HttpPost("http://www.kiy.cn/m-mobile/autobaojia/LTBaojia", jsonObject.ToString());
  10150. JObject jsonObjects = JObject.Parse(response);
  10151. string msg = (string)jsonObjects["msg"];
  10152. if (msg == "报价成功")
  10153. {
  10154. String url1 = "http://localhost:54673/download.aspx?hexdata=" + url + "&onlyfile=1&userid=" + userid + "&cyt=1";
  10155. DownloadAndConvertToBase64(url1);
  10156. }
  10157. else
  10158. {
  10159. LogHelper.addLog(entity.ctid, CurrentUser.UserID, "上传彩印通接口失败,原因:" + msg, entity.OrderState);
  10160. }
  10161. }
  10162. }
  10163. // 上传文件到FTP
  10164. }
  10165. catch (Exception ex)
  10166. {
  10167. Console.WriteLine($"An error occurred: {ex.Message}");
  10168. }
  10169. }
  10170. List<string> lw = new List<string>();
  10171. lw.Add(string.Format("( OrderState < 6 )"));
  10172. lw.Add(string.Format("( ctid in ({0}) )", string.Join(",", tids)));
  10173. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10174. dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  10175. if (dt.Rows.Count > 0)
  10176. {
  10177. foreach (DataRow dr in dt.Rows)
  10178. {
  10179. ids.Add(dr["ctid"].ToString());
  10180. }
  10181. }
  10182. String ErrorMsgs = "";
  10183. foreach (String id in ids)
  10184. {
  10185. ErrorMsgs += id + ",";
  10186. }
  10187. if (ErrorMsgs.Length > 1)
  10188. {
  10189. ErrorMsgs += "上传失败,请检查备注或者是否存在附件!";
  10190. }
  10191. if (ErrorMsgs.Length < 1)
  10192. {
  10193. ErrorMsgs = "上传成功";
  10194. returnSuccessMsg(ErrorMsgs);
  10195. }
  10196. else
  10197. {
  10198. returnErrorMsg("以下订单" + ErrorMsgs);
  10199. }
  10200. }
  10201. // 删除文件夹及其内容
  10202. /* Directory.Delete(localDirectory, true);*/
  10203. }
  10204. catch { }
  10205. }
  10206. public void get_center_data()
  10207. {
  10208. int userId = CurrentUser.UserID;
  10209. string postCode = CurrentUser.UserPost.Post.Code;
  10210. List<string> lw = new List<string>();
  10211. List<string> ww = new List<string>();
  10212. DateTime currentTime = DateTime.Now;
  10213. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10214. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10215. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10216. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10217. string sql = " SELECT ";
  10218. string startTime = "2023-10-01 11:22:31";
  10219. //设计
  10220. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10221. {
  10222. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10223. 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));
  10224. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10225. 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));
  10226. }
  10227. //客服
  10228. else if (postCode == "CustomerService" || postCode == "Director")
  10229. {
  10230. lw.Add(string.Format("COALESCE ( dc.designCount, 0 ) AS designCount"));
  10231. 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));
  10232. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10233. 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));
  10234. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10235. 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));
  10236. lw.Add(string.Format("COALESCE ( bc.backCount, 0 ) AS backCount"));
  10237. 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));
  10238. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10239. 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));
  10240. }
  10241. //售后
  10242. else if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10243. {
  10244. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10245. 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));
  10246. lw.Add(string.Format("COALESCE ( rc.refundCount, 0 ) AS refundCount "));
  10247. 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));
  10248. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10249. 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));
  10250. }
  10251. //下单部
  10252. else if (postCode == "Place" || postCode == "PlaceMr")
  10253. {
  10254. lw.Add(string.Format("COALESCE ( oc.orderCount, 0 ) AS orderCount"));
  10255. 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));
  10256. lw.Add(string.Format("COALESCE ( sc.sendCount, 0 ) AS sendCount"));
  10257. 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));
  10258. }
  10259. //车间
  10260. else if (postCode == "Supplier")
  10261. {
  10262. lw.Add(string.Format("COALESCE ( cc.checkCount, 0 ) AS checkCount "));
  10263. 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));
  10264. }
  10265. DataTable dt = new DataTable();
  10266. if (lw.Count > 0)
  10267. {
  10268. sql += string.Join(" , ", lw);
  10269. sql += " FROM ";
  10270. sql += string.Join(" , ", ww);
  10271. dt = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10272. }
  10273. returnSuccess(Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt));
  10274. }
  10275. public void get_center_data_list()
  10276. {
  10277. int userId = CurrentUser.UserID;
  10278. string postCode = CurrentUser.UserPost.Post.Code;
  10279. string shopIds = CurrentUser.User.pemShop;
  10280. DataStruct dStruct = GetPostStruct();
  10281. List<string> lw = new List<string>();
  10282. DateTime currentTime = DateTime.Now;
  10283. string payTime = currentTime.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
  10284. string finishDesignTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10285. string finishPlaceTime = currentTime.AddDays(-2).ToString("yyyy-MM-dd HH:mm:ss");
  10286. string checkOrderTime = currentTime.AddHours(-6).ToString("yyyy-MM-dd HH:mm:ss");
  10287. string startTime = "2023-10-01 11:22:31";
  10288. int order_type = GetPostInt("order_type");
  10289. if (postCode == "Designer" || postCode == "Designerhd" || postCode == "DesignerMr" || postCode == "wxDesigner" || postCode == "wxDesignerMr")
  10290. {
  10291. lw.Add(string.Format("pay_time > '{0}' and DesignUserId = {1}", startTime, userId));
  10292. if (order_type == 0)
  10293. {
  10294. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10295. }
  10296. else if (order_type == 3)
  10297. {
  10298. lw.Add(string.Format("OrderState = 4 AND ReturnTime IS NOT NULL"));
  10299. }
  10300. else
  10301. {
  10302. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10303. }
  10304. }
  10305. //客服
  10306. if (postCode == "CustomerService" || postCode == "Director")
  10307. {
  10308. lw.Add(string.Format("pay_time > '{0}' and CustomerUserId = {1}", startTime, userId));
  10309. if (order_type == 0)
  10310. {
  10311. lw.Add(string.Format("pay_time < '{0}' AND OrderState < 5 AND IsReturn = 0", payTime));
  10312. }
  10313. else if (order_type == 1)
  10314. {
  10315. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10316. }
  10317. else if (order_type == 2)
  10318. {
  10319. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10320. }
  10321. else if (order_type == 3)
  10322. {
  10323. lw.Add(string.Format("OrderState = 0 AND ReturnTime IS NOT NULL"));
  10324. }
  10325. else if (order_type == 4)
  10326. {
  10327. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10328. }
  10329. else
  10330. {
  10331. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10332. }
  10333. }
  10334. //售后
  10335. if (postCode == "AfterSale" || postCode == "AfterSaleMaster")
  10336. {
  10337. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10338. if (shopIds != "")
  10339. {
  10340. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10341. }
  10342. if (order_type == 2)
  10343. {
  10344. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10345. }
  10346. else if (order_type == 4)
  10347. {
  10348. lw.Add(string.Format("IsRefund > 0 AND OrderState NOT IN ( 8, 9 )"));
  10349. }
  10350. else if (order_type == 5)
  10351. {
  10352. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) ", checkOrderTime));
  10353. }
  10354. else
  10355. {
  10356. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10357. }
  10358. }
  10359. //下单部
  10360. if (postCode == "Place" || postCode == "PlaceMr")
  10361. {
  10362. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10363. if (shopIds != "")
  10364. {
  10365. lw.Add(string.Format("ShopId in ({0})", shopIds));
  10366. }
  10367. else if (order_type == 1)
  10368. {
  10369. lw.Add(string.Format("FinishDesignTime < '{0}' AND OrderState = 5 AND IsReturn = 0", finishDesignTime));
  10370. }
  10371. else if (order_type == 2)
  10372. {
  10373. lw.Add(string.Format("FinishPlaceTime < '{0}' AND OrderState = 6 AND IsReturn = 0", finishPlaceTime));
  10374. }
  10375. else
  10376. {
  10377. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10378. }
  10379. }
  10380. //车间
  10381. if (postCode == "Supplier")
  10382. {
  10383. lw.Add(string.Format("pay_time > '{0}' ", startTime));
  10384. if (order_type == 5)
  10385. {
  10386. lw.Add(string.Format("CheckOrderTime < '{0}' AND (CheckMemo IS NULL OR CheckMemo = '') AND (MemoOpt=3 or MemoOpt=4) AND SupplierId = {1}", checkOrderTime, userId));
  10387. }
  10388. else
  10389. {
  10390. writeGridDataTableJson(dStruct.TotalCount, new DataTable());
  10391. }
  10392. }
  10393. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10394. dStruct.Fileds = "tid,ctid";
  10395. DataTable dt = WebCache.GetData("CE_ErpTradeCell", dStruct);
  10396. writeGridDataTableJson(dStruct.TotalCount, dt);
  10397. }
  10398. public void aftersale_audit_master()
  10399. {
  10400. if (UrlPostParmsCheck("ctid"))
  10401. {
  10402. string ctid = GetPostString("ctid");
  10403. if (ctid.Length > 0)
  10404. {
  10405. bool result = aftersale_data_change(ctid);
  10406. if (result)
  10407. {
  10408. returnSuccessMsg("修改成功!");
  10409. return;
  10410. }
  10411. }
  10412. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10413. }
  10414. }
  10415. public void aftersale_batch_audit_master()
  10416. {
  10417. if (UrlPostParmsCheck("ctids"))
  10418. {
  10419. string ctids = GetPostString("ctids");
  10420. if (ctids.Length > 0)
  10421. {
  10422. List<string> list = new List<string>();
  10423. string[] ctid_list = ctids.Split(',');
  10424. foreach (var item in ctid_list)
  10425. {
  10426. bool result = aftersale_data_change(item);
  10427. if (!result)
  10428. {
  10429. list.Add(item);
  10430. }
  10431. }
  10432. if (list.Count > 0)
  10433. {
  10434. returnSuccessMsg(list.Count + "个订单修改失败!" + string.Join(",", list));
  10435. return;
  10436. }
  10437. returnSuccessMsg("修改成功!");
  10438. return;
  10439. }
  10440. returnErrorMsg("找不到指定售后单对应的原始订单!");
  10441. }
  10442. }
  10443. public bool aftersale_data_change(string ctid)
  10444. {
  10445. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10446. if (ceErpTradeCell != null)
  10447. {
  10448. ceErpTradeCell.AfterSaleSupplierMemo = "";//重置不认同
  10449. ceErpTradeCell.AfterSaleSupplierState = 0;
  10450. StringBuilder sql = new StringBuilder();
  10451. sql.AppendFormat("select type,UserId,ID,OrgPath,OrgID from view_ErpTradeResponsible where tid='{0}' and VerifyState > -1", ctid);
  10452. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  10453. CeErpTradeResponsible.DelByTid(ctid, 0);
  10454. 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 == "不理赔")
  10455. {
  10456. CeErpTradeResponsible.DelByTid(ctid, 1);
  10457. ceErpTradeCell.AfterSaleSupplierState = 1;
  10458. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10459. ceErpTradeCell.AfterSaleState = 4;
  10460. }
  10461. else
  10462. {
  10463. ceErpTradeCell.AfterSaleState = 3;
  10464. }
  10465. bool needCyt = false;
  10466. if (dt != null)
  10467. {
  10468. if (dt.Rows.Count == 1)
  10469. {
  10470. bool isEnd = false;
  10471. foreach (DataRow dr in dt.Rows)
  10472. {
  10473. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10474. {
  10475. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10476. isEnd = true;
  10477. }
  10478. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0 && Convert.ToInt32(dr["UserId"]) == 2125)//设计系统
  10479. {
  10480. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10481. isEnd = true;
  10482. }
  10483. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10484. {
  10485. needCyt = true;
  10486. }
  10487. }
  10488. if (isEnd)
  10489. {
  10490. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10491. ceErpTradeCell.AfterSaleState = 4;
  10492. ceErpTradeCell.AfterSaleSupplierState = 1;
  10493. }
  10494. }
  10495. else
  10496. {
  10497. bool isAll = true;
  10498. foreach (DataRow dr in dt.Rows)
  10499. {
  10500. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 2 && Convert.ToInt32(dr["UserId"]) != 101)//物流
  10501. {
  10502. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10503. continue;
  10504. }
  10505. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 0)
  10506. {
  10507. string path = "";
  10508. int OrgID = 0;
  10509. if (!Convert.IsDBNull(dr["OrgPath"]))
  10510. {
  10511. path = dr["OrgPath"].ToString();
  10512. }
  10513. if (!Convert.IsDBNull(dr["OrgID"]))
  10514. {
  10515. OrgID = Convert.ToInt32(dr["OrgID"]);
  10516. }
  10517. if (!path.Contains("|2|") && OrgID != 2 && !path.Contains("|3|") && OrgID != 3 && !path.Contains("|4|") && OrgID != 4)//客服、设计、下单
  10518. {
  10519. CeErpTradeResponsible.DelById(dr["ID"], 1);
  10520. continue;
  10521. }
  10522. }
  10523. if (!Convert.IsDBNull(dr["type"]) && Convert.ToInt32(dr["type"]) == 1 && Convert.ToInt32(dr["UserId"]) == 64)
  10524. {
  10525. needCyt = true;
  10526. }
  10527. isAll = false;
  10528. }
  10529. if (isAll)
  10530. {
  10531. ceErpTradeCell.FinishAfterSaleTime = DateTime.Now;
  10532. ceErpTradeCell.AfterSaleState = 4;
  10533. ceErpTradeCell.AfterSaleSupplierState = 1;
  10534. }
  10535. }
  10536. }
  10537. if (needCyt && ceErpTradeCell.AfterSaleState != 4)
  10538. {
  10539. commonHelper.sendCytAfterSale(ceErpTradeCell);
  10540. }
  10541. if (ceErpTradeCell.AfterSaleState == 4)
  10542. {
  10543. ApiVo apiVo = new ApiVo();
  10544. apiVo.orderNumber = ceErpTradeCell.ctid;
  10545. apiVo.actionName = "afterOver";
  10546. designHelper.API_WorkCore(apiVo); //afterOver
  10547. }
  10548. ceErpTradeCell.Update();
  10549. CeErpTradeResponsible.dateByTid(ceErpTradeCell.ctid);
  10550. CeErpSukuraData.createInfo(ceErpTradeCell.ctid, 8);
  10551. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "通过售后单", ceErpTradeCell.OrderState, ceErpTradeCell.AfterSaleState);
  10552. return true;
  10553. }
  10554. return false;
  10555. }
  10556. public void get_erp_wechatorder()
  10557. {
  10558. DataStruct dStruct = GetPostStruct();
  10559. List<string> lw = new List<string>();
  10560. string tid = GetPostString("tid");
  10561. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10562. string shopname = GetPostString("shopname");
  10563. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10564. string buyernick = GetPostString("buyer_nick");
  10565. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10566. string customer = GetPostString("customer");
  10567. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10568. string returndate1 = GetPostString("returndate1");
  10569. string returndate2 = GetPostString("returndate2");
  10570. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10571. if (dw.Length > 0) lw.Add(dw);
  10572. string finishDate1 = GetPostString("finishdate1");
  10573. string finishDate2 = GetPostString("finishdate2");
  10574. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10575. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10576. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10577. dStruct.Order = "created desc";
  10578. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10579. DataTable dt = WebCache.GetData("view_ErpReturnCash", dStruct);
  10580. writeGridDataTableJson(dStruct.TotalCount, dt);
  10581. }
  10582. public void get_erp_wechatlist_sumprice()
  10583. {
  10584. DataStruct dStruct = GetPostStruct();
  10585. List<string> lw = new List<string>();
  10586. string tid = GetPostString("tid");
  10587. if (tid.Length > 0) lw.Add(string.Format("tid like '%{0}%'", tid));
  10588. string shopname = GetPostString("shopname");
  10589. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  10590. string buyernick = GetPostString("buyer_nick");
  10591. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  10592. string customer = GetPostString("customer");
  10593. if (customer.Length > 0) lw.Add(string.Format("applyUserName like '%{0}%'", customer));
  10594. string returndate1 = GetPostString("returndate1");
  10595. string returndate2 = GetPostString("returndate2");
  10596. string dw = GetDateMinuteWhere("created", returndate1, returndate2);
  10597. if (dw.Length > 0) lw.Add(dw);
  10598. string finishDate1 = GetPostString("finishdate1");
  10599. string finishDate2 = GetPostString("finishdate2");
  10600. string dw_finish = GetDateMinuteWhere("verifytime", finishDate1, finishDate2);
  10601. if (dw_finish.Length > 0) lw.Add(dw_finish);
  10602. lw.Add(string.Format("rtype = '{0}'", "微信返现"));
  10603. string mainWhere = string.Join(" and ", lw.ToArray());
  10604. string sql = "select sum(payment) as sumpayment from view_ErpReturnCash where " + mainWhere;
  10605. DataSet dataSet = DbHelper.DbConn.ExecuteDataset(sql);
  10606. DataTable dt = dataSet == null ? new DataTable() : dataSet.Tables[0];
  10607. decimal total = 0;
  10608. if (dt.Rows.Count > 0 && Convert.ToString(dt.Rows[0]["sumpayment"]) != "")
  10609. {
  10610. total = Convert.ToDecimal(dt.Rows[0]["sumpayment"]);
  10611. }
  10612. var res = new
  10613. {
  10614. data = total
  10615. };
  10616. string ro_jsond = JsonConvert.SerializeObject(res);
  10617. returnSuccess(ro_jsond);
  10618. return;
  10619. }
  10620. public void get_erp_qr_waitdeliverylist()
  10621. {
  10622. DataStruct dStruct = GetPostStruct();
  10623. List<string> lw = new List<string>();
  10624. string tid = GetPostString("ctid");
  10625. if (tid.Length > 0) lw.Add(string.Format("ctid = '{0}' ", tid));
  10626. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10627. DataTable dt = WebCache.GetData("view_erptradecell", dStruct);
  10628. var res_objz = new
  10629. {
  10630. restype = 1,
  10631. data = dt
  10632. };
  10633. string ro_jsonz = JsonConvert.SerializeObject(res_objz);
  10634. returnSuccess(ro_jsonz);
  10635. }
  10636. public void get_erp_yield_list()
  10637. {
  10638. DataStruct dStruct = GetPostStruct();
  10639. List<string> lw = new List<string>();
  10640. string tid = GetPostString("ctid");
  10641. if (tid.Length > 0) lw.Add(string.Format("tid = '{0}' ", tid));
  10642. string shopname = GetPostString("shopname");
  10643. if (shopname.Length > 0) lw.Add(string.Format("seller_nick='{0}'", shopname));
  10644. string buyernick = GetPostString("buyer_nick");
  10645. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick='{0}'", buyernick));
  10646. //if (tid.Length == 0 && buyernick.Length == 0)
  10647. //{
  10648. // lw.Add(string.Format("IsRefund<={0}", 1));
  10649. //}
  10650. string customer = GetPostString("customer");
  10651. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  10652. string design = GetPostString("design");
  10653. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  10654. string orderState = GetPostString("orderState");
  10655. if (orderState.Length > 0) lw.Add(string.Format("OrderState like '%{0}%'", orderState));
  10656. string address = GetPostString("address");
  10657. 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));
  10658. string sellermemo = GetPostString("seller_memo");
  10659. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  10660. string supplier = GetPostString("supplier");
  10661. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  10662. string OrderArea = GetPostString("order_area");
  10663. if (OrderArea.Length > 0) lw.Add(string.Format("IsSample = {0}", OrderArea));
  10664. string placedate1 = GetPostString("placedate1");
  10665. string placedate2 = GetPostString("placedate2");
  10666. string fdw = GetDateMinuteWhere("FinishPlaceTime", placedate1, placedate2);
  10667. if (fdw.Length > 0) lw.Add(fdw);
  10668. string price1 = GetPostString("price1");
  10669. if (price1.Length > 0) lw.Add(string.Format("payment >= '{0}'", price1));
  10670. string price2 = GetPostString("price2");
  10671. if (price2.Length > 0) lw.Add(string.Format("payment <= '{0}'", price2));
  10672. string unusualCon = GetPostString("unusualcon");
  10673. if (unusualCon.Length > 0) lw.Add(string.Format("UnusualCon like '%{0}%'", unusualCon));
  10674. string posTag = CurrentUser.UserPost.Post.Code;
  10675. if (posTag == "Supplier")
  10676. {
  10677. lw.Add(string.Format("SupplierId in ({0})", CurrentUser.User.pemVend));
  10678. }
  10679. lw.Add(string.Format("OrderState = 6 "));
  10680. lw.Add(string.Format("(IsXianHuo=0 or (IsXianHuo=1 and IsReturn=0)) "));
  10681. dStruct.Order = "MemoOpt desc,IsSF desc, FinishPlaceTime desc, ctid desc";
  10682. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  10683. DataTable dt = WebCache.GetData("view_supYield", dStruct);
  10684. writeGridDataTableJson(dStruct.TotalCount, dt);
  10685. }
  10686. public void change_erp_sup_state()
  10687. {
  10688. if (UrlPostParmsCheck("ctid"))
  10689. {
  10690. string ctid = GetPostString("ctid");
  10691. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10692. if (ceErpTradeCell != null)
  10693. {
  10694. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10695. if (ceErpTradeCellExtend == null)
  10696. {
  10697. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10698. ceErpTradeCellExtend.ctid = ctid;
  10699. ceErpTradeCellExtend.SupState = 1;
  10700. ceErpTradeCellExtend.Create();
  10701. }
  10702. else
  10703. {
  10704. ceErpTradeCellExtend.SupState = 1;
  10705. ceErpTradeCellExtend.Update();
  10706. }
  10707. LogHelper.addLog(ctid, CurrentUser.UserID, "标记已生产", 6);
  10708. returnSuccess(JsonConvert.SerializeObject(new { tid = ceErpTradeCell.tid }));
  10709. return;
  10710. }
  10711. returnErrorMsg("找不到订单");
  10712. }
  10713. }
  10714. public void supplier_all_downs()
  10715. {
  10716. if (UrlPostParmsCheck("tids"))
  10717. {
  10718. string tids = GetPostString("tids");
  10719. if (tids != null && tids.Length > 0)
  10720. {
  10721. StringBuilder sql = new StringBuilder();
  10722. sql.AppendFormat("update CE_ErpTradeCell set OrderState = 6,UpdateTime=getdate() where ctid in ({0}) ;", ("'" + tids.Replace(",", "','") + "'"));
  10723. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10724. sql = new StringBuilder();
  10725. 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, "下载设计文件");
  10726. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  10727. string[] list = tids.Split(',');
  10728. foreach (string ctid in list)
  10729. {
  10730. CeErpSukuraData.createInfo(ctid, 3);
  10731. }
  10732. designHelper.api_approveDesign(tids); //approveDesign
  10733. returnSuccessMsg("下载成功!");
  10734. return;
  10735. }
  10736. returnErrorMsg("下载订单更新失败");
  10737. }
  10738. }
  10739. public void uploaderFileSuccess()
  10740. {
  10741. if (UrlPostParmsCheck("fileName"))
  10742. {
  10743. string fileName = GetPostString("fileName");
  10744. ApiVo apiVo = new ApiVo();
  10745. apiVo.orderNumber = fileName;
  10746. apiVo.actionName = "finishDesign";
  10747. designHelper.API_WorkCore(apiVo);//finishDesign
  10748. returnSuccessMsg("");
  10749. }
  10750. }
  10751. public void get_sample2_order()
  10752. {
  10753. if (UrlPostParmsCheck("ctid"))
  10754. {
  10755. string ctid = GetPostString("ctid");
  10756. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10757. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  10758. string sql = "select payment from ce_erptradecell where IsSample = 2 and IsRefund = 0 and ptid='" + ceErpTradeCell.tid + "'";
  10759. DataTable dt_bu = CeErpTradeCell.ExecuteDataset(sql).Tables[0];
  10760. double total = 0.0;
  10761. double order_price = 0.0;
  10762. if (dt_bu.Rows.Count > 0)
  10763. {
  10764. foreach (DataRow dr in dt_bu.Rows)
  10765. {
  10766. total += Convert.ToDouble(dr["payment"]);
  10767. }
  10768. }
  10769. order_price = Convert.ToDouble(Math.Round(ceErpTradeCell.payment / ceErpTrade.payment * total, 2));
  10770. string after_sql = "select top 1 ReturnReason from ce_erptradecell where IsReturn=3 and ctid='" + "S_" + ceErpTradeCell.ctid + "'";
  10771. DataTable dt_after = CeErpTradeCell.ExecuteDataset(after_sql).Tables[0];
  10772. string tid = ctid.Replace("S_", "");
  10773. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(tid);
  10774. double paymant = 0.0;
  10775. if (entity != null)
  10776. {
  10777. paymant = entity.payment;
  10778. }
  10779. string return_reason = "";
  10780. if (dt_after != null && dt_after.Rows.Count > 0)
  10781. {
  10782. return_reason = dt_after.Rows[0]["ReturnReason"].ToString();
  10783. }
  10784. returnSuccess(JsonConvert.SerializeObject(new { total, order_price, total_order = ceErpTradeCell.payment, return_reason, paymant }));
  10785. }
  10786. }
  10787. public void get_erp_design_status()
  10788. {
  10789. string designName = GetPostString("designName");
  10790. DataStruct dStruct = GetPostStruct();
  10791. if (designName.Length > 0)
  10792. {
  10793. 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";
  10794. sql_user += " and Name like '%" + designName + "%'";
  10795. DataTable user_table = DbHelper.DbConn.ExecuteDataset(sql_user).Tables[0];
  10796. List<string> ids_list = new List<string>();
  10797. if (user_table.Rows.Count > 0)
  10798. {
  10799. foreach (DataRow item in user_table.Rows)
  10800. {
  10801. ids_list.Add(item["id"].ToString());
  10802. string ids_s = item["TeamIds"].ToString();
  10803. if (ids_s.Length > 0)
  10804. {
  10805. ids_list.AddRange(ids_s.Split(','));
  10806. }
  10807. }
  10808. }
  10809. HashSet<string> set = new HashSet<string>(ids_list);
  10810. ids_list = set.ToList();
  10811. if (ids_list.Count > 0)
  10812. {
  10813. 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));
  10814. dStruct.MainWhere = sql;
  10815. DataTable dt = null;
  10816. dt = WebCache.GetData("view_ErpUser", dStruct);
  10817. writeGridDataTableJson(dStruct.TotalCount, dt);
  10818. }
  10819. }
  10820. }
  10821. public void change_erp_order_price()
  10822. {
  10823. string ctid = GetPostString("ctid");
  10824. double price = GetPostDouble("price");
  10825. if (ctid.Length > 0)
  10826. {
  10827. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  10828. if (ceErpTradeCellExtend == null)
  10829. {
  10830. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  10831. ceErpTradeCellExtend.ctid = ctid;
  10832. ceErpTradeCellExtend.payment_cyt = price;
  10833. ceErpTradeCellExtend.Create();
  10834. }
  10835. else
  10836. {
  10837. ceErpTradeCellExtend.payment_cyt = price;
  10838. ceErpTradeCellExtend.Update();
  10839. }
  10840. CeErpDataSendOrderInfo ceErpDataSendOrderInfo = CeErpDataSendOrderInfo.GetByCtid(ctid);
  10841. if (ceErpDataSendOrderInfo != null && ceErpDataSendOrderInfo.ID > 0)
  10842. {
  10843. ceErpDataSendOrderInfo.isSync = false;
  10844. ceErpDataSendOrderInfo.Update();
  10845. }
  10846. if (ceErpDataSendOrderInfo == null)
  10847. {
  10848. ceErpDataSendOrderInfo = new CeErpDataSendOrderInfo();
  10849. ceErpDataSendOrderInfo.isSync = false;
  10850. ceErpDataSendOrderInfo.ctid = ctid;
  10851. ceErpDataSendOrderInfo.Create();
  10852. }
  10853. LogHelper.addLog(ctid, CurrentUser.UserID, "修改order_price成功", 6);
  10854. string sql = string.Format("select * from view_dataSendOrderInfo where ctid='{0}'", ctid);
  10855. DataTable dth = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10856. if (dth != null && dth.Rows.Count > 0)
  10857. {
  10858. dataSendOrderBean dataSendOrderBean = null;
  10859. foreach (DataRow item in dth.Rows)
  10860. {
  10861. try
  10862. {
  10863. dataSendOrderBean = new dataSendOrderBean();
  10864. dataSendOrderBean.Date1723191218572 = item["pay_time"].ToString();
  10865. dataSendOrderBean.RelevanceForm1723191634028 = item["SupplierId"].ToString();
  10866. dataSendOrderBean.RelevanceForm1723191239149 = item["ShopId"].ToString();
  10867. dataSendOrderBean.Date1723193880305 = item["FinishDeliveryTime"].ToString();
  10868. dataSendOrderBean.Date1723193870660 = item["FinishPlaceTime"].ToString();
  10869. dataSendOrderBean.LongText1723542734262 = item["seller_memo"].ToString();
  10870. dataSendOrderBean.ShortText1723542735637 = item["OtherMemo"].ToString();
  10871. dataSendOrderBean.ShortText1723542736542 = item["address"].ToString();
  10872. dataSendOrderBean.ShortText1723193907492 = item["OutSid"].ToString();
  10873. dataSendOrderBean.Number1723193919446 = item["payment_cyt"].ToString();
  10874. dataSendOrderBean.ShortText1723707899761 = item["ctid"].ToString();
  10875. dataSendOrderBean.Radio1723534706288 = item["IsReturn"].ToString() == "0" ? "未结算" : "打回";
  10876. dataResponseVo result = dataHelper.CreateBoFahuo(dataSendOrderBean);
  10877. if (result != null)
  10878. {
  10879. if ("0".Equals(result.errcode))
  10880. {
  10881. CeErpDataSendOrderInfo.updateAsync(item["ctid"].ToString(), JsonConvert.SerializeObject(dataSendOrderBean));
  10882. }
  10883. else
  10884. {
  10885. CeErpDataSendOrderInfo.updateError(item["ctid"].ToString(), result.errmsg, JsonConvert.SerializeObject(dataSendOrderBean));
  10886. }
  10887. }
  10888. }
  10889. catch (Exception ex)
  10890. {
  10891. }
  10892. }
  10893. }
  10894. returnSuccessMsg("修改成功!");
  10895. return;
  10896. }
  10897. returnErrorMsg("找不到订单");
  10898. }
  10899. public void find_he_together()
  10900. {
  10901. string ctid = GetPostString("ctid");
  10902. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  10903. List<string> list = new List<string>();
  10904. if (ceErpTradeCell != null)
  10905. {
  10906. if (ceErpTradeCell.seller_memo.Contains("合包"))//有合包标识
  10907. {
  10908. 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);
  10909. DataTable table = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10910. if (table != null && table.Rows.Count > 0)
  10911. {
  10912. foreach (TableRow row in table.Rows)
  10913. {
  10914. }
  10915. }
  10916. }
  10917. }
  10918. returnSuccess(JsonConvert.SerializeObject(new { list }));
  10919. }
  10920. Dictionary<int, Dictionary<string, string>> supplierMap = new Dictionary<int, Dictionary<string, string>>()
  10921. {
  10922. //chy----19
  10923. {19, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, { "宣传单", "宣传单" }, { "手提袋", "手提袋" } }},
  10924. //GD-CYT-----64
  10925. {64, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"杯套", "杯套"}}},
  10926. //ZHX----3
  10927. {3, new Dictionary<string, string> {{"不干胶", "不干胶"}, {"卡片", "卡片"}, {"插卡", "插卡"}, {"uv", "uv"}, { "班旗", "班旗" }}},
  10928. //JK----97
  10929. {97, new Dictionary<string, string> {{"uv", "uv"}}},
  10930. //ZT----70
  10931. {70, new Dictionary<string, string> {{"uv", "uv"}}},
  10932. //LHCY-----98
  10933. {98, new Dictionary<string, string> {{"条幅", "条幅"}, {"帆布", "帆布"}, { "贡缎布", "贡缎布" }, { "纱幔", "纱幔" }, { "班旗", "班旗" } }},
  10934. //XD-----90
  10935. {90, new Dictionary<string, string> {{"条幅", "条幅"}, {"桌布", "桌布"}, { "班旗", "班旗" } }},
  10936. //CYCY-----14
  10937. {14, new Dictionary<string, string> {{"卡片", "卡片"}, {"宣传单", "宣传单"}, {"杯套", "杯套"}}}
  10938. };
  10939. //其他改名
  10940. Dictionary<int, string> suppliers = new Dictionary<int, string>()
  10941. {
  10942. {15,"滴塑" }, {119,"数码" }, {110,"刮刮卡" }, {10,"数码" },
  10943. {5,"海报" }, {80,"数码" }, {96,"数码" }, {9,"金属标" },
  10944. {7,"综合" }, {116,"棉卡" }, {59,"海报" }, {37,"不干胶" },
  10945. {81,"金属标" }, {30,"卡片" }, {111,"种子纸" }, {72,"金属标" },
  10946. {13,"数码" }, {45,"卷标" }, {31,"联单" }, {118,"海报" },
  10947. {71,"数码" }, {70,"uv" },{93,"金属标" },{105,"uv" },{97,"数码" },
  10948. {49,"暖心贴" }, {117,"手提袋" },{108,"写真布" },{44,"PVC" },{32,"扇子" },
  10949. {4,"不干胶" },{106,"不干胶" },{94,"纸杯" },{100,"暖心贴" },{114,"定制衫" }
  10950. };
  10951. //不统计
  10952. List<int> no_suppliers = new List<int>()
  10953. {
  10954. 84,33,48,25,50,2,56,109,12,8,16,12,8,35,87
  10955. };
  10956. //配件单
  10957. Dictionary<string, List<string>> maps = new Dictionary<string, List<string>>()
  10958. {
  10959. {"绳子",new List<string>(){"帆布", "卡片", "吊牌", "旗帜布" } },
  10960. {"棉绳",new List<string>(){ "卡片", "吊牌" } },
  10961. {"别针",new List<string>(){ "卡片", "吊牌" } },
  10962. {"刮刮膜",new List<string>(){ "卡片", "刮刮卡" } },
  10963. {"流苏",new List<string>(){ "卡片", "吊牌" } },
  10964. {"旗杆",new List<string>(){ "班旗" } },
  10965. {"牙签",new List<string>(){ "不干胶" } }
  10966. };
  10967. public void get_place_order_data()
  10968. {
  10969. string date1 = GetPostString("date1");
  10970. string date2 = GetPostString("date2");
  10971. string starttime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00");
  10972. DateTime start = DateTime.Parse(starttime);
  10973. string endtime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59");
  10974. DateTime end = DateTime.Parse(endtime);
  10975. if (date1 != null && date1.Length > 0)
  10976. {
  10977. DateTime dateTime = DateTime.Parse(date1);
  10978. starttime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10979. start = DateTime.Parse(starttime);
  10980. endtime = dateTime.ToString("yyyy-MM-dd 23:59:59");
  10981. end = DateTime.Parse(endtime);
  10982. }
  10983. if (date2 != null && date2.Length > 0)
  10984. {
  10985. DateTime dateTime = DateTime.Parse(date2);
  10986. endtime = dateTime.ToString("yyyy-MM-dd 00:00:00");
  10987. end = DateTime.Parse(endtime);
  10988. }
  10989. 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);
  10990. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  10991. //不干胶-----1,卡片-----29
  10992. Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
  10993. foreach (DataRow row in data.Rows)
  10994. {
  10995. int productId = Convert.ToInt32(row["ProductId"]);
  10996. int supplierId = Convert.ToInt32(row["SupplierId"]);
  10997. if (no_suppliers.Contains(supplierId))
  10998. {
  10999. continue;
  11000. }
  11001. string seller_memo = row["seller_memo"].ToString();
  11002. bool ispj = false;//是否配件单
  11003. bool isfirst = true;//第一个配
  11004. maps.Keys.ForEach(key =>
  11005. {
  11006. //备注包含配件
  11007. if (seller_memo.Contains(key) && isfirst)
  11008. {
  11009. List<string> list = maps[key];
  11010. ispj = true;
  11011. isfirst = false;
  11012. for (int i = 0; i < list.Count; i++)
  11013. {
  11014. if (seller_memo.Contains(list[i]))
  11015. {
  11016. ispj = false;
  11017. break;
  11018. }
  11019. }
  11020. }
  11021. });
  11022. if (ispj)
  11023. {
  11024. continue;
  11025. }
  11026. seller_memo = seller_memo.Replace("UV", "uv");
  11027. seller_memo = seller_memo.Replace("贡锻布", "贡缎布");
  11028. //吊牌归到卡片
  11029. seller_memo = seller_memo.Replace("吊牌", "卡片");
  11030. seller_memo = seller_memo.Replace("卡套", "卡片");
  11031. seller_memo = seller_memo.Replace("封套", "卡片");
  11032. seller_memo = seller_memo.Replace("吸管套", "卡片");
  11033. seller_memo = seller_memo.Replace("腰封", "卡片");
  11034. seller_memo = seller_memo.Replace("旗帜布", "条幅");
  11035. seller_memo = seller_memo.Replace("手拉旗", "条幅");
  11036. seller_memo = seller_memo.Replace("横幅", "条幅");
  11037. seller_memo = seller_memo.Replace("锦旗", "条幅");
  11038. string map_key = "";
  11039. string type = "";
  11040. if (supplierMap.ContainsKey(supplierId))
  11041. {
  11042. foreach (var kvp in supplierMap[supplierId])
  11043. {
  11044. if (seller_memo.Contains(kvp.Key))
  11045. {
  11046. map_key = kvp.Value;
  11047. type = kvp.Value;
  11048. break;
  11049. }
  11050. }
  11051. }
  11052. if (map_key == "")
  11053. {
  11054. type = "其他";
  11055. map_key = "其他";
  11056. }
  11057. if ("其他".Equals(map_key) && suppliers.ContainsKey(supplierId))
  11058. {
  11059. map_key = suppliers[supplierId];
  11060. }
  11061. if (supplierId == 70)
  11062. {
  11063. supplierId = 70;
  11064. }
  11065. map_key += "_" + row["SupplierName"].ToString();
  11066. Dictionary<string, int> map = null;
  11067. if (other_map.ContainsKey(map_key))
  11068. {
  11069. other_map.TryGetValue(map_key, out map);
  11070. }
  11071. else
  11072. {
  11073. map = new Dictionary<string, int>();
  11074. map.Add("dayDev", 0);//当天出货
  11075. map.Add("dayTotal", 0);//下单总数
  11076. map.Add("payTotal", 0);//500以上
  11077. map.Add("today", 0);//当天出货数量
  11078. map.Add("unusua", 0);//异常数
  11079. other_map.Add(map_key, map);
  11080. other_map.TryGetValue(map_key, out map);
  11081. }
  11082. DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11083. DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
  11084. DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
  11085. DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
  11086. if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
  11087. {
  11088. map["dayTotal"]++;
  11089. if (supplierId == 97)
  11090. {
  11091. supplierId = 97;
  11092. }
  11093. }
  11094. if (Convert.ToDecimal(row["payment"]) >= 500)
  11095. {
  11096. map["payTotal"]++;
  11097. }
  11098. if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
  11099. {
  11100. DateTime FinishDeliveryTime = DateTime.Parse(row["FinishDeliveryTime"].ToString());
  11101. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11102. {
  11103. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeTwoEnd, FinishDeliveryTime) > 0)//当天发货
  11104. {
  11105. map["today"]++;
  11106. }
  11107. }
  11108. else
  11109. {
  11110. if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
  11111. {
  11112. map["today"]++;
  11113. }
  11114. else
  11115. {
  11116. if (supplierId == 119)
  11117. {
  11118. Debug.WriteLine(row["seller_memo"].ToString());
  11119. }
  11120. }
  11121. }
  11122. }
  11123. if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
  11124. {
  11125. map["unusua"]++;
  11126. }
  11127. DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
  11128. //GD-CYT-----64
  11129. DateTime two = palceTimeStart.AddHours(14);
  11130. DateTime three = palceTimeStart.AddHours(15);
  11131. DateTime four = palceTimeStart.AddHours(16);
  11132. if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
  11133. {
  11134. //下午四点前 500-1000
  11135. string count = row["ProductCount"].ToString();
  11136. if (count != null && count.Length > 0)
  11137. {
  11138. int productCount = commonHelper.getPlaceProductCount(count);
  11139. if (productCount >= 500 && productCount <= 1000)
  11140. {
  11141. if (DateTime.Compare(FinishPlaceTime, four) < 0)
  11142. {
  11143. map["dayDev"]++;
  11144. }
  11145. }
  11146. }
  11147. }
  11148. //UV
  11149. else if ("uv".Equals(type))
  11150. {
  11151. //ZT----70
  11152. //ZHX----3
  11153. if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
  11154. {
  11155. map["dayDev"]++;
  11156. }
  11157. //JK----97
  11158. //HZX----105
  11159. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
  11160. {
  11161. map["dayDev"]++;
  11162. if (supplierId == 97)
  11163. {
  11164. supplierId = 97;
  11165. }
  11166. }
  11167. }
  11168. //帆布---52|条幅---27
  11169. else if ("帆布".Equals(type) || "条幅".Equals(type))
  11170. {
  11171. //LHCY-----98
  11172. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
  11173. {
  11174. map["dayDev"]++;
  11175. }
  11176. }
  11177. //条幅
  11178. else if ("条幅".Equals(type))
  11179. {
  11180. //XD-----90
  11181. if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
  11182. {
  11183. map["dayDev"]++;
  11184. }
  11185. }
  11186. //桌布
  11187. else if ("桌布".Equals(type))
  11188. {
  11189. //XD-----90
  11190. if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
  11191. {
  11192. map["dayDev"]++;
  11193. }
  11194. }
  11195. //DL---10
  11196. //AYTW---119
  11197. //FS-CYT-DY ----80
  11198. //JK----97
  11199. else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
  11200. {
  11201. if (DateTime.Compare(FinishPlaceTime, three) < 0)
  11202. {
  11203. map["dayDev"]++;
  11204. }
  11205. }
  11206. }
  11207. DataTable dt = new DataTable();
  11208. dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
  11209. dt.Columns.Add(new DataColumn("SupplierName", typeof(string)));
  11210. dt.Columns.Add(new DataColumn("dayTotal", typeof(string)));
  11211. dt.Columns.Add(new DataColumn("payTotal", typeof(string)));
  11212. dt.Columns.Add(new DataColumn("today", typeof(string)));
  11213. dt.Columns.Add(new DataColumn("unusua", typeof(string)));
  11214. dt.Columns.Add(new DataColumn("dayDev", typeof(string)));
  11215. dt.Columns.Add(new DataColumn("dayRate", typeof(string)));
  11216. other_map.Keys.ForEach(key =>
  11217. {
  11218. DataRow dr = dt.NewRow();
  11219. Dictionary<string, int> map = other_map[key];
  11220. string[] key_list = key.Split('_');
  11221. dr[0] = key_list[0];
  11222. dr[1] = key_list[1];
  11223. if (key_list.Length > 2)
  11224. {
  11225. dr[1] += "(" + key_list[2] + ")";
  11226. }
  11227. dr[2] = map["dayTotal"];
  11228. dr[3] = map["payTotal"];
  11229. dr[4] = map["today"];
  11230. dr[5] = map["unusua"];
  11231. dr[6] = map["dayDev"];
  11232. double rate = 0.00;
  11233. if (map["dayDev"] > 0)
  11234. {
  11235. rate = Math.Round((Convert.ToDouble(map["today"]) / Convert.ToDouble(map["dayDev"])), 2);
  11236. }
  11237. dr[7] = rate.ToString();
  11238. dt.Rows.Add(dr);
  11239. });
  11240. DataView dv = new DataView(dt);
  11241. dv.Sort = "SupplierName";
  11242. //dv.Sort = "AllOrder desc";
  11243. DataTable dtNew = dv.ToTable();
  11244. writeGridDataTableJson(dtNew.Rows.Count, dtNew);
  11245. }
  11246. public void check_order_desing_info()
  11247. {
  11248. string ctid = GetPostString("ctid");
  11249. if (!string.IsNullOrEmpty(ctid))
  11250. {
  11251. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11252. if (ceErpTradeCell != null)
  11253. {
  11254. designApiResponseVo response = commonHelper.checkOrderDesignInfo(ceErpTradeCell);
  11255. returnSuccess(JsonConvert.SerializeObject(new { response }));
  11256. return;
  11257. }
  11258. returnErrorMsg("找不到订单");
  11259. return;
  11260. }
  11261. returnErrorMsg("找不到订单");
  11262. }
  11263. public void get_timeout_detail()
  11264. {
  11265. string poscode = CurrentUser.UserPost.Post.Code;
  11266. DataStruct dStruct = GetPostStruct();
  11267. List<string> lw = new List<string>();
  11268. string id = GetPostString("id");
  11269. string pay_date1 = GetPostString("pay_date1");
  11270. string pay_date2 = GetPostString("pay_date2");
  11271. int type = GetPostInt("type");
  11272. if (type == 0)
  11273. {
  11274. if (pay_date1.Length > 0)
  11275. {
  11276. lw.Add(string.Format(" pay_time >= '{0}' ", pay_date1));
  11277. }
  11278. if (pay_date2.Length > 0)
  11279. {
  11280. lw.Add(string.Format(" pay_time < '{0}'", pay_date2));
  11281. }
  11282. lw.Add(string.Format(" CustomerUserId = {0} AND create_time > 0 AND pay_time > 0 AND datediff( HOUR, pay_time,create_time ) > 1 ", id));
  11283. }
  11284. if (type == 1)
  11285. {
  11286. if (pay_date1.Length > 0)
  11287. {
  11288. lw.Add(string.Format(" WaitDesignTime >= '{0}' ", pay_date1));
  11289. }
  11290. if (pay_date2.Length > 0)
  11291. {
  11292. lw.Add(string.Format(" WaitDesignTime < '{0}'", pay_date2));
  11293. }
  11294. lw.Add(string.Format(" DesignUserId = {0} AND WaitDesignTime > 0 AND FinishDesignTime > 0 AND datediff( HOUR, WaitDesignTime, FinishDesignTime ) > 24 ", id));
  11295. }
  11296. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11297. DataTable dt = null;
  11298. dt = WebCache.GetData("view_orderlist", dStruct);
  11299. writeGridDataTableJson(dStruct.TotalCount, dt);
  11300. }
  11301. public void saveUrgentChargePrice()
  11302. {
  11303. string ctid = GetPostString("ctid");
  11304. if (!string.IsNullOrEmpty(ctid))
  11305. {
  11306. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11307. if (ceErpTradeCell != null)
  11308. {
  11309. double price = GetPostDouble("price");
  11310. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ceErpTradeCell.ctid);
  11311. if (ceErpTradeCellExtend == null)
  11312. {
  11313. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11314. ceErpTradeCellExtend.ctid = ceErpTradeCell.ctid;
  11315. }
  11316. ceErpTradeCellExtend.urgentCharge = price;
  11317. if (ceErpTradeCellExtend.ID > 0)
  11318. {
  11319. ceErpTradeCellExtend.Update();
  11320. }
  11321. else
  11322. {
  11323. ceErpTradeCellExtend.Save();
  11324. }
  11325. returnSuccessMsg("修改成功!");
  11326. return;
  11327. }
  11328. returnErrorMsg("找不到订单");
  11329. return;
  11330. }
  11331. returnErrorMsg("找不到订单");
  11332. }
  11333. public void finish_erp_order()
  11334. {
  11335. string ctid = GetPostString("ctid");
  11336. if (!string.IsNullOrEmpty(ctid))
  11337. {
  11338. if (CurrentUser.UserPost.Post.Code == "AfterSaleMaster" || CurrentUser.UserPost.Post.Code == "AfterSale" || CurrentUser.UserPost.Post.Code == "SysAdmin" || CurrentUser.UserID == 82 || CurrentUser.UserID == 2846)
  11339. {
  11340. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(ctid);
  11341. if (ceErpTradeCell != null)
  11342. {
  11343. ceErpTradeCell.OrderState = ((int)OrderState.交易关闭);
  11344. ceErpTradeCell.Update();
  11345. LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "关闭订单", ceErpTradeCell.OrderState);
  11346. returnSuccessMsg("修改成功!");
  11347. return;
  11348. }
  11349. }
  11350. }
  11351. returnErrorMsg("找不到订单");
  11352. }
  11353. public void get_trade_order_list()
  11354. {
  11355. string tid = GetPostString("tid");
  11356. if (!string.IsNullOrEmpty(tid))
  11357. {
  11358. string sql = string.Format("select * from CE_ErpTradeOrder where tid = '{0}'", tid);
  11359. DataTable data = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
  11360. writeGridDataTableJson(data.Rows.Count, data);
  11361. return;
  11362. }
  11363. returnErrorMsg("找不到订单");
  11364. }
  11365. public void save_cell_spu()
  11366. {
  11367. string ctid = GetPostString("ctid");
  11368. string spu_id = GetPostString("spu_id");
  11369. if (!string.IsNullOrEmpty(ctid))
  11370. {
  11371. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11372. if (ceErpTradeCellExtend == null)
  11373. {
  11374. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11375. ceErpTradeCellExtend.ctid = ctid;
  11376. }
  11377. ceErpTradeCellExtend.spu_id = spu_id;
  11378. if (ceErpTradeCellExtend.ID == 0)
  11379. {
  11380. ceErpTradeCellExtend.Create();
  11381. }
  11382. else
  11383. {
  11384. ceErpTradeCellExtend.Update();
  11385. }
  11386. returnSuccessMsg("修改成功!");
  11387. return;
  11388. }
  11389. returnErrorMsg("找不到订单");
  11390. }
  11391. public void change_express_info()
  11392. {
  11393. string ctid = GetPostString("ctid");
  11394. string transNo = GetPostString("transNo");
  11395. string transCom = GetPostString("transCom");
  11396. if (!string.IsNullOrEmpty(ctid))
  11397. {
  11398. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11399. if (ceErpTradeCellExtend == null)
  11400. {
  11401. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11402. ceErpTradeCellExtend.ctid = ctid;
  11403. }
  11404. ceErpTradeCellExtend.modExpressNo = transNo;
  11405. ceErpTradeCellExtend.modExpressCom = transCom;
  11406. ceErpTradeCellExtend.readMod = 2;
  11407. if (ceErpTradeCellExtend.ID == 0)
  11408. {
  11409. ceErpTradeCellExtend.Create();
  11410. }
  11411. else
  11412. {
  11413. ceErpTradeCellExtend.Update();
  11414. }
  11415. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息:" + transNo + "_" + transCom, 6);
  11416. returnSuccessMsg("修改成功!");
  11417. return;
  11418. }
  11419. returnErrorMsg("找不到订单");
  11420. }
  11421. public void get_change_express_list()
  11422. {
  11423. DataStruct dStruct = GetPostStruct();
  11424. List<string> lw = new List<string>();
  11425. int st = 2;
  11426. string tid = GetPostString("ctid");
  11427. if (tid.Length > 0)
  11428. {
  11429. string select_tid = getTidByCtid(tid);
  11430. lw.Add(string.Format("tid='{0}'", select_tid));
  11431. }
  11432. string shopname = GetPostString("shopname");
  11433. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11434. string buyernick = GetPostString("buyer_nick");
  11435. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11436. string sellermemo = GetPostString("seller_memo");
  11437. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11438. string supplier = GetPostString("supplier");
  11439. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11440. string customer = GetPostString("customer");
  11441. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11442. string design = GetPostString("design");
  11443. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11444. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11445. string poscode = CurrentUser.UserPost.Post.Code;
  11446. if (poscode != "SysAdmin")
  11447. {
  11448. string shopid = CurrentUser.User.pemShop;
  11449. lw.Add(string.Format("shopId in ({0})", shopid));
  11450. }
  11451. lw.Add("readMod = 2");
  11452. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11453. DataTable dt = WebCache.GetData("view_ErpTradeCell", dStruct);
  11454. writeGridDataTableJson(dStruct.TotalCount, dt);
  11455. }
  11456. public void deal_express_complete()
  11457. {
  11458. string ctid = GetPostString("ctid");
  11459. if (!string.IsNullOrEmpty(ctid))
  11460. {
  11461. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11462. if (ceErpTradeCellExtend == null)
  11463. {
  11464. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11465. ceErpTradeCellExtend.ctid = ctid;
  11466. }
  11467. ceErpTradeCellExtend.readMod = 1;
  11468. if (ceErpTradeCellExtend.ID == 0)
  11469. {
  11470. ceErpTradeCellExtend.Create();
  11471. }
  11472. else
  11473. {
  11474. ceErpTradeCellExtend.Update();
  11475. }
  11476. LogHelper.addLog(ctid, CurrentUser.UserID, "修改物流信息处理完成", 6);
  11477. returnSuccessMsg("修改成功!");
  11478. return;
  11479. }
  11480. returnErrorMsg("找不到订单");
  11481. }
  11482. public void aftersale_return_visit()
  11483. {
  11484. string ctid = GetPostString("ctid");
  11485. if (!string.IsNullOrEmpty(ctid))
  11486. {
  11487. CeErpTradeCellExtend ceErpTradeCellExtend = CeErpTradeCellExtend.getByTid(ctid);
  11488. if (ceErpTradeCellExtend == null)
  11489. {
  11490. ceErpTradeCellExtend = new CeErpTradeCellExtend();
  11491. ceErpTradeCellExtend.ctid = ctid;
  11492. }
  11493. ceErpTradeCellExtend.returnVisit = 1;
  11494. if (ceErpTradeCellExtend.ID == 0)
  11495. {
  11496. ceErpTradeCellExtend.Create();
  11497. }
  11498. else
  11499. {
  11500. ceErpTradeCellExtend.Update();
  11501. }
  11502. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11503. if (ceErpTradeAfterSaleExtend != null)
  11504. {
  11505. ceErpTradeAfterSaleExtend.TextResult = "";
  11506. ceErpTradeAfterSaleExtend.Update();
  11507. }
  11508. LogHelper.addLog(ctid, CurrentUser.UserID, "添加客户回访信息", 6);
  11509. returnSuccessMsg("修改成功!");
  11510. return;
  11511. }
  11512. returnErrorMsg("找不到订单");
  11513. }
  11514. public void orderPlaceInfo()
  11515. {
  11516. string ctids = GetPostString("ctids");
  11517. string[] list = ctids.Split(',');
  11518. foreach (string ctid in list)
  11519. {
  11520. CeErpSukuraData.createInfo(ctid, 3);
  11521. }
  11522. StringBuilder sql = new StringBuilder();
  11523. sql.AppendFormat("update CE_ErpTradeCell set UpdateTime=getdate() where ctid in ({0}) ;", ("'" + ctids.Replace(",", "','") + "'"));
  11524. CeErpTradeCell.ExecuteNonQuery(sql.ToString());
  11525. designHelper.api_approveDesign(ctids); //approveDesign
  11526. returnSuccessMsg("");
  11527. }
  11528. public void get_issue_list()
  11529. {
  11530. DataStruct dStruct = GetPostStruct();
  11531. List<string> lw = new List<string>();
  11532. int st = 2;
  11533. string tid = GetPostString("ctid");
  11534. if (tid.Length > 0)
  11535. {
  11536. string select_tid = getTidByCtid(tid);
  11537. lw.Add(string.Format("tid='{0}'", select_tid));
  11538. }
  11539. string shopname = GetPostString("shopname");
  11540. if (shopname.Length > 0) lw.Add(string.Format("seller_nick = '{0}'", shopname));
  11541. string buyernick = GetPostString("buyer_nick");
  11542. if (buyernick.Length > 0) lw.Add(string.Format("buyer_nick like '%{0}%'", buyernick));
  11543. string sellermemo = GetPostString("seller_memo");
  11544. if (sellermemo.Length > 0) lw.Add(string.Format("seller_memo like '%{0}%'", sellermemo));
  11545. string supplier = GetPostString("supplier");
  11546. if (supplier.Length > 0) lw.Add(string.Format("SupplierName like '%{0}%'", supplier));
  11547. string customer = GetPostString("customer");
  11548. if (customer.Length > 0) lw.Add(string.Format("CustomerTb like '%{0}%'", customer));
  11549. string design = GetPostString("design");
  11550. if (design.Length > 0) lw.Add(string.Format("DesignUserName like '%{0}%'", design));
  11551. //lw.Add(string.Format("IsArbitrate != '{0}'", 2));
  11552. string poscode = CurrentUser.UserPost.Post.Code;
  11553. if (poscode != "SysAdmin")
  11554. {
  11555. string shopid = CurrentUser.User.pemShop;
  11556. lw.Add(string.Format("shopId in ({0})", shopid));
  11557. }
  11558. if ("AfterSale".Equals(poscode) || "AfterSaleMaster".Equals(poscode))
  11559. {
  11560. lw.Add("IssueState = 1");
  11561. }
  11562. lw.Add("IssueState > 0");
  11563. dStruct.MainWhere = string.Join(" and ", lw.ToArray());
  11564. DataTable dt = WebCache.GetData("view_ErpTradeCellIssue", dStruct);
  11565. writeGridDataTableJson(dStruct.TotalCount, dt);
  11566. }
  11567. public void saveIssueContent()
  11568. {
  11569. string ctid = GetPostString("ctid");
  11570. if (!string.IsNullOrEmpty(ctid))
  11571. {
  11572. string content = GetPostString("content");
  11573. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11574. if (ceErpTradeAfterSaleExtend == null)
  11575. {
  11576. ceErpTradeAfterSaleExtend = new CeErpTradeAfterSaleExtend();
  11577. ceErpTradeAfterSaleExtend.tid = ctid;
  11578. }
  11579. ceErpTradeAfterSaleExtend.IssueContent = content;
  11580. ceErpTradeAfterSaleExtend.IssueState = 1;
  11581. if (ceErpTradeAfterSaleExtend.ID > 0)
  11582. {
  11583. ceErpTradeAfterSaleExtend.Update();
  11584. }
  11585. else
  11586. {
  11587. ceErpTradeAfterSaleExtend.Create();
  11588. }
  11589. LogHelper.addLog(ctid, CurrentUser.UserID, "添加问题反馈信息:" + content, 6);
  11590. returnSuccessMsg("添加成功!");
  11591. return;
  11592. }
  11593. returnErrorMsg("找不到订单");
  11594. }
  11595. public void dealIssueContent()
  11596. {
  11597. string ctid = GetPostString("ctid");
  11598. if (!string.IsNullOrEmpty(ctid))
  11599. {
  11600. string content = GetPostString("content");
  11601. CeErpTradeAfterSaleExtend ceErpTradeAfterSaleExtend = CeErpTradeAfterSaleExtend.getByTid(ctid);
  11602. if (ceErpTradeAfterSaleExtend != null)
  11603. {
  11604. ceErpTradeAfterSaleExtend.IssueState = 2;
  11605. ceErpTradeAfterSaleExtend.Update();
  11606. LogHelper.addLog(ctid, CurrentUser.UserID, "处理问题反馈信息", 6);
  11607. returnSuccessMsg("修改完成!");
  11608. return;
  11609. }
  11610. }
  11611. returnErrorMsg("找不到订单");
  11612. }
  11613. public void set_tid_attachments()
  11614. {
  11615. string tid = GetPostString("tid");
  11616. string atta = GetPostString("atta");
  11617. if (!string.IsNullOrEmpty(tid))
  11618. {
  11619. if (string.IsNullOrEmpty(atta))
  11620. {
  11621. returnErrorMsg("文件地址为空");
  11622. return;
  11623. }
  11624. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11625. if (ceErpTradeCell != null)
  11626. {
  11627. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11628. if (ceErpTrade == null)
  11629. {
  11630. returnErrorMsg("找不到订单");
  11631. return;
  11632. }
  11633. DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
  11634. bool isSend = false;
  11635. if (dt != null && dt.Rows.Count > 0)
  11636. {
  11637. foreach (DataRow row in dt.Rows)
  11638. {
  11639. if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
  11640. {
  11641. isSend = true;
  11642. }
  11643. }
  11644. if (isSend)
  11645. {
  11646. returnErrorMsg("已发货无法修改");
  11647. return;
  11648. }
  11649. ceErpTrade.Attachments = atta;
  11650. ceErpTrade.Update();
  11651. LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
  11652. returnSuccessMsg("上传成功!");
  11653. return;
  11654. }
  11655. }
  11656. }
  11657. returnErrorMsg("找不到订单");
  11658. }
  11659. public void get_tid_attachments()
  11660. {
  11661. string tid = GetPostString("tid");
  11662. if (!string.IsNullOrEmpty(tid))
  11663. {
  11664. CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
  11665. if (ceErpTradeCell != null)
  11666. {
  11667. CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
  11668. if (ceErpTrade == null)
  11669. {
  11670. returnErrorMsg("找不到订单");
  11671. return;
  11672. }
  11673. returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
  11674. return;
  11675. }
  11676. }
  11677. returnErrorMsg("找不到订单");
  11678. }
  11679. public void check_erp_sameorders()
  11680. {
  11681. if (UrlPostParmsCheck("ctid"))
  11682. {
  11683. string eid = GetPostString("ctid");
  11684. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11685. if (entity != null)
  11686. {
  11687. if (entity.OrderState > 6)
  11688. {
  11689. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11690. return;
  11691. }
  11692. StringBuilder sql = new StringBuilder();
  11693. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11694. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11695. List<string> ids = new List<string>();
  11696. if (dt != null && dt.Rows.Count > 1)
  11697. {
  11698. bool needhe = true;
  11699. foreach (DataRow dr in dt.Rows)
  11700. {
  11701. ids.Add("'" + dr["ctid"] + "'");
  11702. /* //备注有合包
  11703. if (dr["seller_memo"].ToString().IndexOf("合包") > -1)
  11704. {
  11705. needhe = true;
  11706. }
  11707. if (dr["OtherMemo"].ToString().IndexOf("合包") > -1)
  11708. {
  11709. needhe = true;
  11710. }
  11711. //顺丰快递
  11712. if (Convert.ToInt32(dr["IsSF"]) > 0)
  11713. {
  11714. needhe = true;
  11715. }*/
  11716. }
  11717. if (!needhe)
  11718. {
  11719. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11720. return;
  11721. }
  11722. sql = new StringBuilder();
  11723. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11724. dt.Columns.Add(new DataColumn("dstate", typeof(int)));
  11725. dt.Columns.Add(new DataColumn("dnumber", typeof(int)));
  11726. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11727. foreach (DataRow dr in dt.Rows)
  11728. {
  11729. dr["dstate"] = 0;
  11730. dr["dnumber"] = 0;
  11731. foreach (DataRow row in dt1.Rows)
  11732. {
  11733. if (dr["ctid"].ToString().Equals(row["ctid"].ToString()))
  11734. {
  11735. dr["dstate"] = 2;
  11736. dr["dnumber"] = Convert.ToInt32(row["markNumber"]);
  11737. }
  11738. }
  11739. if (eid.Equals(dr["ctid"].ToString()))
  11740. {
  11741. dr["dstate"] = 1;
  11742. }
  11743. }
  11744. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(dt)) + "}");
  11745. return;
  11746. }
  11747. ReturnSuccess("{" + string.Format("\"data\":{0}", Utils.Serialization.JsonString.DataTable2MiniAjaxJson(new DataTable())) + "}");
  11748. return;
  11749. }
  11750. returnErrorMsg("未找到订单");
  11751. return;
  11752. }
  11753. returnErrorMsg("缺少必要的参数");
  11754. }
  11755. public void get_mark_number()
  11756. {
  11757. string eid = GetPostString("ctid");
  11758. CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
  11759. if (entity != null)
  11760. {
  11761. CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
  11762. int current = 1;
  11763. if (ceErpDeliverMark == null)
  11764. {
  11765. StringBuilder sql = new StringBuilder();
  11766. sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
  11767. DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11768. List<string> ids = new List<string>();
  11769. if (dt != null && dt.Rows.Count > 1)
  11770. {
  11771. foreach (DataRow dr in dt.Rows)
  11772. {
  11773. ids.Add("'" + dr["ctid"] + "'");
  11774. }
  11775. //查询已有的编号
  11776. sql = new StringBuilder();
  11777. sql.AppendFormat("select * from CE_ErpDeliverMark where isDel = 0 and ctid in ({0});", string.Join(",", ids));
  11778. DataTable dt1 = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
  11779. if (dt1 == null || dt1.Rows.Count == 0)
  11780. {
  11781. DataTable numbers = DbHelper.DbConn.ExecuteDataset(string.Format("select markNumber from CE_ErpDeliverMark where isDel = 0 group by markNumber")).Tables[0];
  11782. List<int> list_number = new List<int>();
  11783. foreach (DataRow row in numbers.Rows)
  11784. {
  11785. list_number.Add(Convert.ToInt32(row["markNumber"]));
  11786. }
  11787. //查询空余编号
  11788. for (int i = 0; i < list_number.Count + 2; i++)
  11789. {
  11790. if (!list_number.Contains(current))
  11791. {
  11792. CeErpDeliverMark ceErpDeliverMark1 = CeErpDeliverMark.GetByNumber(current);
  11793. //防止查询过程中有新数据生成
  11794. if (ceErpDeliverMark1 == null)
  11795. {
  11796. break;
  11797. }
  11798. }
  11799. current++;
  11800. }
  11801. }
  11802. else
  11803. {
  11804. foreach (DataRow row in dt1.Rows)
  11805. {
  11806. current = Convert.ToInt32(row["markNumber"]);
  11807. }
  11808. }
  11809. ceErpDeliverMark = new CeErpDeliverMark();
  11810. ceErpDeliverMark.ctid = eid;
  11811. ceErpDeliverMark.createtime = DateTime.Now;
  11812. CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
  11813. if (ceErpTrade != null)
  11814. {
  11815. ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;
  11816. }
  11817. ceErpDeliverMark.markNumber = current;
  11818. ceErpDeliverMark.Create();
  11819. }
  11820. }
  11821. else
  11822. {
  11823. current = ceErpDeliverMark.markNumber;
  11824. }
  11825. ReturnSuccess(JsonConvert.SerializeObject(new { markNumber = current }));
  11826. return;
  11827. }
  11828. }
  11829. }
  11830. }