Fullordertt.php 226 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullordertt extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_fullorder','fullorder');
  7. $this->load->_model('Model_fullordertt','fullordertt');
  8. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  9. $this->load->_model('Model_shop','shop');
  10. $this->load->_model('Model_typeclass','typeclass');
  11. $this->load->_model('Model_express','express');
  12. $this->load->_model('Model_country','country');
  13. $this->load->_model('Model_productdescribe','productdescribe');
  14. $this->load->_model('Model_customs','customs');
  15. $this->load->_model('Model_detailed','detailed');
  16. $this->load->_model('Model_productdescription','productdescription');
  17. $this->load->_model('Model_logistics','logistics');
  18. $this->load->_model('Model_hl','hl');
  19. $this->load->_model('Model_excel','excel');
  20. $this->load->_model('Model_warehouse','warehouse');
  21. $this->load->_model('Model_customertt','customertt');
  22. $this->load->_model('Model_user','user');
  23. $this->load->_model('Model_dhl','dhl');
  24. $this->load->_model('Model_ali','ali');
  25. $this->load->_model('Model_notice','notice');
  26. $this->load->_model('Model_api','api');
  27. $this->load->_model('Model_usps','usps');
  28. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_reset','fullreset');
  31. $this->load->_model('Model_specialstock','specialstock');
  32. $this->load->_model('Model_systemwigsout','systemwigsout');
  33. $this->load->_model('Model_colourorderts','colourorderts');
  34. $this->load->_model('Model_paypal','paypal');
  35. $this->load->_model('Model_ck','ck');
  36. $this->load->_model('Model_weight','weight');
  37. $this->load->_model('Model_pay','pay');
  38. $this->load->_model('Model_setting','setting');
  39. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  40. $this->load->_model('Model_transfer','transfer');
  41. $this->load->_model('Model_systemtransfer','systemtransfer');
  42. $this->load->_model('Model_power','power');
  43. $this->load->_model('Model_fullordertthb','fullordertthb');
  44. $this->load->_model('Model_returngoods','returngoods');
  45. }
  46. //定义方法的调用规则 获取URI第二段值
  47. public function _remap($arg,$arg_array)
  48. {
  49. if($arg == 'add')//添加
  50. {
  51. $this->_add();
  52. }
  53. else if($arg == 'edit')//修改
  54. {
  55. $this->_edit($arg_array);
  56. }
  57. else if($arg == 'readonly')//修改
  58. {
  59. $this->_readonly($arg_array);
  60. }
  61. else if($arg == 'readlist')
  62. {
  63. $this->_readlist();
  64. }
  65. else if($arg == 'readlistdown')
  66. {
  67. $this->_readlistdown();
  68. }
  69. else if($arg == 'del')//修改
  70. {
  71. $this->_del();
  72. }
  73. else if($arg == 'price')//价格明细
  74. {
  75. $this->_price();
  76. }
  77. else if($arg == 'customs')
  78. {
  79. $this->_customs();
  80. }
  81. else if($arg == 'express')
  82. {
  83. $this->_express();
  84. }
  85. else if($arg == 'hl')
  86. {
  87. $this->_hl();
  88. }
  89. else if($arg == 'repeat')
  90. {
  91. $this->_repeat();
  92. }
  93. else if($arg == 'operation')
  94. {
  95. $this->_operation();
  96. }
  97. else if($arg == 'merge')
  98. {
  99. $this->_merge();
  100. }
  101. else if($arg == 'fmexcel')
  102. {
  103. $this->_fmexcel();
  104. }
  105. else if($arg == 'fdexcel')
  106. {
  107. $this->_fdexcel();
  108. }
  109. else if($arg == 'fdfexcel')
  110. {
  111. $this->_fdfexcel();
  112. }
  113. else if($arg == 'evaluate')
  114. {
  115. $this->_evaluate();
  116. }
  117. else if($arg == 'state')
  118. {
  119. $this->_state();
  120. }
  121. else if($arg == 'wl')
  122. {
  123. $this->_wl();
  124. }
  125. else if($arg == 'wlbz')
  126. {
  127. $this->_wlbz($arg_array);
  128. }
  129. else if($arg == 'review')
  130. {
  131. $this->_review();
  132. }
  133. else if($arg == 'black')
  134. {
  135. $this->_black();
  136. }
  137. else if($arg == 'ryf')
  138. {
  139. $this->_ryf();
  140. }
  141. else if($arg == 'expresstype')
  142. {
  143. $this->_expresstype();
  144. }
  145. else if($arg == 'fsstate')
  146. {
  147. $this->_fsstate();
  148. }
  149. else if($arg == 'power')
  150. {
  151. $this->_power();
  152. }
  153. else if($arg == 'error')
  154. {
  155. $this->_error();
  156. }
  157. else if($arg == 'yc')
  158. {
  159. $this->_yc();
  160. }
  161. else if($arg == 'yzaddress')
  162. {
  163. $this->_yzaddress();
  164. }
  165. else if($arg == 'return')
  166. {
  167. $this->_return();
  168. }
  169. else if($arg == 'clearreturn')
  170. {
  171. $this->_clearreturn();
  172. }
  173. else if($arg == 'ali')
  174. {
  175. $this->_ali();
  176. }
  177. else if($arg == 'dqpm')
  178. {
  179. $this->_dqpm();
  180. }
  181. else if($arg == 'ddpmdata')
  182. {
  183. $this->_ddpmdata($arg_array);
  184. }
  185. else if($arg == 'dqpmprovince')
  186. {
  187. $this->_dqpmprovince($arg_array);
  188. }
  189. else if($arg == 'ddpmexcel')
  190. {
  191. $this->_ddpmexcel($arg_array);
  192. }
  193. else if($arg == 'statedc')
  194. {
  195. $this->_statedc();
  196. }
  197. else if($arg == 'statedcwl')
  198. {
  199. $this->_statedcwl();
  200. }
  201. else if($arg == 'waybillemail')
  202. {
  203. $this->_waybillemail();
  204. }
  205. else if($arg == 'khdd')
  206. {
  207. $this->_khdd();
  208. }
  209. else if($arg == 'klarnadata')
  210. {
  211. $this->_klarnadata();
  212. }
  213. else if($arg == 'epod')
  214. {
  215. $this->_epod();
  216. }
  217. else if($arg == 'zw')
  218. {
  219. $this->_zw($arg_array);
  220. }
  221. else if($arg == 'thxz')
  222. {
  223. $this->_thxz($arg_array);
  224. }
  225. else if($arg == 'dcdxyz')
  226. {
  227. $this->_dcdxyz();
  228. }
  229. else if($arg == 'ddcf')
  230. {
  231. $this->_ddcf();
  232. }
  233. else if($arg == 'cf')
  234. {
  235. $this->_cf();
  236. }
  237. else if($arg == 'pljzzd')
  238. {
  239. $this->_pljzzd();
  240. }
  241. else
  242. {
  243. $this->_index();
  244. }
  245. }
  246. //管理
  247. public function _index()
  248. {
  249. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  250. if(isset($_SESSION['api']))
  251. {
  252. $user = $this->user->get_api($_SESSION['api']);
  253. $usp = $user;
  254. $fgshop = "";$sid = "";
  255. $usersp = explode('|',trim($user['shop'],'|'));
  256. foreach ($usersp as $value)
  257. {
  258. $fgshop .= " shop = ".$value." or";
  259. $sid .= " id = ".$value." or";
  260. }
  261. if($user['vip'] == 1)
  262. {
  263. $vip = 1;
  264. }
  265. else
  266. {
  267. $vip = 0;
  268. }
  269. }
  270. else
  271. {
  272. $vip = 0;
  273. header('Location: /');exit;
  274. }
  275. $post = $this->input->post(NULL, TRUE);
  276. if(isset($post['page']))
  277. {
  278. $page = $this->input->post('page',true);
  279. $perpage = $this->input->post('perpage',true);
  280. $warehouse = $this->input->post('warehouse',true);
  281. $timetk = $this->input->post('timetk',true);
  282. $timetj = $this->input->post('timetj',true);
  283. $shop = $this->input->post('shop',true);
  284. $source = $this->input->post('source',true);
  285. $state = $this->input->post('state',true);
  286. $review = $this->input->post('review',true);
  287. $type = $this->input->post('type',true);
  288. $express = $this->input->post('express',true);
  289. $orderinfo = $this->input->post('orderinfo',true);
  290. $user = $this->input->post('user',true);
  291. $client = $this->input->post('name');
  292. $waybill = $this->input->post('waybill',true);
  293. $number = $this->input->post('number',true);
  294. $email = $this->input->post('email',true);
  295. $phone = $this->input->post('phone',true);
  296. $dlz = $this->input->post('dlz',true);
  297. $print = $this->input->post('print',true);
  298. $library = $this->input->post('library',true);
  299. $js = $this->input->post('js',true);
  300. $exstate = $this->input->post('exstate',true);
  301. $xztime = $this->input->post('xztime',true);
  302. $libraryconfirm = $this->input->post('libraryconfirm',true);
  303. $timetk = strtotime($timetk);
  304. $timetj = strtotime($timetj);
  305. $plorder = $this->input->post('pl',true);
  306. $paypal = $this->input->post('paypal',true);
  307. $pay = $this->input->post('pay',true);
  308. $klarna = $this->input->post('klarna',true);
  309. $zf = $this->input->post('zf',true);
  310. $where = "1=1 and (".rtrim($fgshop,'or').")";
  311. if($warehouse)
  312. {
  313. $where .= " and type = '$warehouse'";
  314. }
  315. if($timetk && $timetj)
  316. {
  317. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  318. }
  319. if($shop)
  320. {
  321. $where .= " and shop = '$shop'";
  322. }
  323. if($source)
  324. {
  325. if($source == '2d')
  326. {
  327. $where .= " and source >= '2'";
  328. }
  329. else
  330. {
  331. $where .= " and source = '$source'";
  332. }
  333. }
  334. if($state)
  335. {
  336. $where .= " and state = '$state'";
  337. }
  338. if($review)
  339. {
  340. $where .= " and review = '$review'";
  341. }
  342. if($type)
  343. {
  344. $where .= " and type = '$type'";
  345. }
  346. if($express)
  347. {
  348. $where .= " and express = '$express'";
  349. }
  350. if($orderinfo)
  351. {
  352. $where .= " and orderinfo = '$orderinfo' and orderinfo != '0'";
  353. }
  354. if($user)
  355. {
  356. $where .= " and user = '$user'";
  357. }
  358. if($client)
  359. {
  360. $where .= " and client like '%$client%'";
  361. }
  362. if($waybill)
  363. {
  364. $where .= " and waybill = '$waybill'";
  365. }
  366. if($number)
  367. {
  368. $where .= " and number like '$number%'";
  369. }
  370. if($email)
  371. {
  372. $where .= " and email = '$email'";
  373. }
  374. if($phone)
  375. {
  376. $where .= " and phone like '%$phone%'";
  377. }
  378. if($library)
  379. {
  380. $where .= " and library = '$library'";
  381. }
  382. if($print)
  383. {
  384. $where .= " and print = '$print'";
  385. }
  386. if($dlz != '')
  387. {
  388. $where .= " and dlz = '$dlz'";
  389. }
  390. if($js)
  391. {
  392. $where .= " and js = '$js'";
  393. }
  394. if($exstate)
  395. {
  396. $where .= " and exstate = '$exstate'";
  397. }
  398. if($libraryconfirm)
  399. {
  400. $where .= " and libraryconfirm = '$libraryconfirm'";
  401. }
  402. if($klarna != '')
  403. {
  404. if($klarna == 2)
  405. {
  406. $where .= " and klarna >= '$klarna'";
  407. }
  408. else
  409. {
  410. $where .= " and klarna = '$klarna'";
  411. }
  412. }
  413. if($paypal)
  414. {
  415. $where .= " and paypal = '$paypal'";
  416. }
  417. if($pay)
  418. {
  419. $where .= " and pay = '$pay'";
  420. }
  421. if($zf)
  422. {
  423. if($zf == 1)
  424. {
  425. $where .= " and paypal not like '%-%-%-%'";
  426. }
  427. else
  428. {
  429. $where .= " and paypal like '%-%-%-%'";
  430. }
  431. }
  432. if($plorder)
  433. {
  434. $plorderinfo = '';$plnumber = '';$pln = 0;
  435. $plorder = explode(',',trim($plorder,','));
  436. foreach ($plorder as $value)
  437. {
  438. if(is_numeric($value))
  439. {
  440. $plorderinfo .= " orderinfo = ".$value." or";
  441. }
  442. else if($value != '')
  443. {
  444. $plorderinfo .= " number = '".$value."' or";
  445. }
  446. }
  447. if($pln > 0)
  448. {
  449. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  450. }
  451. else
  452. {
  453. $where .= " and (".rtrim($plorderinfo,'or').")";
  454. }
  455. }
  456. //数据排序
  457. $order_str = "dtime desc";
  458. if(empty($page))
  459. {
  460. $start = 0;
  461. $perpage = 1;
  462. }
  463. else
  464. {
  465. $start = ($page - 1)*$perpage;
  466. }
  467. //取得信息列表id,shop,type,source,user,orderinfo,number,name,state,buytime,clientremarks,review,print,library,libraryconfirm,express,waybill,orderremarks,black
  468. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,sname,phone,state,dtime,review,libraryconfirm,express,waybill,orderremarks,library,black,clientremarks',$order_str,$start,$perpage);
  469. //格式化数据
  470. foreach ($info_list as $key=>$value)
  471. {
  472. $ud = $this->fullordertt->read($value['id']);
  473. $ud['address'] = str_replace("'","’",$ud['address']);
  474. $ud['name'] = str_replace("'","’",$ud['name']);
  475. $customer = $this->customertt->get_email($ud['email'],$value['shop']);
  476. $customernum = $this->fullordertt->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  477. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  478. $numphone = join('',$result[0]);
  479. $hmdaddress1 = str_replace(array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),strtolower($ud['address']));
  480. $hmdaddress2 = str_replace(array(' pkwy',' dr',' st',' rd',' av',' blvd',' aly',' ct',' pl',' ln',' mnr',' ter',' trl',' vw',' cv'),array(' parkway',' drive',' street',' road',' avenue',' boulevard',' alley',' court',' place',' lane',' manor',' terrace',' trail',' view',' cove'),strtolower($ud['address']));
  481. $hmdaddress3 = str_replace(array(' avenue',' ave',' av'),array(' ave',' avenue',' ave'),strtolower($ud['address']));
  482. if($numphone == '0')
  483. {
  484. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or phone = '".$numphone."')",'*','id desc');
  485. }
  486. else
  487. {
  488. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or address = '".$hmdaddress1."' or address = '".$hmdaddress2."' or address = '".$hmdaddress3."' or numphone = '".$numphone."')",'*','id desc');
  489. }
  490. $customerc = $this->customertt->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  491. $customerd = $this->customertt->find_all("type = 2 and shop = '".$ud['shop']."' and email = '".$ud['email']."'",'*','id desc');
  492. //$a = array_column($customer, 'email'); //三维找其中健的数组
  493. //$a = array_flip($a); //键和值调换
  494. $djcount = '';
  495. $lkh = $value['sname'];
  496. $djlkh = 0;$djhmd = 0;
  497. if($customer)
  498. {
  499. if($customer['count'] != '' && $customernum < 2)
  500. {
  501. $count = '<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>';
  502. $djcount = $count;
  503. }
  504. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  505. {
  506. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  507. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  508. $djlkh = 1;
  509. $djcount = $count;
  510. }
  511. else if(isset($customerc[0]['num']))
  512. {
  513. if($customerc[0]['num'] > 1)
  514. {
  515. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  516. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户(".$customer['num'].")</p>";
  517. $djlkh = 1;
  518. $djcount = $count;
  519. }
  520. }
  521. }
  522. if($customerb)
  523. {
  524. $hmsp = $this->shop->read($customerb[0]['shop']);
  525. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  526. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC' data-id='".$customerb[0]['id']."'>来自".$hmsp['shopname']."</p>";
  527. $djhmd = 1;
  528. if($customerd)
  529. {
  530. if($customerd[0]['num'] > 1)
  531. {
  532. $count = $customerd[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerd[0]['count'].'"></i>':'';
  533. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  534. $djlkh = 1;
  535. $djcount = $count;
  536. $djlkh = 1;
  537. }
  538. }
  539. }
  540. if($djlkh == '1' && $djhmd == '1')
  541. {
  542. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  543. }
  544. if($djlkh != '1' && $djhmd != '1' && $djcount)
  545. {
  546. $info_list[$key]['sname'] = $lkh."<p style='color:#FF3333'>".$djcount."</p>";
  547. }
  548. else
  549. {
  550. $info_list[$key]['sname'] = $lkh;
  551. }
  552. $shop = $this->shop->read($value['shop']);
  553. $info_list[$key]['shop'] = $shop['shopname'];
  554. //$info_list[$key]['user'] = $shop['shopuser'];
  555. $warehouse = $this->warehouse->read($value['type']);
  556. $warehousetitle = $warehouse['title'];
  557. if($value['type'] != 13){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  558. $info_list[$key]['type'] = $warehousetitle;
  559. $info_list[$key]['phone'] = $value['phone'];
  560. $typeclass = $this->typeclass->read($value['state']);
  561. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  562. /**
  563. $wl = '';
  564. if($value['exstate'] == '99')
  565. {
  566. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  567. }
  568. else if($value['exstate'] == '1')
  569. {
  570. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  571. }
  572. else if($value['exstate'] == '2')
  573. {
  574. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  575. }
  576. else if($value['exstate'] == '3')
  577. {
  578. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  579. }
  580. else if($value['exstate'] == '4')
  581. {
  582. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  583. }
  584. else if($value['exstate'] == '5')
  585. {
  586. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  587. }
  588. $info_list[$key]['exstate'] = $wl.'<br />';
  589. **/
  590. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  591. {
  592. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$ud['dtime']).'</p><p style="font-size: 13px;">'.date('H:i:s',$ud['dtime']).'</p>';
  593. }
  594. else
  595. {
  596. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$value['dtime']+$dt).'</p><p style="font-size: 13px;">'.date('H:i:s',$value['dtime']+$dt).'</p>';
  597. }
  598. if($value['review'] == 1)
  599. {
  600. $info_list[$key]['review'] = "<font style='font-size: 13px;'>未送审</font>";
  601. }
  602. else if($value['review'] == 2)
  603. {
  604. $info_list[$key]['review'] = "<font style='color:#555;font-size: 13px;'>待审核</font>";
  605. }
  606. else if($value['review'] == 3)
  607. {
  608. $info_list[$key]['review'] = "<font style='color:#f90f4b;font-size: 13px;'>不通过</font>";
  609. }
  610. else if($value['review'] == 4)
  611. {
  612. $info_list[$key]['review'] = "<font style='font-size: 13px;'>取消重审</font>";
  613. }
  614. else if($value['review'] == 5)
  615. {
  616. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>审核通过</font>";
  617. }
  618. else if($value['review'] == 6)
  619. {
  620. $info_list[$key]['review'] = "<font style='color:#2f80f9;font-size: 13px;'>自动通过</font>";
  621. }
  622. if($ud['dlz'] == 1)
  623. {
  624. $dlz = "<p>独立站已更新</p>";
  625. }
  626. else if($ud['dlz'] == 3)
  627. {
  628. $dlz = "<p>不需要更新</p>";
  629. }
  630. else if($ud['dlz'] == 2)
  631. {
  632. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  633. }
  634. else
  635. {
  636. $dlz = "";
  637. }
  638. if($value['waybill'] != "")
  639. {
  640. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  641. }
  642. if($value['express'] != 0)
  643. {
  644. $express = $this->express->read($value['express']);
  645. $expressservicename = $express['servicename'];
  646. if($value['express'] != 1 && $value['express'] != 63)
  647. {
  648. $expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";
  649. }
  650. else if($value['express'] == 63)
  651. {
  652. $expressservicename = "<font style='color:#a910f8'>".$express['servicename']."</font>";
  653. }
  654. $info_list[$key]['express'] = $expressservicename;
  655. }
  656. else
  657. {
  658. $info_list[$key]['express'] = "无";
  659. }
  660. $x = "";
  661. if($value['libraryconfirm'] == 2 && $value['review'] > 4 && $ud['library'] == 1)
  662. {
  663. $x = "<p class='ckn'><b class='fojz' data-type='1'>禁止发货</b></p>";
  664. }
  665. else if(($value['review'] > 4) && $ud['print'] != 1 && $value['libraryconfirm'] == 1)
  666. {
  667. $x = "<p class='ckn'><b class='fojzof' data-type='6' data-id='".$value['id']."'>允许发货</b></p>";
  668. }
  669. if(($value['review'] > 4) && $ud['print'] == 2)
  670. {
  671. $x = "<p class='ckn'><b class='fojzof' data-type='7' data-id='".$value['id']."'>禁止打印</b></p>";
  672. }
  673. else if($value['review'] >4 && $ud['print'] == 1)
  674. {
  675. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  676. }
  677. if($value['waybill'] == "" && $value['review'] > 4)
  678. {
  679. $x .= "<p><b class='kn' data-type='2'>填写运单号</b></p>";
  680. }
  681. else if($value['waybill'] != "" && $value['review'] > 4)
  682. {
  683. $x .= "<p><b class='kn' data-type='2'>修改运单号</b></p>";
  684. }
  685. if(($value['review'] == 1 || $value['review'] == 3) && $ud['express'] > 0 && $ud['dtsbjz'] != 0 && $ud['ts'] != 0 && $ud['zsbjz'] != 0 && $ud['zjs'] != 0 && $ud['ts'] != 0)
  686. {
  687. $x .= "<p><b class='focz' data-type='2' data-id='".$value['id']."'>提交审核</b></p>";
  688. }
  689. $x .= "<p><b class='window' data-h='/customertt/edit/".$customer['id']."' data-t='客户信息 - 修改'>客户信息</b></p>";
  690. $info_list[$key]['black'] = $x;
  691. $tly = "";
  692. if($value['clientremarks'] != "")
  693. {
  694. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  695. }
  696. if($value['review'] > 4 && $usp['vip'] != 1 && ($ud['merge'] == 0 || $ud['merge'] == $ud['id']))
  697. {
  698. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/readonly/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  699. }
  700. else if($ud['merge'] == 0 || $ud['merge'] == $ud['id'])
  701. {
  702. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'><p>".$value['orderinfo']."</p>".$tly."</h9>";
  703. }
  704. else if($ud['merge'] != 0 && $ud['merge'] != $ud['id'])
  705. {
  706. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."' style='color:#000'><p>".$value['orderinfo']."</p>".$tly."</h9>"."<p>合并订单</p>";
  707. }
  708. if($value['library'] == 1 && $ud['printtype'] == 3)
  709. {
  710. $info_list[$key]['library'] = "不需要";
  711. }
  712. else if($value['library'] == 1 && $ud['printtype'] != 3)
  713. {
  714. $info_list[$key]['library'] = "未出库";
  715. }
  716. else if($value['library'] == 2)
  717. {
  718. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  719. }
  720. else if($value['library'] == 3)
  721. {
  722. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  723. }
  724. }
  725. $total = $this->fullordertt->find_count($where);
  726. $pagenum = ceil($total/$perpage);
  727. $over = $total-($start+$perpage);
  728. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  729. echo json_encode($rows);exit;
  730. }
  731. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  732. $this->data['wlshop'] = $wlshop;
  733. $this->data['express'] = $this->express->find_all();
  734. $user = $this->user->get_api($_SESSION['api']);
  735. $powerid = $this->power->read($user['power']);
  736. $powertext = explode('|',trim($powerid['excelid'],'|'));
  737. $pid = '';
  738. foreach ($powertext as $v)
  739. {
  740. $pid .= " id = ".$v." or";
  741. }
  742. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  743. $this->data['fullorderexcel'] = $fullorderexcel;
  744. $error = $this->fullordertt->find_count("failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').") and dtime > '".(time()-90*24*3600)."'");
  745. $this->data['error'] = $error;
  746. $yc = $this->fullordertt->find_count("library = 2 and state = 214 and (".rtrim($fgshop,'or').")");
  747. $this->data['yc'] = $yc;
  748. $this->data['power'] = $vip;
  749. $this->_Template('fullordertt',$this->data);
  750. }
  751. //筛选重复订单
  752. public function _repeat()
  753. {
  754. $user = $this->user->get_api($_SESSION['api']);
  755. if($user)
  756. {
  757. $fgshop = "";$sid = "";
  758. $user = explode('|',trim($user['shop'],'|'));
  759. foreach ($user as $value)
  760. {
  761. $fgshop .= " shop = ".$value." or";
  762. $sid .= " id = ".$value." or";
  763. }
  764. }
  765. $post = $this->input->post(NULL, TRUE);
  766. if(isset($post['page']))
  767. {
  768. $page = $this->input->post('page',true);
  769. $perpage = $this->input->post('perpage',true);
  770. $shop = $this->input->post('shop',true);
  771. $timetk = $this->input->post('timetk',true);
  772. $timetj = $this->input->post('timetj',true);
  773. $timetk = strtotime($timetk);
  774. $timetj = strtotime($timetj);
  775. $where = "print != 999 and state = 207 and review = 1 and number NOT like '%-%-%-%-%' and (".rtrim($fgshop,'or').")";
  776. if($shop)
  777. {
  778. $where .= " and shop = '$shop'";
  779. }
  780. if($timetk && $timetj)
  781. {
  782. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  783. }
  784. //数据排序
  785. $order_str = "id desc";
  786. if(empty($page))
  787. {
  788. $start = 0;
  789. $perpage = 1;
  790. }
  791. else
  792. {
  793. $start = ($page - 1)*$perpage;
  794. }
  795. //取得信息列表
  796. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,name,phone,address,state,dtime,shipremarks,type,merge');
  797. $info = array();
  798. $len = count($info_list);
  799. //格式化数据
  800. foreach ($info_list as $key=>$value)
  801. {
  802. $ud = $this->fullordertt->read($value['id']);
  803. $shop = $this->shop->read($value['shop']);
  804. $warehouse = $this->warehouse->read($value['type']);
  805. $info_list[$key]['shop'] = '<p>'.$shop['shopname'].'</p>'.'<p>'.$warehouse['title'].'</p>';
  806. $typeclass = $this->typeclass->read($value['state']);
  807. $info_list[$key]['state'] = $typeclass['spare'];
  808. $info_list[$key]['type'] = $ud['orderremarks'];
  809. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  810. if($value['merge'] == 0)
  811. {
  812. $info_list[$key]['merge'] = "<p>可合并</p>";
  813. }
  814. else
  815. {
  816. if($value['merge'] == $value['id'])
  817. {
  818. if($ud['print'] < '3' && $ud['library'] == '1')
  819. {
  820. $info_list[$key]['merge'] = "<p><b class='cforder' data-id='".$value['id']."'>拆分订单</b></p>";
  821. }
  822. else
  823. {
  824. $info_list[$key]['merge'] = "已合并";
  825. }
  826. }
  827. else
  828. {
  829. $info_list[$key]['merge'] = "被合并";
  830. }
  831. }
  832. }
  833. /** 操作合并
  834. if($value['merge'] == 0)
  835. {
  836. $info_list[$key]['merge'] = "<p><b class='jd' data-type='5'>合并订单</b></p>";
  837. }
  838. else
  839. {
  840. if($value['merge'] == $value['id'])
  841. {
  842. $info_list[$key]['merge'] = "已合并";
  843. }
  844. else
  845. {
  846. $info_list[$key]['merge'] = "被合并";
  847. }
  848. }
  849. **/
  850. $asd = array();
  851. for($i=0;$i<$len;$i++)
  852. {
  853. for($j=$i+1;$j<$len;$j++)
  854. {
  855. if (strtolower($info_list[$i]['address']) == strtolower($info_list[$j]['address']) && stripos($info_list[$i]['number'],$info_list[$j]['number']) === false && stripos($info_list[$j]['number'],$info_list[$i]['number']) === false) //$info_list[$i]['email'] == $info_list[$j]['email']
  856. {
  857. if(!array_key_exists($j,$info))
  858. {
  859. $info[$j] = $info_list[$j];
  860. }
  861. if(!array_key_exists($i,$info))
  862. {
  863. $info[$i] = $info_list[$i];
  864. }
  865. }
  866. }
  867. }
  868. rsort($info);
  869. $total = count($info);
  870. $pagenum = ceil($total/$perpage);
  871. $over = $total-($start+$perpage);
  872. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>(array_slice($info,$start,$perpage)));
  873. echo json_encode($rows);exit;
  874. }
  875. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  876. $this->data['wlshop'] = $wlshop;
  877. $this->_Template('fullordertt_repeat',$this->data);
  878. }
  879. //修改
  880. public function _edit($arg_array)
  881. {
  882. if(isset($_SESSION['api']))
  883. {
  884. $user = $this->user->get_api($_SESSION['api']);
  885. if($user['vip'] == 1)
  886. {
  887. $vip = 1;
  888. }
  889. else
  890. {
  891. $vip = 0;
  892. }
  893. }
  894. else
  895. {
  896. $vip = 0;
  897. }
  898. $post = $this->input->post(NULL, TRUE);
  899. if(isset($post['id']))
  900. {
  901. $id = $this->input->post('id',true);
  902. $data = $this->fullordertt->read($id);
  903. $post['type'] = $this->input->post('warehouse',true);
  904. $post['country'] = $this->input->post('country',true);
  905. $currency = $this->country->read($post['country']);
  906. $post['al'] = $currency['lb'];
  907. $post['freight'] = $this->input->post('freight',true);
  908. $post['expressmoney'] = $this->input->post('expressmoney',true);
  909. $post['shouldmoney'] = $this->input->post('shouldmoney',true);
  910. $orderremarks = $this->input->post('orderremarks');
  911. $orderremarks = str_replace(array('%26','%2B'),array('&','+'),$orderremarks);
  912. $post['orderremarks'] = $orderremarks;
  913. $shipremarks = $this->input->post('shipremarks');
  914. $shipremarks = str_replace(array('%26','%2B'),array('&','+'),$shipremarks);
  915. $post['shipremarks'] = preg_replace('/( | | |\s)/',' ',$shipremarks);
  916. $post['email'] = $this->input->post('email',true);
  917. //$post['paypal'] = $this->input->post('paypal',true);
  918. $name = $this->input->post('name',true);
  919. $post['name'] = str_replace("'","’",$name);
  920. $post['phone'] = $this->input->post('phone',true);
  921. $post['phone'] = preg_replace('/\D/s','',$post['phone']);
  922. $post['country'] = $this->input->post('country',true);
  923. $post['province'] = $this->input->post('province',true);//省、州
  924. $post['province'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['province']); //替换开头空字符
  925. $post['province'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['province']); //替换结尾空字符
  926. $post['city'] = $this->input->post('city',true);//城市
  927. $post['city'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['city']); //替换开头空字符
  928. $post['city'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['city']); //替换结尾空字符
  929. $post['zipcode'] = $this->input->post('zipcode',true);//邮编
  930. $post['zipcode'] = preg_replace("/^[\s\v".chr(227).chr(128)."]+/","", $post['zipcode']); //替换开头空字符
  931. $post['zipcode'] = preg_replace("/[\s\v".chr(227).chr(128)."]+$/","", $post['zipcode']); //替换结尾空字符
  932. $post['street'] = $this->input->post('street',true);
  933. $address = $this->input->post('address',true);
  934. $address = preg_replace('/( | | |\s)/',' ',$address);
  935. $post['address'] = str_replace("'","’",$address);
  936. $address2 = $this->input->post('address2',true);
  937. $address2 = preg_replace('/( | | |\s)/',' ',$address2);
  938. if($address2 == ' ')
  939. {
  940. $address2 = '';
  941. }
  942. $post['address2'] = str_replace("'","’",$address2);
  943. $post['express'] = $this->input->post('express',true);
  944. $post['printtype'] = $this->input->post('printtype',true);
  945. $fpdata = $this->input->post('fpdata');
  946. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  947. $post['fpdata'] = $fpdata;
  948. $post['waybill'] = $this->input->post('waybill',true);
  949. $post['msg'] = $this->input->post('msg',true);
  950. $post['zsbjz'] = $this->input->post('zsbjz',true);
  951. $post['refundy'] = $this->input->post('refundy',true);
  952. $post['refundj'] = $this->input->post('refundj',true);
  953. $rtime = $this->input->post('rtime',true);
  954. $post['rtime'] = strtotime($rtime);
  955. $post['rpaypal'] = $this->input->post('rpaypal',true);
  956. $post['rtext'] = $this->input->post('rtext',true);
  957. $post['sbpm'] = $this->input->post('sbpm',true);
  958. $post['edittime'] = time();
  959. $editstate = $this->input->post('state',true);
  960. $whlabel = $this->input->post('whlabel',true);
  961. $fpcount = $this->input->post('fpcount',true);
  962. $post['ioss'] = $this->input->post('ioss',true);
  963. $post['waybill'] = preg_replace('/( | | | |\s)/','',$post['waybill']);
  964. $pay = $this->pay->get_typeclass($data['pay']);
  965. $yga = $post['shouldmoney'];
  966. $ygc = $data['estimaterate'];
  967. $post['budget'] = $this->input->post('newbudget',true);
  968. //$post['budget'] = $this->input->post('newbudget',true);
  969. /**
  970. $post['budget'] = 0;
  971. $ifbudget = eval("return $yga*1.$ygc;");
  972. if($ifbudget > 0)
  973. {
  974. $post['budget'] = eval("return $yga*1.$ygc;");
  975. }
  976. **/
  977. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  978. foreach ($whlabeldata as $va)
  979. {
  980. if(stripos($va,'z') !== false)
  981. {
  982. $way += 1;
  983. }
  984. }
  985. //如果备注中出现网红的两个字 ,那么在fpdata种的品名中必须有 WH这两个字 且美仓不用
  986. if($post['type'] !=5 ){
  987. if(stripos($post['shipremarks'],'网红') !== false){
  988. if(stripos($post['fpdata'],'-2090-') === false){
  989. echo json_encode(array('msg'=>'网红单请在商品名称中勾选WH!','success'=>false));exit;
  990. }
  991. }
  992. }
  993. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['type'] == 5))
  994. {
  995. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  996. }
  997. if($post['express'] == 42 && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  998. {
  999. echo json_encode(array('msg'=>'此快递方式必须选择Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1000. }
  1001. if($post['express'] == 24 && $post['sbpm'] != 'Hair Sample' && $post['sbpm'] != 'Human Hair Wigs' && $post['sbpm'] != 'Human Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  1002. {
  1003. echo json_encode(array('msg'=>'此快递方式必须选择Hair Sample/Human Hair Wigs/Human Hair Goods!','success'=>false));exit;
  1004. }
  1005. if($post['country'] != 192 && $post['express'] == 1 && $post['sbpm'] != 'Synthetic Hair Wigs' && $post['sbpm'] != 'Synthetic Hair Goods' && $post['type'] != 34)//$post['express'] == 3 ||
  1006. {
  1007. echo json_encode(array('msg'=>'非美国选择官方DHL必须选择Synthetic Hair Wigs/Synthetic Hair Goods','success'=>false));exit;
  1008. }
  1009. if($way == count($whlabeldata) && $post['type'] != 12)
  1010. {
  1011. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1012. }
  1013. if($way == '0' && $post['type'] == 12)
  1014. {
  1015. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1016. }
  1017. $post['review'] = 1;
  1018. if($post['zsbjz'] < '0.01' && $post['type'] != 34)
  1019. {
  1020. echo json_encode(array('msg'=>'总申报价错误!'.$post['type'],'success'=>false));exit;
  1021. }
  1022. if($data['library'] == 1)
  1023. {
  1024. if($data['print'] != 3)
  1025. {
  1026. $post['print'] = 1;
  1027. $post['libraryconfirm'] = 1;
  1028. $post['librarynot'] = "订单未打印,未审核或未通过";
  1029. }
  1030. else
  1031. {
  1032. $post['libraryconfirm'] = 1;
  1033. $post['librarynot'] = "订单被修改或重新提交";
  1034. }
  1035. }
  1036. if($data['yhs'] == 1)
  1037. {
  1038. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1039. }
  1040. if($post['express'] == 2 && (stripos($post['name'],'&') !== false || stripos($post['name'],"'") !== false))
  1041. {
  1042. echo json_encode(array('msg'=>'USPS收件人或公司名不可用特殊符号!','success'=>false));exit;
  1043. }
  1044. if(strlen($post['client']) > 34 || strlen($post['name']) > 34)//收件人姓名或公司名不允许超过35位
  1045. {
  1046. echo json_encode(array('msg'=>'收件人姓名或公司名不可超过34个字符!','success'=>false));exit;
  1047. }
  1048. if($post['express'] == '3' && $post['address2'] != '')//UPS不允许提交地址2
  1049. {
  1050. echo json_encode(array('msg'=>'UPS不允许提交地址2','success'=>false));exit;
  1051. }
  1052. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $post['country'] != 192 && $post['type'] != 34)
  1053. {
  1054. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1055. }
  1056. if($post['express'] == '3' && $post['country'] != 192 && $post['country'] != 35)
  1057. {
  1058. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1059. }
  1060. if($post['country'] == 35 && $post['zsbjz'] > 20)
  1061. {
  1062. echo json_encode(array('msg'=>'加拿大最高申报不可超过20','success'=>false));exit;
  1063. }
  1064. if(($post['express'] == '28' || $post['express'] == '7') && $post['country'] != 191)
  1065. {
  1066. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1067. }
  1068. $express = $this->express->read($post['express']);
  1069. if($express['ioss'] == 1 && $post['ioss'] == '')
  1070. {
  1071. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1072. }
  1073. if(strlen($post['address']) > $express['addresssize'] || strlen($post['address2']) > $express['addresssize'])
  1074. {
  1075. echo json_encode(array('msg'=>'此快递方地址不可超出'.$express['addresssize'].'个字符','success'=>false));exit;
  1076. }
  1077. if(strlen($post['address']) > 32 && ($post['express'] == 2 || $post['express'] == 16))
  1078. {
  1079. echo json_encode(array('msg'=>'此快递方地址不可超出32个字符','success'=>false));exit;
  1080. }
  1081. if(strlen($post['address']) < 5)
  1082. {
  1083. echo json_encode(array('msg'=>'地址不可留空!','success'=>false));exit;
  1084. }
  1085. if($post['zsbjz'] > $express['sbjz'])
  1086. {
  1087. echo json_encode(array('msg'=>'总申报价值不可超出'.$express['sbjz'],'success'=>false));exit;
  1088. }
  1089. if($post['shouldmoney'] > $express['shouldmoney'] && $express['shouldmoney'] != 0)
  1090. {
  1091. echo json_encode(array('msg'=>'订单金额不可超出'.$express['shouldmoney'],'success'=>false));exit;
  1092. }
  1093. if($post['express'] == '2' && $post['zzl'] > '16' && isset($post['js']) && $post['js'] == '0')
  1094. {
  1095. echo json_encode(array('msg'=>'重量大于16不可按Ground Advantage提交!','success'=>false));exit;
  1096. }
  1097. if($post['express'] == '2' && isset($post['js']) && $post['js'] == '0'&& $post['qm'] == '1')
  1098. {
  1099. echo json_encode(array('msg'=>'Ground Advantage不可使用签名服务!','success'=>false));exit;
  1100. }
  1101. if(isset($post['bx']))
  1102. {
  1103. if($post['express'] == '99' && $post['bx'] > 0)
  1104. {
  1105. echo json_encode(array('msg'=>'此物流不允许购买保险','success'=>false));exit;
  1106. }
  1107. }
  1108. if(($post['express'] == '3' || $post['express'] == '42' || $post['express'] == '24') && $post['shouldmoney'] < 1)
  1109. {
  1110. //echo json_encode(array('msg'=>'零金额订单不可发 UPS/DHL官方-美国/Fedex(杭州)','success'=>false));exit;
  1111. }
  1112. if($post['express'] == '42' && $post['zsbjz'] < 1)
  1113. {
  1114. echo json_encode(array('msg'=>'零申报金额不可发 DHL官方-美国','success'=>false));exit;
  1115. }
  1116. if($post['express'] == '6' && $post['province'] == '')
  1117. {
  1118. echo json_encode(array('msg'=>'选择DPEX必须填写州信息','success'=>false));exit;
  1119. }
  1120. if(($post['express'] == '24' || $post['express'] == '3') && $post['shouldmoney'] == 0)
  1121. {
  1122. echo json_encode(array('msg'=>'0金额订单不可发UPS/Fedex(杭州)!!!','success'=>false));exit;
  1123. }
  1124. if($post['country'] == '35' && $post['zsbjz'] > 20)
  1125. {
  1126. echo json_encode(array('msg'=>'加拿大不可申报超过20美金!!!','success'=>false));exit;
  1127. }
  1128. if($post['printtype'] == 1)//如果是运单
  1129. {
  1130. $post['productdescription'] = $this->input->post('productdescription',true);
  1131. $post['customs'] = $this->input->post('customs',true);
  1132. }
  1133. if($post['express'] == 2 && strlen($post['zipcode']) != 5)//如果usps 邮编不是5位
  1134. {
  1135. echo json_encode(array('msg'=>'USPS-USA的邮编需按5位数格式提交!','success'=>false));exit;
  1136. }
  1137. if(strlen($post['phone']) > 11 && $post['express'] == 63)
  1138. {
  1139. echo json_encode(array('msg'=>'美国联邦,电话号码不允许超过11位!','success'=>false));exit;
  1140. }
  1141. /**
  1142. if($post['paypal'] != '')
  1143. {
  1144. $pp = $this->fullordertt->get_paypal($post['paypal']);
  1145. if(isset($pp['number']) && $pp['number'] != $data['number'])
  1146. {
  1147. echo json_encode(array('msg'=>'此交易号的订单已存在!-'.$pp['number'],'success'=>false));exit;
  1148. }
  1149. }
  1150. **/
  1151. /**
  1152. if($editstate == 216 && $data['state'] != 216)
  1153. {
  1154. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1155. }
  1156. **/
  1157. if($editstate == 216 && preg_match('/\d/is',$post['waybill']) != true)
  1158. {
  1159. //echo json_encode(array('msg'=>'当前信息不可修改订单状态','success'=>false));exit;
  1160. }
  1161. else
  1162. {
  1163. $post['review'] = $data['review'];
  1164. $post['state'] = $editstate;
  1165. }
  1166. $thisdata = $this->fullordertt->read($id);
  1167. $warehouse = $this->warehouse->read($thisdata['type']);
  1168. $warehousenew = $this->warehouse->read($post['type']);
  1169. if($warehousenew['bdcountry'] != 0 && $post['country'] != $warehousenew['bdcountry'])
  1170. {
  1171. echo json_encode(array('msg'=>'当前国家无法选择'.$warehousenew['title'].'!','success'=>false));exit;
  1172. }
  1173. /**
  1174. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1175. {
  1176. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1177. }
  1178. **/
  1179. if($thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1180. {
  1181. echo json_encode(array('msg'=>'此单已出库,无法更改仓库!','success'=>false));exit;
  1182. }
  1183. $expt = $this->express->read($post['express']);
  1184. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false && $post['type'] != 34)
  1185. {
  1186. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1187. }
  1188. if($expt['province'] != '' && stripos($expt['province'],$post['province'].'、') !== false)
  1189. {
  1190. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1191. }
  1192. /**
  1193. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1194. {
  1195. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1196. }
  1197. **/
  1198. //开始注释 xyxg
  1199. /**
  1200. $ft = array();
  1201. $ftdata = explode('|',rtrim($fpcount,'|'));
  1202. foreach ($ftdata as $va)
  1203. {
  1204. $ftitle = '';
  1205. $va = explode('-',trim($va,'-'));
  1206. foreach ($va as $v)
  1207. {
  1208. $v = $this->typeclass->read($v);
  1209. $ftitle .= $v['title'].' ';
  1210. }
  1211. $ft[] = rtrim($ftitle,' ');
  1212. }
  1213. if($data['library'] == 1)
  1214. {
  1215. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$data['shop'],$data['number']);
  1216. if(isset($tqkcyz[0]))
  1217. {
  1218. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1219. }
  1220. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1221. {
  1222. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1223. if($tskcyz['t'] > '0')
  1224. {
  1225. echo $tskcyz['m'];exit;
  1226. }
  1227. }
  1228. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1229. if($kcyz['t'] > '0')
  1230. {
  1231. echo $kcyz['m'];exit;
  1232. }
  1233. }
  1234. //结束注释
  1235. **/
  1236. /** 重新写产品名称
  1237. $dtctitle = array();
  1238. $dictionaries = $this->typeclass->find_all();
  1239. foreach ($dictionaries as $v)
  1240. {
  1241. $dtctitle[$v['id']] = array($v['title'],$v['bqsku']);
  1242. }
  1243. if(stripos($fpdata,'-128-') !== false || stripos($fpdata,'-127-') !== false)
  1244. {
  1245. $dfp = explode(';',trim($fpdata,';'));
  1246. $fdata = '';
  1247. foreach ($dfp as $k=>$v)
  1248. {
  1249. $ptitleb = '';
  1250. $fp = explode('|',trim($v,'|'));
  1251. $fp0 = explode(',',$fp[0]);
  1252. $fp1 = explode('-',trim($fp0[1],'-'));
  1253. foreach ($fp1 as $vv)
  1254. {
  1255. $ptitleb .= isset($dtctitle[$vv])?$dtctitle[$vv][0].' ':'';
  1256. }
  1257. $ptitleb .= $dtctitle[$fp0[0]][1].'inch ';
  1258. $fp[1] = $ptitleb;
  1259. $fdata .= implode("|",$fp).";";
  1260. }
  1261. $fpdata = $fdata;
  1262. }
  1263. **/
  1264. $warehouse = $this->warehouse->read($post['type']);
  1265. if($data['library'] == 1 || ($data['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1266. {
  1267. var_dump($whlabel);
  1268. die;
  1269. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1270. if($kcyz['t'] > '0')
  1271. {
  1272. echo $kcyz['m'];exit;
  1273. }
  1274. else if($kcyz['fpdata'] != '')
  1275. {
  1276. $post['whlabel'] = $kcyz['whlabel'];
  1277. $post['fpdata'] = $kcyz['fpdata'];
  1278. }
  1279. }
  1280. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1281. $post['sfxh'] = $fl['sfxh'];
  1282. $post['ckfl'] = $fl['ckfl'];
  1283. //查询净重开始
  1284. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1285. //查询净重结束
  1286. if($this->fullordertt->save($post,$id))
  1287. {
  1288. if($data['printtime'] == '0')
  1289. {
  1290. $xghz = ',将自动禁止打印';
  1291. }
  1292. else if($data['printtime'] > '0' && $data['librarytime'] == '0')
  1293. {
  1294. $q = '';
  1295. if($data['libraryconfirm'] == 1)
  1296. {
  1297. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1298. }
  1299. $xghz = ',将自动禁止发货'.$q;
  1300. }
  1301. else
  1302. {
  1303. $xghz = '';
  1304. }
  1305. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1306. }
  1307. else
  1308. {
  1309. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1310. }
  1311. }
  1312. $this->data['vip'] = $vip;
  1313. $arg_array = $arg_array[0];$fpdata = array();
  1314. $fullordertt = $this->fullordertt->read($arg_array);
  1315. $returngoods = $this->returngoods->get_orderinfo($fullordertt['orderinfo']);
  1316. $this->data['returngoods'] = $returngoods?1:0;
  1317. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  1318. $country = $this->country->find_all('1=1','id,name','name asc');//所有国家信息
  1319. $express = $this->express->find_all('1=1');//所有快递配置信息
  1320. $this->data['fullordertt'] = $fullordertt;
  1321. if($fullordertt['express'] == 2)
  1322. {
  1323. $zzhl = 'oz';
  1324. }
  1325. else
  1326. {
  1327. $zzhl = 'kg';
  1328. }
  1329. $this->data['zzhl'] = $zzhl;
  1330. $this->data['country'] = $country;
  1331. $this->data['express'] = $express;
  1332. $this->data['dtime'] = date('Y-m-d H:i:s',$fullordertt['dtime']);
  1333. $warehouse = $this->warehouse->read($fullordertt['type']);
  1334. if(stripos($fullordertt['fpdata'],';') !== false)
  1335. {
  1336. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  1337. foreach ($fpdata as $k=>$v)
  1338. {
  1339. $xxv = explode('|',$v);
  1340. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1341. {
  1342. $xxv['zd'] = "<p>已占单</p>";
  1343. $bdck = $warehouse['bdck'];
  1344. if(stripos($xxv[9],'~') !== false)
  1345. {
  1346. $dxxv = explode('~',trim($xxv[9],'~'));
  1347. foreach ($dxxv as $val)
  1348. {
  1349. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1350. if($wzid['details'] != '')
  1351. {
  1352. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1353. }
  1354. }
  1355. }
  1356. else
  1357. {
  1358. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1359. if($wzid['details'] != '')
  1360. {
  1361. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1362. }
  1363. }
  1364. }
  1365. $fpdata[$k] = $xxv;
  1366. }
  1367. }
  1368. $this->data['fpdata'] = $fpdata;
  1369. $thfpdataxs = array();
  1370. if($fullordertt['thfpdata'] != '')
  1371. {
  1372. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  1373. foreach ($thfpdata as $k=>$v)
  1374. {
  1375. $thxs = explode('~',trim($v,'~'));
  1376. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1377. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1378. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1379. }
  1380. }
  1381. $this->data['thfpdata'] = $thfpdataxs;
  1382. $shop = $this->shop->read($fullordertt['shop']);
  1383. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1384. $is = 0;
  1385. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1386. {
  1387. $is = 1;
  1388. }
  1389. $this->data['is'] = $is;
  1390. if(isset($_SESSION['api']))
  1391. {
  1392. $user = $this->user->get_api($_SESSION['api']);
  1393. if($user['vip'] == 1)
  1394. {
  1395. $vip = 1;
  1396. }
  1397. else
  1398. {
  1399. $vip = 0;
  1400. }
  1401. }
  1402. else
  1403. {
  1404. $vip = 0;
  1405. }
  1406. $this->data['power'] = $vip;
  1407. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1408. $downwaybill = '';$dwls = array();
  1409. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  1410. if(isset($oldwaybill[0][1]))
  1411. {
  1412. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1413. foreach ($oldwaybill as $v)
  1414. {
  1415. $dw = explode('/',$v);
  1416. if(isset($dw[1]))
  1417. {
  1418. if(stripos($downwaybill,$dw[1]) === false)
  1419. {
  1420. $dwls[$dw[1]] = 1;
  1421. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1422. }
  1423. }
  1424. }
  1425. }
  1426. if($fullordertt['printtype'] == 1)
  1427. {
  1428. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  1429. {
  1430. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  1431. }
  1432. }
  1433. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1434. /** 历史打印时间 **/
  1435. $printtime = '';
  1436. if($fullordertt['oldprinttime'])
  1437. {
  1438. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  1439. foreach ($pte as $v)
  1440. {
  1441. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1442. }
  1443. }
  1444. $this->data['printtime'] = rtrim($printtime,'、');
  1445. $product = '';
  1446. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  1447. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  1448. {
  1449. $pt = explode(',',$fullordertt['product']);
  1450. $lk = explode(',',$fullordertt['link']);
  1451. for($i=0;$i<count($pt);$i++)
  1452. {
  1453. if(isset($lk[$i]))
  1454. {
  1455. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  1456. }
  1457. else
  1458. {
  1459. $octs = '';
  1460. }
  1461. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  1462. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  1463. if(isset($lk[$i]))
  1464. {
  1465. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  1466. }
  1467. else
  1468. {
  1469. $product .= ($product != '')?' , '.$a:$a;
  1470. }
  1471. }
  1472. }
  1473. else
  1474. {
  1475. $octs = $this->colourorderts->get_text($fullordertt['product']);
  1476. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  1477. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  1478. $product = $a;
  1479. }
  1480. $this->data['product'] = $product;
  1481. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  1482. $outread = '';
  1483. if($out)
  1484. {
  1485. foreach ($out as $val)
  1486. {
  1487. $list = '';
  1488. $rk = explode('|',trim($val['rk'],'|'));
  1489. $rktime = explode('|',trim($val['rktime'],'|'));
  1490. $zw = array();
  1491. $t = $this->transfer->find_all("1=1");
  1492. foreach ($t as $v)
  1493. {
  1494. $zw[$v['id']] = $v['title'];
  1495. }
  1496. if($val['rk'] != '' && count($rk) > 0)
  1497. {
  1498. for($i=0;$i<count($rk);$i++)
  1499. {
  1500. if(!isset($rktime[$i]))
  1501. {
  1502. $list .= $zw[$cz[$i]];
  1503. }
  1504. else
  1505. {
  1506. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1507. }
  1508. }
  1509. }
  1510. //$outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1511. $outread .= '<span style="color:#f00">'.$val['shipremarks'].'</span>:'.$list.'<br>';
  1512. }
  1513. }
  1514. else
  1515. {
  1516. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  1517. $outread = array();
  1518. if($systemwigsout)
  1519. {
  1520. foreach ($systemwigsout as $v)
  1521. {
  1522. if($v['czwarehouse'] == 37)
  1523. {
  1524. $outread[] = '华荣厂';
  1525. }
  1526. else if($v['czwarehouse'] == 0)
  1527. {
  1528. $outread[] = '龙盈厂';
  1529. }
  1530. $cz = explode('|',trim($v['cz'],'|'));
  1531. $cztime = explode('|',trim($v['cztime'],'|'));
  1532. $zw = $this->transfer->get_list();
  1533. if($v['cz'] != '' && count($cz) > 0)
  1534. {
  1535. for($i=0;$i<count($cz);$i++)
  1536. {
  1537. if(!isset($cztime[$i]))
  1538. {
  1539. $outread[] = $zw[$cz[$i]].' -&gt; ';
  1540. }
  1541. else
  1542. {
  1543. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1544. }
  1545. }
  1546. $outread[] = '<br>';
  1547. }
  1548. }
  1549. }
  1550. }
  1551. $klarnacolor = '';
  1552. if($fullordertt['klarnadata'] !='')
  1553. {
  1554. $klarnadata = explode('|',$fullordertt['klarnadata']);
  1555. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  1556. {
  1557. $klarnadata[1] = json_decode($klarnadata[1],true);
  1558. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  1559. {
  1560. $klarnacolor = 'style="color:#F00"';
  1561. }
  1562. }
  1563. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  1564. {
  1565. $klarnacolor = 'style="color:#F00"';
  1566. }
  1567. if($fullordertt['pay'] == 23)//klarna
  1568. {
  1569. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  1570. $ToState = array_flip($ToState);
  1571. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  1572. $city = str_replace(' ','',$fullordertt['city']);
  1573. $klarnadataaddress = explode($city,$klarnadata3);
  1574. if(isset($klarnadataaddress[1]))
  1575. {
  1576. $klarnadata3 = $city.$klarnadataaddress[1];
  1577. $klarnadatacolor = explode(',',$klarnadata3);
  1578. unset($klarnadatacolor[4]);
  1579. unset($klarnadatacolor[6]);
  1580. if(isset($ToState[$klarnadatacolor[1]]))
  1581. {
  1582. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  1583. }
  1584. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  1585. }
  1586. else
  1587. {
  1588. $klarnadata['color'] = $klarnadata3;
  1589. }
  1590. }
  1591. }
  1592. else
  1593. {
  1594. $klarnadata = '';
  1595. }
  1596. $p = explode('-',$fullordertt['paypal']);
  1597. $this->data['klarnacolor'] = $klarnacolor;
  1598. $this->data['klarnadata'] = $klarnadata;
  1599. $this->data['systemwigsout'] = $outread;
  1600. $quantity = explode(';',trim($fullordertt['quantity'],';'));
  1601. $qc = 0;
  1602. foreach ($quantity as $v)
  1603. {
  1604. if($v > 1)
  1605. {
  1606. $qc += 1;
  1607. }
  1608. }
  1609. $this->data['qc'] = $qc;
  1610. $this->_Template('fullordertt_edit',$this->data);
  1611. }
  1612. //不可修改
  1613. public function _readonly($arg_array)
  1614. {
  1615. $post = $this->input->post(NULL, TRUE);
  1616. if(isset($post['id']))
  1617. {
  1618. $id = $this->input->post('id',true);
  1619. $ud = $this->fullordertt->read($id);
  1620. $post['type'] = $this->input->post('warehouse',true);
  1621. $post['orderremarks'] = $this->input->post('orderremarks',true);
  1622. $post['state'] = $this->input->post('state',true);
  1623. $post['msg'] = $this->input->post('msg',true);
  1624. $post['refundy'] = $this->input->post('refundy',true);
  1625. $post['refundj'] = $this->input->post('refundj',true);
  1626. $fpdata = $this->input->post('fpdata');
  1627. $fpdata = str_replace(array('%26','%2B'),array('&','+'),$fpdata);
  1628. $post['fpdata'] = $fpdata;
  1629. $rtime = $this->input->post('rtime',true);
  1630. $post['rtime'] = strtotime($rtime);
  1631. $post['rpaypal'] = $this->input->post('rpaypal',true);
  1632. $post['rtext'] = $this->input->post('rtext',true);
  1633. $post['express'] = $this->input->post('express',true);
  1634. $whlabel = $this->input->post('whlabel',true);
  1635. $post['budget'] = $this->input->post('newbudget',true);
  1636. //$post['ioss'] = $this->input->post('ioss',true);
  1637. $post['edittime'] = time();
  1638. $editstate = $post['state'];
  1639. /**
  1640. if($post['state'] == 216 && $ud['state'] != 216)
  1641. {
  1642. echo json_encode(array('msg'=>'不可修改为完成状态','success'=>false));exit;
  1643. }
  1644. **/
  1645. $whlabeldata = explode('|',trim($whlabel,'|'));$way = 0;
  1646. foreach ($whlabeldata as $va)
  1647. {
  1648. if(stripos($va,'z') !== false)
  1649. {
  1650. $way += 1;
  1651. }
  1652. }
  1653. if((($post['express'] == 2 || $post['express'] == 63 || $post['express'] == 64) && $post['type'] != 5) || ($post['express'] != 2 && $post['express'] != 63 && $post['express'] != 64 && $post['type'] == 5))
  1654. {
  1655. echo json_encode(array('msg'=>'此快递方式必须选择美国仓!','success'=>false));exit;
  1656. }
  1657. if($way == count($whlabeldata) && $post['type'] != 12)
  1658. {
  1659. echo json_encode(array('msg'=>'必须选择特殊仓!','success'=>false));exit;
  1660. }
  1661. if($way == '0' && $post['type'] == 12)
  1662. {
  1663. echo json_encode(array('msg'=>'特殊仓必须包含特殊仓货物!','success'=>false));exit;
  1664. }
  1665. $fpcount = $this->input->post('fpcount',true);
  1666. if(!$fpcount)
  1667. {
  1668. echo json_encode(array('msg'=>'需要先清理浏览器缓存,刷新当前页面后再试!','success'=>false));exit;
  1669. }
  1670. if($ud['library'] == 1)
  1671. {
  1672. if($ud['print'] != 3)
  1673. {
  1674. $post['print'] = 1;
  1675. $post['libraryconfirm'] = 1;
  1676. $post['librarynot'] = "订单未打印,未审核或未通过";
  1677. }
  1678. else
  1679. {
  1680. $post['libraryconfirm'] = 1;
  1681. $post['librarynot'] = "订单被重新提交";
  1682. }
  1683. }
  1684. if(($post['express'] == '5' || $post['express'] == '24' || $post['express'] == '42' || $post['express'] == '31') && $ud['country'] != 192)
  1685. {
  1686. echo json_encode(array('msg'=>'非美国无法选择Fedex、DHL官方-美国!','success'=>false));exit;
  1687. }
  1688. if($post['express'] == '3' && $ud['country'] != 192 && $ud['country'] != 35)
  1689. {
  1690. echo json_encode(array('msg'=>'非美国和加拿大无法选择UPS!','success'=>false));exit;
  1691. }
  1692. if(($post['express'] == '28' || $post['express'] == '7') && $ud['country'] != 191)
  1693. {
  1694. echo json_encode(array('msg'=>'非英国无法选择CNE和GES!','success'=>false));exit;
  1695. }
  1696. $express = $this->express->read($post['express']);
  1697. /**
  1698. if($express['ioss'] == 1 && $post['ioss'] == '')
  1699. {
  1700. echo json_encode(array('msg'=>'此快递方式必须选择IOSS!','success'=>false));exit;
  1701. }
  1702. **/
  1703. $thisdata = $this->fullordertt->read($id);
  1704. $warehouse = $this->warehouse->read($thisdata['type']);
  1705. $warehousenew = $this->warehouse->read($post['type']);
  1706. if(($warehouse['zd'] == '1' || stripos($thisdata['whlabel'],'z|') !== false) && $thisdata['library'] == '2' && $post['type'] != $thisdata['type'])//如果已出库并且开启库存模式仓库或者有特殊库存,禁止调整仓库
  1707. {
  1708. echo json_encode(array('msg'=>'此单已占用库存并出库,无法更改仓库!','success'=>false));exit;
  1709. }
  1710. if($ud['yhs'] == 1)
  1711. {
  1712. echo json_encode(array('msg'=>'仓库货物验证中,请稍后再试!','success'=>false));exit;
  1713. }
  1714. $expt = $this->express->read($post['express']);
  1715. if($expt['pt'] != '' && stripos($post['fpdata'],$expt['pt']) !== false)
  1716. {
  1717. echo json_encode(array('msg'=>$expt['ptts'],'success'=>false));exit;
  1718. }
  1719. if($expt['province'] != '' && stripos($expt['province'],$ud['province'].'、') !== false)
  1720. {
  1721. echo json_encode(array('msg'=>'此省/州不可使用 '.$expt['servicename'],'success'=>false));exit;
  1722. }
  1723. /**
  1724. if($warehouse['zd'] == '1' && $warehouse['ys'] != '1' && $thisdata['library'] == '2' && $post['fpdata'] != $thisdata['fpdata'])
  1725. {
  1726. echo json_encode(array('msg'=>'已扣减库存,无法更改产品!','success'=>false));exit;
  1727. }
  1728. **/
  1729. /**
  1730. if($warehousenew['zd'] == '1' && $editstate != $thisdata['state'] && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1731. {
  1732. echo json_encode(array('msg'=>'如需更改订单状态,请先把仓库选择为非开启库存模式仓库或等待订单出库!','success'=>false));exit;
  1733. }
  1734. if($warehousenew['zd'] == '1' && $editstate != '207' && $thisdata['library'] == '1')//如果提交的仓库开启库存模式并且更改订单状态并且未出库,那么拒绝
  1735. {
  1736. echo json_encode(array('msg'=>'非待发货状态,不允许修改为开启库存模式仓库','success'=>false));exit;
  1737. }
  1738. **/
  1739. //开始注释 xyxg
  1740. /**
  1741. $ft = array();
  1742. $ftdata = explode('|',rtrim($fpcount,'|'));
  1743. foreach ($ftdata as $va)
  1744. {
  1745. $ftitle = '';
  1746. $va = explode('-',trim($va,'-'));
  1747. foreach ($va as $v)
  1748. {
  1749. $v = $this->typeclass->read($v);
  1750. $ftitle .= $v['title'].' ';
  1751. }
  1752. $ft[] = rtrim($ftitle,' ');
  1753. }
  1754. $user = $this->user->get_api($_SESSION['api']);
  1755. if($ud['library'] == 1)
  1756. {
  1757. $tqkcyz = $this->_kcyz($post['type'],$whlabel,$id,$ud['shop'],$ud['number']);
  1758. if(isset($tqkcyz[0]))
  1759. {
  1760. echo json_encode(array('t'=>2,'msg'=>"红色商品名库存匹配错误或库存不够扣减",'error'=>$tqkcyz,'success'=>false));exit;
  1761. }
  1762. if(stripos($whlabel,'z|') !== false || stripos($thisdata['whlabel'],'z|') !== false)
  1763. {
  1764. $tskcyz = $this->specialstock->get_kc($thisdata['state'],$post['state'],$whlabel,$thisdata['whlabel'],$thisdata['number']);
  1765. if($tskcyz['t'] > '0')
  1766. {
  1767. echo $tskcyz['m'];exit;
  1768. }
  1769. }
  1770. $kcyz = $this->whlabel->get_kc($thisdata['state'],$post['state'],$warehousenew['zd'],$warehousenew['ys'],$post['type'],$whlabel,$fpcount,$ft,$thisdata['number'],$thisdata['shop'],$thisdata['type'],$thisdata['whlabel']);//旧状态、新状态、仓库占单设置、仓库预设设置、新仓库、新产品简化数字、旧产品数字、旧产品名称、订单号、订单店铺、旧订单仓库、旧产品简化数字
  1771. if($kcyz['t'] > '0')
  1772. {
  1773. echo $kcyz['m'];exit;
  1774. }
  1775. }
  1776. //结束注释
  1777. **/
  1778. $warehouse = $this->warehouse->read($post['type']);
  1779. if($ud['library'] == 1 || ($ud['library'] != 2 && ($post['state'] != '207' || $post['state'] == '209')))
  1780. {
  1781. $kcyz = $this->ck->get_kc($post['state'],$warehouse,$thisdata['shop'],$thisdata['number'],$whlabel,$fpdata);
  1782. if($kcyz['t'] > '0')
  1783. {
  1784. echo $kcyz['m'];exit;
  1785. }
  1786. else if($kcyz['fpdata'] != '')
  1787. {
  1788. $post['whlabel'] = $kcyz['whlabel'];
  1789. $post['fpdata'] = $kcyz['fpdata'];
  1790. }
  1791. }
  1792. $fl = $this->ck->get_fl($warehouse['hz'],$whlabel,$fpdata);
  1793. $post['sfxh'] = $fl['sfxh'];
  1794. $post['ckfl'] = $fl['ckfl'];
  1795. //查询净重开始
  1796. $post['jweight'] = $this->weight->get_weightcx($post['fpdata']);
  1797. //查询净重结束
  1798. if($this->fullordertt->save($post,$id))
  1799. {
  1800. if($ud['printtime'] == '0')
  1801. {
  1802. $xghz = ',将自动禁止打印';
  1803. }
  1804. else if($ud['printtime'] > '0' && $ud['librarytime'] == '0')
  1805. {
  1806. $q = '';
  1807. if($ud['libraryconfirm'] == 1)
  1808. {
  1809. $q = ',<em style="color: #F00;">改前状态为:禁止出库</em>';
  1810. }
  1811. $xghz = ',将自动禁止发货'.$q;
  1812. }
  1813. else
  1814. {
  1815. $xghz = '';
  1816. }
  1817. echo json_encode(array('msg'=>'修改成功'.$xghz,'id'=>$id,'success'=>true));exit;
  1818. }
  1819. else
  1820. {
  1821. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  1822. }
  1823. }
  1824. $arg_array = $arg_array[0];$fpdata = array();
  1825. $fullordertt = $this->fullordertt->read($arg_array);
  1826. $returngoods = $this->returngoods->get_orderinfo($fullordertt['orderinfo']);
  1827. $this->data['returngoods'] = $returngoods?1:0;
  1828. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  1829. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  1830. $this->data['fullordertt'] = $fullordertt;
  1831. if($fullordertt['express'] == 2)
  1832. {
  1833. $zzhl = 'oz';
  1834. }
  1835. else
  1836. {
  1837. $zzhl = 'kg';
  1838. }
  1839. $this->data['zzhl'] = $zzhl;
  1840. $this->data['countrys'] = $this->country->find_all();
  1841. $this->data['express'] = $this->express->find_all();
  1842. $warehouse = $this->warehouse->read($fullordertt['type']);
  1843. if(stripos($fullordertt['fpdata'],';') !== false)
  1844. {
  1845. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  1846. foreach ($fpdata as $k=>$v)
  1847. {
  1848. $xxv = explode('|',$v);
  1849. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  1850. {
  1851. $xxv['zd'] = "<p>已占单</p>";
  1852. $bdck = $warehouse['bdck'];
  1853. if(stripos($xxv[9],'~') !== false)
  1854. {
  1855. $dxxv = explode('~',trim($xxv[9],'~'));
  1856. foreach ($dxxv as $val)
  1857. {
  1858. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  1859. if($wzid['details'] != '')
  1860. {
  1861. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1862. }
  1863. }
  1864. }
  1865. else
  1866. {
  1867. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  1868. if($wzid['details'] != '')
  1869. {
  1870. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  1871. }
  1872. }
  1873. }
  1874. $fpdata[$k] = $xxv;
  1875. }
  1876. }
  1877. $this->data['fpdata'] = $fpdata;
  1878. $this->data['fpdata'] = $fpdata;
  1879. $thfpdataxs = array();
  1880. if($fullordertt['thfpdata'] != '')
  1881. {
  1882. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  1883. foreach ($thfpdata as $k=>$v)
  1884. {
  1885. $thxs = explode('~',trim($v,'~'));
  1886. $thxs[0] = explode('|',trim($thxs[0],'|'));
  1887. $thxs[1] = explode('|',trim($thxs[1],'|'));
  1888. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  1889. }
  1890. }
  1891. $this->data['thfpdata'] = $thfpdataxs;
  1892. $shop = $this->shop->read($fullordertt['shop']);
  1893. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  1894. $is = 0;
  1895. if($shop['type'] == 269)//判断是否独立站,269是独立站
  1896. {
  1897. $is = 1;
  1898. }
  1899. $this->data['is'] = $is;
  1900. //单项开始
  1901. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  1902. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  1903. $country = $this->country->read($fullordertt['country']);//国家
  1904. if($fullordertt['capital'] == 1)
  1905. {
  1906. $capital = '暂未支付';
  1907. }
  1908. else if($fullordertt['capital'] == 2)
  1909. {
  1910. $capital = '部分支付';
  1911. }
  1912. else if($fullordertt['capital'] == 3)
  1913. {
  1914. $capital = '全部支付';
  1915. }
  1916. if($fullordertt['printtype'] == 1)
  1917. {
  1918. $printtype = '运单';
  1919. }
  1920. else if($fullordertt['printtype'] == 2)
  1921. {
  1922. $printtype = '发货单';
  1923. }
  1924. else if($fullordertt['printtype'] == 3)
  1925. {
  1926. $printtype = '不打印单据';
  1927. }
  1928. else
  1929. {
  1930. $printtype = '未选择';
  1931. }
  1932. $this->data['warehouse'] = $warehouse['title'];
  1933. $this->data['state'] = $state['title'];
  1934. $this->data['capital'] = $capital;
  1935. $this->data['country'] = $country['name'];
  1936. $this->data['printtype'] = $printtype;
  1937. //单项结束
  1938. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  1939. $downwaybill = '';$dwls = array();
  1940. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  1941. if(isset($oldwaybill[0][1]))
  1942. {
  1943. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  1944. foreach ($oldwaybill as $v)
  1945. {
  1946. $dw = explode('/',$v);
  1947. if(isset($dw[1]))
  1948. {
  1949. if(stripos($downwaybill,$dw[1]) === false)
  1950. {
  1951. $dwls[$dw[1]] = 1;
  1952. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  1953. }
  1954. }
  1955. }
  1956. }
  1957. if($fullordertt['printtype'] == 1)
  1958. {
  1959. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  1960. {
  1961. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  1962. }
  1963. }
  1964. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  1965. /** 历史打印时间 **/
  1966. $printtime = '';
  1967. if($fullordertt['oldprinttime'])
  1968. {
  1969. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  1970. foreach ($pte as $v)
  1971. {
  1972. if(is_numeric($v) && $v > 0)
  1973. {
  1974. $printtime .= date('Y-m-d H:i:s',$v).'、';
  1975. }
  1976. }
  1977. }
  1978. $this->data['printtime'] = rtrim($printtime,'、');
  1979. $product = '';
  1980. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  1981. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  1982. {
  1983. $pt = explode(',',$fullordertt['product']);
  1984. $lk = explode(',',$fullordertt['link']);
  1985. for($i=0;$i<count($pt);$i++)
  1986. {
  1987. if(isset($lk[$i]))
  1988. {
  1989. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  1990. }
  1991. else
  1992. {
  1993. $octs = '';
  1994. }
  1995. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  1996. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  1997. if(isset($lk[$i]))
  1998. {
  1999. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  2000. }
  2001. else
  2002. {
  2003. $product .= ($product != '')?' , '.$a:$a;
  2004. }
  2005. }
  2006. }
  2007. else
  2008. {
  2009. $octs = $this->colourorderts->get_text($fullordertt['product']);
  2010. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  2011. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  2012. $product = $a;
  2013. }
  2014. $this->data['product'] = $product;
  2015. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  2016. $outread = '';
  2017. if($out)
  2018. {
  2019. foreach ($out as $val)
  2020. {
  2021. $list = '';
  2022. $rk = explode('|',trim($val['rk'],'|'));
  2023. $rktime = explode('|',trim($val['rktime'],'|'));
  2024. $zw = array();
  2025. $t = $this->transfer->find_all("1=1");
  2026. foreach ($t as $v)
  2027. {
  2028. $zw[$v['id']] = $v['title'];
  2029. }
  2030. if($val['rk'] != '' && count($rk) > 0)
  2031. {
  2032. for($i=0;$i<count($rk);$i++)
  2033. {
  2034. if(!isset($rktime[$i]))
  2035. {
  2036. $list .= $zw[$cz[$i]];
  2037. }
  2038. else
  2039. {
  2040. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2041. }
  2042. }
  2043. }
  2044. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2045. }
  2046. }
  2047. else
  2048. {
  2049. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  2050. $outread = array();
  2051. if($systemwigsout)
  2052. {
  2053. foreach ($systemwigsout as $v)
  2054. {
  2055. if($v['czwarehouse'] == 37)
  2056. {
  2057. $outread[] = '华荣厂';
  2058. }
  2059. else if($v['czwarehouse'] == 0)
  2060. {
  2061. $outread[] = '龙盈厂';
  2062. }
  2063. $cz = explode('|',trim($v['cz'],'|'));
  2064. $cztime = explode('|',trim($v['cztime'],'|'));
  2065. $zw = $this->transfer->get_list();
  2066. if($v['cz'] != '' && count($cz) > 0)
  2067. {
  2068. for($i=0;$i<count($cz);$i++)
  2069. {
  2070. if(!isset($cztime[$i]))
  2071. {
  2072. $outread[] = $zw[$cz[$i]].' -&gt; ';
  2073. }
  2074. else
  2075. {
  2076. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2077. }
  2078. }
  2079. $outread[] = '<br>';
  2080. }
  2081. }
  2082. }
  2083. }
  2084. $klarnacolor = '';
  2085. if($fullordertt['klarnadata'] !='')
  2086. {
  2087. $klarnadata = explode('|',$fullordertt['klarnadata']);
  2088. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  2089. {
  2090. $klarnadata[1] = json_decode($klarnadata[1],true);
  2091. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  2092. {
  2093. $klarnacolor = 'style="color:#F00"';
  2094. }
  2095. }
  2096. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  2097. {
  2098. $klarnacolor = 'style="color:#F00"';
  2099. }
  2100. if($fullordertt['pay'] == 23)//klarna
  2101. {
  2102. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  2103. $ToState = array_flip($ToState);
  2104. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  2105. $city = str_replace(' ','',$fullordertt['city']);
  2106. $klarnadataaddress = explode($city,$klarnadata3);
  2107. if(isset($klarnadataaddress[1]))
  2108. {
  2109. $klarnadata3 = $city.$klarnadataaddress[1];
  2110. $klarnadatacolor = explode(',',$klarnadata3);
  2111. unset($klarnadatacolor[4]);
  2112. unset($klarnadatacolor[6]);
  2113. if(isset($ToState[$klarnadatacolor[1]]))
  2114. {
  2115. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  2116. }
  2117. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  2118. }
  2119. else
  2120. {
  2121. $klarnadata['color'] = $klarnadata3;
  2122. }
  2123. }
  2124. }
  2125. else
  2126. {
  2127. $klarnadata = '';
  2128. }
  2129. $p = explode('-',$fullordertt['paypal']);
  2130. $this->data['klarnacolor'] = $klarnacolor;
  2131. $this->data['klarnadata'] = $klarnadata;
  2132. $this->data['systemwigsout'] = $outread;
  2133. $quantity = explode(';',trim($fullordertt['quantity'],';'));
  2134. $qc = 0;
  2135. foreach ($quantity as $v)
  2136. {
  2137. if($v > 1)
  2138. {
  2139. $qc += 1;
  2140. }
  2141. }
  2142. $this->data['qc'] = $qc;
  2143. $this->_Template('fullordertt_readonly',$this->data);
  2144. }
  2145. //浏览列表
  2146. public function _readlist()
  2147. {
  2148. if(isset($_SESSION['api']))
  2149. {
  2150. $user = $this->user->get_api($_SESSION['api']);
  2151. $usp = $user;
  2152. $fgshop = "";$sid = "";
  2153. $usersp = explode('|',trim($user['shop'],'|'));
  2154. foreach ($usersp as $value)
  2155. {
  2156. $fgshop .= " shop = ".$value." or";
  2157. $sid .= " id = ".$value." or";
  2158. }
  2159. }
  2160. $post = $this->input->post(NULL, TRUE);
  2161. if(isset($post['page']))
  2162. {
  2163. $page = $this->input->post('page',true);
  2164. $perpage = $this->input->post('perpage',true);
  2165. $shop = $this->input->post('shop',true);
  2166. $warehouse = $this->input->post('warehouse',true);
  2167. $express = $this->input->post('express',true);
  2168. $state = $this->input->post('state',true);
  2169. $print = $this->input->post('print',true);
  2170. $libraryconfirm = $this->input->post('libraryconfirm',true);
  2171. $orderinfo = $this->input->post('orderinfo',true);
  2172. $client = $this->input->post('name',true);
  2173. $email = $this->input->post('email',true);
  2174. $number = $this->input->post('number',true);
  2175. $waybill = $this->input->post('waybill',true);
  2176. $authorid = $this->input->post('authorid',true);
  2177. $sourcecontentid = $this->input->post('sourcecontentid',true);
  2178. $timetk = $this->input->post('timetk',true);
  2179. $timetj = $this->input->post('timetj',true);
  2180. $timetk = strtotime($timetk);
  2181. $timetj = strtotime($timetj);
  2182. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2183. if($shop)
  2184. {
  2185. $where .= " and shop = '$shop'";
  2186. }
  2187. if($warehouse)
  2188. {
  2189. $where .= " and type = '$warehouse'";
  2190. }
  2191. if($express)
  2192. {
  2193. $where .= " and express = '$express'";
  2194. }
  2195. if($state)
  2196. {
  2197. $where .= " and state = '$state'";
  2198. }
  2199. if($print)
  2200. {
  2201. $where .= " and print = '$print'";
  2202. }
  2203. if($libraryconfirm)
  2204. {
  2205. $where .= " and libraryconfirm = '$libraryconfirm'";
  2206. }
  2207. if($orderinfo)
  2208. {
  2209. $where .= " and orderinfo = '$orderinfo'";
  2210. }
  2211. if($client)
  2212. {
  2213. $where .= " and client like '%$client%'";
  2214. }
  2215. if($email)
  2216. {
  2217. $where .= " and email = '$email'";
  2218. }
  2219. if($number)
  2220. {
  2221. $where .= " and number = '$number'";
  2222. }
  2223. if($waybill)
  2224. {
  2225. $where .= " and waybill = '$waybill'";
  2226. }
  2227. if($authorid)
  2228. {
  2229. $where .= " and authorid = '$authorid'";
  2230. }
  2231. if($sourcecontentid)
  2232. {
  2233. $where .= " and sourcecontentid = '$sourcecontentid'";
  2234. }
  2235. if($timetk && $timetj)
  2236. {
  2237. $timetj = $timetj+24*3600;
  2238. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2239. }
  2240. //数据排序
  2241. $order_str = "dtime desc";
  2242. if(empty($page))
  2243. {
  2244. $start = 0;
  2245. $perpage = 1;
  2246. }
  2247. else
  2248. {
  2249. $start = ($page - 1)*$perpage;
  2250. }
  2251. //取得信息列表
  2252. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,sname,state,dtime,review,libraryconfirm,express,waybill,exstate,orderremarks,library,clientremarks',$order_str,$start,$perpage);
  2253. //格式化数据
  2254. $dt = 0;
  2255. foreach ($info_list as $key=>$value)
  2256. {
  2257. $ud = $this->fullordertt->read($value['id']);
  2258. $ud['address'] = str_replace("'","’",$ud['address']);
  2259. $ud['name'] = str_replace("'","’",$ud['name']);
  2260. $customer = $this->customertt->get_email($ud['email'],$value['shop']);
  2261. $customernum = $this->fullordertt->find_count("email = '".$ud['email']."' and shop = '".$value['shop']."'");
  2262. preg_match_all('/[0-9]/u',$ud['phone'],$result);
  2263. $numphone = join('',$result[0]);
  2264. $customerb = $this->customertt->find_all("type = 2 and (email = '".$ud['email']."' or address = '".$ud['address']."' or numphone = '".$numphone."')",'*','id desc');
  2265. $customerc = $this->customertt->find_all("type = 1 and shop = '".$ud['shop']."' and address = '".$ud['address']."' and numphone = '".$numphone."'",'*','id desc');
  2266. //$a = array_column($customer, 'email'); //三维找其中健的数组
  2267. //$a = array_flip($a); //键和值调换
  2268. $lkh = $value['sname'];
  2269. $djlkh = 0;$djhmd = 0;
  2270. if($customer)
  2271. {
  2272. if(($customer['type'] == 1 && $customernum > 1))// || $customerc['type'] == 1 && $customerc['num'] > 1
  2273. {
  2274. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2275. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2276. $djlkh = 1;
  2277. $djcount = $count;
  2278. }
  2279. else if(isset($customerc[0]['num']))
  2280. {
  2281. if($customerc[0]['num'] > 1)
  2282. {
  2283. $count = $customer['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customer['count'].'"></i>':'';
  2284. $lkh = "<p>".$value['sname']."</p><p style='color:#FF3333'>".$count."老客户</p>";
  2285. $djlkh = 1;
  2286. $djcount = $count;
  2287. }
  2288. }
  2289. }
  2290. if($customerb)
  2291. {
  2292. $hmsp = $this->shop->read($customerb[0]['shop']);
  2293. $count = $customerb[0]['count']?'<i class="method fa fa-exclamation-circle" data-t="'.$customerb[0]['count'].'"></i>':'';
  2294. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'>".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2295. $djhmd = 1;
  2296. }
  2297. if($djlkh == '1' && $djhmd == '1')
  2298. {
  2299. $lkh = "<p>".$value['sname']."</p><p style='color:#9900CC'><em style='color:#FF3333'>".$djcount."老客户</em> - ".$count."黑名单</p><p style='color:#9900CC'>来自".$hmsp['shopname']."</p>";
  2300. }
  2301. $info_list[$key]['sname'] = $lkh;
  2302. $shop = $this->shop->read($value['shop']);
  2303. $info_list[$key]['shop'] = $shop['shopname'];
  2304. //$info_list[$key]['user'] = $shop['shopuser'];
  2305. $warehouse = $this->warehouse->read($value['type']);
  2306. $warehousetitle = $warehouse['title'];
  2307. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  2308. $info_list[$key]['type'] = $warehousetitle;
  2309. $typeclass = $this->typeclass->read($value['state']);
  2310. $info_list[$key]['state'] = $typeclass['spare'];
  2311. $wl = '';
  2312. if($value['exstate'] == '99')
  2313. {
  2314. $wl = '<font style="color:#ccc">未获取到物流信息</font>';
  2315. }
  2316. else if($value['exstate'] == '1')
  2317. {
  2318. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已揽收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2319. }
  2320. else if($value['exstate'] == '2')
  2321. {
  2322. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">在途中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2323. }
  2324. else if($value['exstate'] == '3')
  2325. {
  2326. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送中<font style="display: none">'.$ud['excontent'].'</font></font>';
  2327. }
  2328. else if($value['exstate'] == '4')
  2329. {
  2330. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">已签收<font style="display: none">'.$ud['excontent'].'</font></font>';
  2331. }
  2332. else if($value['exstate'] == '5')
  2333. {
  2334. $wl = '<font id="wl'.$ud['id'].'" class="lbwlxx">派送异常<font style="display: none">'.$ud['excontent'].'</font></font>';
  2335. }
  2336. $info_list[$key]['exstate'] = $wl.'<br />';
  2337. if($ud['source'] == 1) //线下单用订单时间,其他用付款时间
  2338. {
  2339. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$ud['dtime']).'</p><p>'.date('H:i:s',$ud['dtime']).'</p>';
  2340. }
  2341. else
  2342. {
  2343. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']+$dt).'</p><p>'.date('H:i:s',$value['dtime']+$dt).'</p>';
  2344. }
  2345. if($value['review'] == 1)
  2346. {
  2347. $info_list[$key]['review'] = "未送审";
  2348. }
  2349. else if($value['review'] == 2)
  2350. {
  2351. $info_list[$key]['review'] = "<font style='color:#555'>待审核</font>";
  2352. }
  2353. else if($value['review'] == 3)
  2354. {
  2355. $info_list[$key]['review'] = "<font style='color:#f90f4b'>不通过</font>";
  2356. }
  2357. else if($value['review'] == 4)
  2358. {
  2359. $info_list[$key]['review'] = "取消重审";
  2360. }
  2361. else if($value['review'] == 5)
  2362. {
  2363. $info_list[$key]['review'] = "<font style='color:#2f80f9'>审核通过</font>";
  2364. }
  2365. else if($value['review'] == 6)
  2366. {
  2367. $info_list[$key]['review'] = "<font style='color:#2f80f9'>自动通过</font>";
  2368. }
  2369. if($ud['dlz'] == 1)
  2370. {
  2371. $dlz = "<p>独立站已更新</p>";
  2372. }
  2373. else if($ud['dlz'] == 3)
  2374. {
  2375. $dlz = "<p>不需要更新</p>";
  2376. }
  2377. else if($ud['dlz'] == 2)
  2378. {
  2379. $dlz = "<p style='color:#C3C'>独立站更新失败</p>";
  2380. }
  2381. else
  2382. {
  2383. $dlz = "";
  2384. }
  2385. if($value['waybill'] != "")
  2386. {
  2387. $info_list[$key]['waybill'] = "<p>".$value['waybill']."</p>".$dlz;
  2388. }
  2389. if($value['express'] != 0)
  2390. {
  2391. $express = $this->express->read($value['express']);
  2392. $expressservicename = $express['servicename'];
  2393. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  2394. $info_list[$key]['express'] = $expressservicename;
  2395. }
  2396. else
  2397. {
  2398. $info_list[$key]['express'] = "无";
  2399. }
  2400. $tly = "";
  2401. if($value['clientremarks'] != "")
  2402. {
  2403. $tly = "<p style='color:#FF3333'>有客户留言</p>";
  2404. }
  2405. if($value['library'] == 1 && $ud['printtype'] == 3)
  2406. {
  2407. $info_list[$key]['library'] = "不需要";
  2408. }
  2409. else if($value['library'] == 1 && $ud['printtype'] != 3)
  2410. {
  2411. $info_list[$key]['library'] = "未出库";
  2412. }
  2413. else if($value['library'] == 2)
  2414. {
  2415. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  2416. }
  2417. else if($value['library'] == 3)
  2418. {
  2419. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  2420. }
  2421. if($ud['authorid'] != '' && $ud['authorid'] != 0)
  2422. {
  2423. $info_list[$key]['orderremarks'] = '<p>'.$value['orderremarks'].'</p><p style="border-top: 1px dashed #C2C2C2;">author_id:</p><p>'.$ud['authorid'].'</p><p>source_content_id:</p><p>'.$ud['sourcecontentid'].'</p>';
  2424. }
  2425. }
  2426. $total = $this->fullordertt->find_count($where);
  2427. $pagenum = ceil($total/$perpage);
  2428. $over = $total-($start+$perpage);
  2429. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  2430. echo json_encode($rows);exit;
  2431. }
  2432. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  2433. $this->data['wlshop'] = $wlshop;
  2434. $this->_Template('fullordertt_readlist',$this->data);
  2435. }
  2436. public function _readlistdown()
  2437. {
  2438. if(isset($_SESSION['api']))
  2439. {
  2440. $user = $this->user->get_api($_SESSION['api']);
  2441. $usp = $user;
  2442. $fgshop = "";$sid = "";
  2443. $usersp = explode('|',trim($user['shop'],'|'));
  2444. foreach ($usersp as $value)
  2445. {
  2446. $fgshop .= " shop = ".$value." or";
  2447. $sid .= " id = ".$value." or";
  2448. }
  2449. }
  2450. $post = $this->input->get(NULL, TRUE);
  2451. if(isset($post['excel']))
  2452. {
  2453. $shop = $this->input->get('shop',true);
  2454. $warehouse = $this->input->get('warehouse',true);
  2455. $express = $this->input->get('express',true);
  2456. $state = $this->input->get('state',true);
  2457. $print = $this->input->get('print',true);
  2458. $libraryconfirm = $this->input->get('libraryconfirm',true);
  2459. $orderinfo = $this->input->get('orderinfo',true);
  2460. $client = $this->input->get('name',true);
  2461. $email = $this->input->get('email',true);
  2462. $number = $this->input->get('number',true);
  2463. $waybill = $this->input->get('waybill',true);
  2464. $authorid = $this->input->get('authorid',true);
  2465. $sourcecontentid = $this->input->get('sourcecontentid',true);
  2466. $timetk = $this->input->get('timetk',true);
  2467. $timetj = $this->input->get('timetj',true);
  2468. $timetk = strtotime($timetk);
  2469. $timetj = strtotime($timetj);
  2470. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  2471. if($shop)
  2472. {
  2473. $where .= " and shop = '$shop'";
  2474. }
  2475. if($warehouse)
  2476. {
  2477. $where .= " and type = '$warehouse'";
  2478. }
  2479. if($express)
  2480. {
  2481. $where .= " and express = '$express'";
  2482. }
  2483. if($state)
  2484. {
  2485. $where .= " and state = '$state'";
  2486. }
  2487. if($print)
  2488. {
  2489. $where .= " and print = '$print'";
  2490. }
  2491. if($libraryconfirm)
  2492. {
  2493. $where .= " and libraryconfirm = '$libraryconfirm'";
  2494. }
  2495. if($orderinfo)
  2496. {
  2497. $where .= " and orderinfo = '$orderinfo'";
  2498. }
  2499. if($client)
  2500. {
  2501. $where .= " and client like '%$client%'";
  2502. }
  2503. if($email)
  2504. {
  2505. $where .= " and email = '$email'";
  2506. }
  2507. if($number)
  2508. {
  2509. $where .= " and number = '$number'";
  2510. }
  2511. if($waybill)
  2512. {
  2513. $where .= " and waybill = '$waybill'";
  2514. }
  2515. if($authorid)
  2516. {
  2517. $where .= " and authorid = '$authorid'";
  2518. }
  2519. if($sourcecontentid)
  2520. {
  2521. $where .= " and sourcecontentid = '$sourcecontentid'";
  2522. }
  2523. if($timetk && $timetj)
  2524. {
  2525. $timetj = $timetj+24*3600;
  2526. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  2527. }
  2528. //数据排序
  2529. $order_str = "dtime desc";
  2530. //取得信息列表
  2531. $info_list = $this->fullordertt->find_all($where,'shop,number,orderinfo,dtime,name,express,waybill,email,shipremarks,shouldmoney,orderremarks,librarytime,authorid,sourcecontentid',$order_str);
  2532. //格式化数据
  2533. $dt = 0;
  2534. foreach ($info_list as $key=>$value)
  2535. {
  2536. $shop = $this->shop->read($value['shop']);
  2537. $info_list[$key]['shop'] = $shop['shopname'];
  2538. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  2539. if($value['librarytime'] > 0)
  2540. {
  2541. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2542. }
  2543. if($value['express'] != 0)
  2544. {
  2545. $express = $this->express->read($value['express']);
  2546. $info_list[$key]['express'] = $express['servicename'];
  2547. }
  2548. else
  2549. {
  2550. $info_list[$key]['express'] = "无";
  2551. }
  2552. }
  2553. $title = "订单列表 ".date("Y-m-d");
  2554. $titlename = "<table border=1>
  2555. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  2556. <tr>
  2557. <td>店铺</td>
  2558. <td>编号</td>
  2559. <td>订单号</td>
  2560. <td>订单日期</td>
  2561. <td>客户姓名</td>
  2562. <td>快递方式</td>
  2563. <td>运单号</td>
  2564. <td>邮箱</td>
  2565. <td>仓库品名</td>
  2566. <td>订单金额</td>
  2567. <td>订单备注</td>
  2568. <td>出库时间</td>
  2569. <td>author_id</td>
  2570. <td>source_content_id</td>
  2571. </tr>
  2572. </table>";
  2573. $filename = $title.".xls";
  2574. $tail = "\n";
  2575. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  2576. }
  2577. }
  2578. //删除
  2579. public function _del()
  2580. {
  2581. $post = $this->input->post(NULL, TRUE);
  2582. if(isset($post['s']))
  2583. {
  2584. $id_arr = $this->input->post('s');
  2585. $id_arr = explode(',',$id_arr);
  2586. if(!$id_arr)
  2587. {
  2588. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2589. }
  2590. //循环删除记录
  2591. foreach ($id_arr as $v)
  2592. {
  2593. $this->fullordertt->remove($v);
  2594. }
  2595. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  2596. }
  2597. }
  2598. //查找商品价格
  2599. public function _price()
  2600. {
  2601. $post = $this->input->post(NULL, TRUE);
  2602. if(isset($post['data']))
  2603. {
  2604. $data = $this->input->post('data');
  2605. $data = explode('-',$data);
  2606. $number = '';$num = count($data);
  2607. //循环删除记录
  2608. for($i=0;$i<$num-1;$i++)
  2609. {
  2610. if($data[$i] != 0)
  2611. {
  2612. $number=$number.$data[$i];
  2613. if($i == 2)
  2614. {
  2615. $number=$number.$data[$num-1];
  2616. }
  2617. }
  2618. }
  2619. $list = $this->productdescribe->get_number($number);
  2620. if($list)
  2621. {
  2622. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));
  2623. }
  2624. else
  2625. {
  2626. $list = array('purchase'=>0,'cost'=>0,'salesprice'=>0);
  2627. //echo json_encode(array('msg'=>'此信息没有配置价格!','n'=>$data[$num-1],'success'=>false));exit;
  2628. echo json_encode(array('msg'=>($list),'n'=>$data[$num-1],'number'=>$number,'success'=>true));exit;
  2629. }
  2630. }
  2631. }
  2632. public function _customs()
  2633. {
  2634. $post = $this->input->post(NULL, TRUE);
  2635. if(isset($post['e']))
  2636. {
  2637. $e = $this->input->post('e');//快递信息
  2638. $c = $this->input->post('c');//国家信息
  2639. $data = $this->customs->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2640. $list = $this->productdescription->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2641. $rows = array();
  2642. foreach ($data as $key=>$value)
  2643. {
  2644. $detailed = explode('|',trim($value['detailed'],'|'));
  2645. //此处未对比重量选择价值,暂直接选择第一条海关价值
  2646. $detailed = $this->detailed->read($detailed[0]);
  2647. $money = $detailed['customsval'];//找到海关价值
  2648. }
  2649. foreach ($list as $key=>$value)
  2650. {
  2651. $description = $this->typeclass->read($value['description']);
  2652. $list[$key]['title'] = $description['title'];//产品描述名称
  2653. }
  2654. if(!$data && !$list)
  2655. {
  2656. echo json_encode(array('msg'=>'无此快递配置信息!','success'=>false));exit;
  2657. }
  2658. else
  2659. {
  2660. //$list-title -description 取值
  2661. echo json_encode(array('money'=>sprintf("%.2f",$money),'msg'=>$list,'success'=>true));
  2662. }
  2663. }
  2664. }
  2665. public function _express()
  2666. {
  2667. $post = $this->input->post(NULL, TRUE);
  2668. if(isset($post['e']))
  2669. {
  2670. $e = $this->input->post('e');//快递信息
  2671. $c = $this->input->post('c');//国家信息
  2672. $data = $this->logistics->find_all('express = "'.$e.'" and country = "'.$c.'"');
  2673. if(!$data)
  2674. {
  2675. echo json_encode(array('success'=>false));exit;
  2676. }
  2677. else
  2678. {
  2679. echo json_encode(array('money'=>sprintf("%.2f",$data[0]['firstmoney']),'success'=>true));
  2680. }
  2681. }
  2682. }
  2683. public function _hl()
  2684. {
  2685. $post = $this->input->post(NULL, TRUE);
  2686. if(isset($post['cy']))
  2687. {
  2688. $hl = 0;
  2689. $cy = $this->input->post('cy');//币种ID
  2690. $cy = $this->typeclass->read($cy);
  2691. $gethl = $this->hl->get_hl();
  2692. foreach ($gethl as $v)
  2693. {
  2694. $code = str_replace(" ","",$v['code']);
  2695. if($code == $cy['title'])
  2696. {
  2697. $hl = $v['refePrice']/100;
  2698. }
  2699. }
  2700. echo json_encode(array('msg'=>$hl,'success'=>true));
  2701. }
  2702. }
  2703. public function _operation()
  2704. {
  2705. $post = $this->input->post(NULL, TRUE);
  2706. if(isset($post['type']))
  2707. {
  2708. $type = $this->input->post('type');
  2709. $id = $this->input->post('id');
  2710. $msg = $this->input->post('msg');
  2711. if($type == 1)//禁止发货
  2712. {
  2713. $d = $this->fullordertt->read($id);
  2714. if($d['library'] != 1)
  2715. {
  2716. echo json_encode(array('msg'=>'操作失败,订单非未出库状态!','success'=>false));exit;
  2717. }
  2718. if($msg == "")
  2719. {
  2720. echo json_encode(array('msg'=>'必须填写禁止原因!','success'=>false));exit;
  2721. }
  2722. if($d['print'] < 3)
  2723. {
  2724. $a = "订单未打印,";
  2725. }
  2726. else
  2727. {
  2728. $a = "";
  2729. }
  2730. if($this->fullordertt->save(array('libraryconfirm'=>1,'librarynot'=>$a.$msg),$id))
  2731. {
  2732. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2733. }
  2734. else
  2735. {
  2736. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2737. }
  2738. }
  2739. if($type == 6)//允许发货
  2740. {
  2741. $d = $this->fullordertt->read($id);
  2742. if($d['library'] > 1)
  2743. {
  2744. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2745. }
  2746. if($d['print'] < 3)
  2747. {
  2748. $a = "订单未打印,";
  2749. }
  2750. else
  2751. {
  2752. $a = "";
  2753. }
  2754. if($this->fullordertt->save(array('libraryconfirm'=>2,'librarynot'=>$a.$msg),$id))
  2755. {
  2756. echo json_encode(array('msg'=>'操作成功','l'=>1,'d'=>$id,'success'=>true));exit;
  2757. }
  2758. else
  2759. {
  2760. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2761. }
  2762. }
  2763. if($type == 7)//禁止打印
  2764. {
  2765. $d = $this->fullordertt->read($id);
  2766. if($d['printtime'] != 0)
  2767. {
  2768. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2769. }
  2770. if($d['library'] > 1)
  2771. {
  2772. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2773. }
  2774. if($d['print'] < 3)
  2775. {
  2776. $a = "订单未打印,";
  2777. }
  2778. else
  2779. {
  2780. $a = "";
  2781. }
  2782. if($this->fullordertt->save(array('print'=>1),$id))
  2783. {
  2784. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2785. }
  2786. else
  2787. {
  2788. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2789. }
  2790. }
  2791. if($type == 8)//允许打印
  2792. {
  2793. $d = $this->fullordertt->read($id);
  2794. /**
  2795. if($d['printtime'] != 0)
  2796. {
  2797. echo json_encode(array('msg'=>'订单已打印,操作失败','success'=>false));exit;
  2798. }
  2799. **/
  2800. if($d['library'] > 1)
  2801. {
  2802. echo json_encode(array('msg'=>'订单已出库,操作失败','success'=>false));exit;
  2803. }
  2804. if($d['print'] < 3)
  2805. {
  2806. $a = "订单未打印,";
  2807. }
  2808. else
  2809. {
  2810. $a = "";
  2811. }
  2812. if($d['printtime'] == '0')
  2813. {
  2814. $bcprint = 2;
  2815. }
  2816. else
  2817. {
  2818. $bcprint = 3;
  2819. }
  2820. if($this->fullordertt->save(array('print'=>$bcprint,'failed'=>''),$id))
  2821. {
  2822. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2823. }
  2824. else
  2825. {
  2826. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2827. }
  2828. }
  2829. if($type == 9)//关闭
  2830. {
  2831. if($this->fullordertt->save(array('failed'=>''),$id))
  2832. {
  2833. echo json_encode(array('msg'=>'操作成功','l'=>2,'d'=>$id,'success'=>true));exit;
  2834. }
  2835. else
  2836. {
  2837. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2838. }
  2839. }
  2840. if($type == 2)//填写运单、修改运单
  2841. {
  2842. $d = $this->fullordertt->read($id);
  2843. if($d['express'] == 0)
  2844. {
  2845. echo json_encode(array('msg'=>'操作失败,未选择物流方式!','success'=>false));exit;
  2846. }
  2847. if($d['library'] == 3 || ($d['print'] == 3 && $d['libraryconfirm'] == 1))
  2848. {
  2849. echo json_encode(array('msg'=>'操作失败,不允许填写运单号!','success'=>false));exit;
  2850. }
  2851. $xg = $this->fullordertt->read($id);
  2852. $shop = $this->shop->read($xg['shop']);
  2853. $ex = $this->express->read($xg['express']);
  2854. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2855. if($xg['source'] != 1)
  2856. {
  2857. //独立站地址更新订单状态、物流信息
  2858. $gx = $this->api->get_gx(substr($xg['orderinfo'],1),$msg,$xg,$shop,$ex,$xg['msg'],$xg['shopify']);
  2859. }
  2860. else if($xg['source'] == 1)
  2861. {
  2862. $gx['res'] = 3;
  2863. $gx['state'] = 216;
  2864. }
  2865. if(!isset($gx['res']))
  2866. {
  2867. $gx['res'] = 2;
  2868. $gx['state'] = $xg['state'];
  2869. }
  2870. if($gx['res'] > 0 && $fs)
  2871. {
  2872. $warehouse = $this->warehouse->read($xg['type']);
  2873. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2874. }
  2875. $msg = preg_replace('/( | | | |\s)/','',$msg);
  2876. if($this->fullordertt->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$id))
  2877. {
  2878. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  2879. }
  2880. else
  2881. {
  2882. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  2883. }
  2884. }
  2885. }
  2886. }
  2887. public function _merge()
  2888. {
  2889. $post = $this->input->post(NULL, TRUE);
  2890. if(isset($post['s']))
  2891. {
  2892. $id_arr = $this->input->post('s');
  2893. $id_arr = explode(',',trim( $id_arr,','));
  2894. $id_arr = array_reverse($id_arr);
  2895. if(!$id_arr)
  2896. {
  2897. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  2898. }
  2899. if(count($id_arr) < 2)
  2900. {
  2901. echo json_encode(array('msg'=>'缺少可合并单!','success'=>false));exit;
  2902. }
  2903. $post = array();
  2904. $u = $this->fullordertt->read($id_arr[0]);
  2905. unset($id_arr[0]);
  2906. $this->db->trans_begin();
  2907. $hd = $this->fullordertthb->get_orderinfo($u['orderinfo']);
  2908. if(!$hd)
  2909. {
  2910. $this->fullordertthb->insert($u);
  2911. }
  2912. //相加
  2913. $post['shouldmoney'] = $u['shouldmoney'];//购买应收金额
  2914. $post['budget'] = $u['budget'];//预估到帐金额
  2915. $post['expressmoney']= $u['expressmoney'];//物流金额
  2916. //$post['refundy'] = $u['refundy'];//补/退原额
  2917. //$post['refundj'] = $u['refundj'];//补/退净额
  2918. $post['cost'] = $u['cost'];//成本金额
  2919. //$post['zzl'] = $u['zzl'];//总重量
  2920. //$post['zsbjz'] = $u['zsbjz'];//总申报价值
  2921. $post['ts'] = $u['ts'];//条数
  2922. $post['cost'] = $u['cost'];//成本金额
  2923. //追加
  2924. $post['rpaypal'] = $u['rpaypal'];//补/退交易号
  2925. $post['rtext'] = $u['rtext'];//补/退原因
  2926. $post['pay'] = $u['pay'];//付款方式
  2927. $post['paypal'] = $u['paypal'];//交易号
  2928. $post['clientremarks'] = $u['clientremarks'];//客户留言
  2929. $post['product'] = $u['product'];//商品名称
  2930. //$post['issku'] = $u['issku'];//sku
  2931. //$post['orderremarks'] = $u['orderremarks'];//订单备注
  2932. $post['shipremarks'] = $u['shipremarks'];//仓库品名
  2933. //产品追加
  2934. $post['fpdata'] = $u['fpdata'];//产品内容
  2935. $post['whlabel'] = $u['whlabel'];//产品对应库存码
  2936. $merge = $u['id'];
  2937. $d = array($u['id']);$order = '';
  2938. $zsl = 0;$zccsl = 0;
  2939. foreach ($id_arr as $v)
  2940. {
  2941. $v = $this->fullordertt->read($v);
  2942. if($u['type'] != $v['type'])
  2943. {
  2944. echo json_encode(array('msg'=>'仓库不一致,无法合并!','success'=>false));exit;
  2945. }
  2946. if($v['shop'] = $u['shop'])
  2947. {
  2948. $hd = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  2949. if(!$hd)
  2950. {
  2951. $this->fullordertthb->insert($v);
  2952. }
  2953. $post['shouldmoney'] += $v['shouldmoney'];//购买应收金额
  2954. $post['budget'] += $v['budget'];//预估到帐金额
  2955. $post['expressmoney'] += $v['expressmoney'];//物流金额
  2956. //$post['refundy'] += $v['refundy'];//补/退原额
  2957. //$post['refundj'] += $v['refundj'];//补/退净额
  2958. $post['cost'] += $v['cost'];//成本金额
  2959. //$post['zzl'] += $v['zzl'];//总重量
  2960. //$post['zsbjz'] += $v['zsbjz'];//总申报价值
  2961. $post['ts'] += $v['ts'];//条数
  2962. //$post['rpaypal'] .= $v['rpaypal'];//补/退交易号
  2963. //$post['rtext'] .= $v['rtext'];//补/退原因
  2964. //$post['pay'] .= (stripos($post['pay'],$v['pay']) !== false)?'':';'.$v['pay'];//付款方式
  2965. //$post['paypal'] .= $v['paypal'];//交易号
  2966. $post['clientremarks'] .= $v['clientremarks'];//客户留言
  2967. $post['product'] .= $v['product'];//商品名称
  2968. //$post['issku'] .= $v['issku'];//sku
  2969. //$post['orderremarks'] .= $v['orderremarks'];//订单备注
  2970. $post['shipremarks'] .= $v['shipremarks'];//仓库品名
  2971. $post['fpdata'] .= $v['fpdata'];//产品内容
  2972. $post['whlabel'] .= $v['whlabel'];//产品对应库存码
  2973. $d[] = $v['id'];
  2974. $order .= $v['orderinfo'].'('.$v['number'].')、';
  2975. $wl = $this->whlabel->find_all("zd = '".$v['number']."'");//查找是否有占用库存情况
  2976. $i = 0;
  2977. if($wl)//如果有那么清除所有占用
  2978. {
  2979. foreach ($wl as $val)
  2980. {
  2981. if($val['sku'] == 'Preset' && $val['state'] == '9')
  2982. {
  2983. $this->whlabel->remove($val['id']);//删除预设
  2984. $i++;
  2985. }
  2986. else
  2987. {
  2988. $this->whlabel->save(array('zd'=>''),$val['id']);//专属
  2989. $i++;
  2990. }
  2991. }
  2992. }
  2993. $zsl += count($wl);
  2994. $zccsl += $i;
  2995. $this->fullordertt->save(array('merge'=>$u['id'],'mergeid'=>1,'orderremarks'=>' 《合并信息》:'.'已合并到'.$u['orderinfo'].'('.$u['number'].')中; '.$v['orderremarks'],'shouldmoney'=>0,'print'=>1,'libraryconfirm'=>1,'shouldmoney'=>0,'budget'=>0,'whlabel'=>'','fpdata'=>'','shipremarks'=>''),$v['id']);
  2996. }
  2997. }
  2998. //计算出单条价值
  2999. /**
  3000. if($post['zsbjz'] < 1 || $post['ts'] < 1)
  3001. {
  3002. //$post['dtsbjz'] = 0;
  3003. }
  3004. else
  3005. {
  3006. //$post['dtsbjz'] = $post['zsbjz']/$post['ts'];//单条申报价
  3007. }
  3008. **/
  3009. $post['orderremarks'] = ' 《合并信息》:由'.rtrim($order,'、').'合并而来; '.$u['orderremarks'];
  3010. $post['merge'] = $u['id'];
  3011. //$post['mergeid'] = 1;
  3012. //合并重复项
  3013. //解决whlabel 合并在一起是 多出的那个|
  3014. $post['whlabel'] = str_replace("||","|",$post['whlabel']);
  3015. $hbcfw = explode('|',trim($post['whlabel'],'|'));
  3016. $hbcff = explode(';',trim($post['fpdata'],';'));
  3017. $c = 0;
  3018. $hbw = array();
  3019. $hbf = array();
  3020. for($i=0;$i<count($hbcfw);$i++)
  3021. {
  3022. $w = explode('-',$hbcfw[$i]);
  3023. $f = explode('|',$hbcff[$i]);
  3024. $w2 = ($w[2]==0)?0:'';
  3025. if(!isset($hbw[$w[0].$w2]))
  3026. {
  3027. $hbw[$w[0].$w2] = $hbcfw[$i];
  3028. $hbf[$w[0].$w2] = $hbcff[$i];
  3029. }
  3030. else
  3031. {
  3032. $c++;
  3033. $cw = explode('-',$hbw[$w[0].$w2]);
  3034. $cf = explode('|',$hbf[$w[0].$w2]);
  3035. if($cw[2] != 0 && $w[2] != 0)
  3036. {
  3037. $cf[2] += $f[2];
  3038. $cf[9] .= '~'.$f[9];
  3039. $hbf[$w[0].$w2] = implode("|",$cf);
  3040. $cw[1] += $f[2];
  3041. $cw[2] .= '~'.$f[9];
  3042. $hbw[$w[0].$w2] = implode("-",$cw);
  3043. }
  3044. else if($cw[2] == 0 && $w[2] == 0)
  3045. {
  3046. $cf[2] += $f[2];
  3047. $hbf[$w[0].$w2] = implode("|",$cf);
  3048. $cw[1] += $f[2];
  3049. $hbw[$w[0].$w2] = implode("-",$cw);
  3050. }
  3051. else
  3052. {
  3053. $hbw[] = $hbcfw[$i];
  3054. $hbf[] = $hbcff[$i];
  3055. }
  3056. }
  3057. }
  3058. if($c > 0)
  3059. {
  3060. $post['fpdata'] = implode(";",$hbf).';';
  3061. $post['whlabel'] = '|'.implode("|",$hbw).'|';
  3062. }
  3063. //合并重复项结束
  3064. $this->fullordertt->save($post,$u['id']);
  3065. if ($this->db->trans_status() === FALSE)
  3066. {
  3067. $this->db->trans_commit();
  3068. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  3069. }
  3070. else
  3071. {
  3072. $this->db->trans_commit();
  3073. echo json_encode(array('msg'=>'操作成功','d'=>($d),'b'=>$u['id'],'success'=>true));
  3074. }
  3075. }
  3076. }
  3077. //评价管理
  3078. public function _evaluate()
  3079. {
  3080. $user = $this->user->get_api($_SESSION['api']);
  3081. if($user)
  3082. {
  3083. $fgshop = "";$sid = "";
  3084. $user = explode('|',trim($user['shop'],'|'));
  3085. foreach ($user as $value)
  3086. {
  3087. $fgshop .= " shop = ".$value." or";
  3088. $sid .= " id = ".$value." or";
  3089. }
  3090. }
  3091. $post = $this->input->post(NULL, TRUE);
  3092. if(isset($post['page']))
  3093. {
  3094. $page = $this->input->post('page',true);
  3095. $perpage = $this->input->post('perpage',true);
  3096. $shop = $this->input->post('shop',true);
  3097. $where = "1=1 and evaluate = 0 and (".rtrim($fgshop,'or').")";
  3098. if($shop)
  3099. {
  3100. $where .= " and shop = '$shop'";
  3101. }
  3102. //数据排序
  3103. $order_str = "id desc";
  3104. if(empty($page))
  3105. {
  3106. $start = 0;
  3107. $perpage = 1;
  3108. }
  3109. else
  3110. {
  3111. $start = ($page - 1)*$perpage;
  3112. }
  3113. //取得信息列表
  3114. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,operation',$order_str,$start,$perpage);
  3115. //格式化数据
  3116. foreach ($info_list as $key=>$value)
  3117. {
  3118. $shop = $this->shop->read($value['shop']);
  3119. $info_list[$key]['shop'] = $shop['shopname'];
  3120. $info_list[$key]['operation'] = "评价";
  3121. }
  3122. $total = $this->fullordertt->find_count($where);
  3123. $pagenum = ceil($total/$perpage);
  3124. $over = $total-($start+$perpage);
  3125. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3126. echo json_encode($rows);exit;
  3127. }
  3128. $this->_Template('fullordertt_evaluate',$this->data);
  3129. }
  3130. //订单消息
  3131. public function _state()
  3132. {
  3133. $user = $this->user->get_api($_SESSION['api']);
  3134. if($user)
  3135. {
  3136. $fgshop = "";$sid = "";
  3137. $user = explode('|',trim($user['shop'],'|'));
  3138. foreach ($user as $value)
  3139. {
  3140. $fgshop .= " shop = ".$value." or";
  3141. $sid .= " id = ".$value." or";
  3142. }
  3143. }
  3144. $post = $this->input->post(NULL, TRUE);
  3145. if(isset($post['page']))
  3146. {
  3147. $page = $this->input->post('page',true);
  3148. $perpage = $this->input->post('perpage',true);
  3149. $timetk = $this->input->post('timetk',true);
  3150. $timetj = $this->input->post('timetj',true);
  3151. $shop = $this->input->post('shop',true);
  3152. $expressstate = $this->input->post('expressstate',true);
  3153. $fs = $this->input->post('fs',true);
  3154. $state = $this->input->post('state',true);
  3155. $express = $this->input->post('express',true);
  3156. $review = $this->input->post('review',true);
  3157. $orderinfo = $this->input->post('orderinfo',true);
  3158. $number = $this->input->post('number',true);
  3159. $waybill = $this->input->post('waybill',true);
  3160. $xztime = $this->input->post('xztime',true);
  3161. $timetk = strtotime($timetk);
  3162. $timetj = strtotime($timetj);
  3163. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3164. if($timetk && $timetj)
  3165. {
  3166. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3167. }
  3168. if($xztime == 'librarytime')
  3169. {
  3170. $order_str = "librarytime desc";
  3171. }
  3172. else if($xztime == 'dtime')
  3173. {
  3174. $order_str = "dtime desc";
  3175. }
  3176. if($shop)
  3177. {
  3178. $where .= " and shop = '$shop'";
  3179. }
  3180. if($expressstate)
  3181. {
  3182. $where .= " and expressstate = '$expressstate'";
  3183. }
  3184. if($review)
  3185. {
  3186. $where .= " and review = '$review'";
  3187. }
  3188. if($fs)
  3189. {
  3190. if($fs == '2')
  3191. {
  3192. $where .= " and exstateerror != ''";
  3193. }
  3194. else
  3195. {
  3196. $where .= " and exstateerror = ''";
  3197. }
  3198. }
  3199. if($state)
  3200. {
  3201. $where .= " and state = '$state'";
  3202. }
  3203. if($express)
  3204. {
  3205. $where .= " and express = '$express'";
  3206. }
  3207. if($orderinfo)
  3208. {
  3209. $where .= " and orderinfo = '$orderinfo'";
  3210. }
  3211. if($number)
  3212. {
  3213. $where .= " and number = '$number'";
  3214. }
  3215. if($waybill)
  3216. {
  3217. $where .= " and waybill = '$waybill'";
  3218. }
  3219. if(empty($page))
  3220. {
  3221. $start = 0;
  3222. $perpage = 1;
  3223. }
  3224. else
  3225. {
  3226. $start = ($page - 1)*$perpage;
  3227. }
  3228. //取得信息列表
  3229. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,content,orderremarks,exstateerror',$order_str,$start,$perpage);
  3230. //格式化数据
  3231. foreach ($info_list as $key=>$value)
  3232. {
  3233. $shop = $this->shop->read($value['shop']);
  3234. $info_list[$key]['shop'] = $shop['shopname'];
  3235. $country = $this->country->read($value['country']);
  3236. $info_list[$key]['country'] = $country['name'];
  3237. //$state = $this->typeclass->read($value['state']);
  3238. //$info_list[$key]['state'] = $state['title'];
  3239. if($value['library'] == 1)
  3240. {
  3241. $info_list[$key]['library'] = "未出库";
  3242. }
  3243. else if($value['library'] == 2)
  3244. {
  3245. $info_list[$key]['library'] = "已出库";
  3246. }
  3247. else if($value['library'] == 3)
  3248. {
  3249. $info_list[$key]['library'] = "已退库";
  3250. }
  3251. if($value['librarytime'] == '0')
  3252. {
  3253. $info_list[$key]['librarytime'] = '无';
  3254. }
  3255. else
  3256. {
  3257. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  3258. }
  3259. $express = $this->express->read($value['express']);
  3260. $info_list[$key]['express'] = $express['servicename'];
  3261. }
  3262. $total = $this->fullordertt->find_count($where);
  3263. $pagenum = ceil($total/$perpage);
  3264. $over = $total-($start+$perpage);
  3265. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3266. echo json_encode($rows);exit;
  3267. }
  3268. $notice = $this->notice->find_all("type = '1' and (".rtrim($fgshop,'or').")");
  3269. $this->data['notice'] = $notice;
  3270. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3271. $this->data['wlshop'] = $wlshop;
  3272. $this->data['express'] = $this->express->find_all();
  3273. $this->_Template('fullordertt_state',$this->data);
  3274. }
  3275. //物流信息
  3276. public function _wl()
  3277. {
  3278. $user = $this->user->get_api($_SESSION['api']);
  3279. if($user)
  3280. {
  3281. $fgshop = "";$sid = "";
  3282. $user = explode('|',trim($user['shop'],'|'));
  3283. foreach ($user as $value)
  3284. {
  3285. $fgshop .= " shop = ".$value." or";
  3286. $sid .= " id = ".$value." or";
  3287. }
  3288. }
  3289. $post = $this->input->post(NULL, TRUE);
  3290. if(isset($post['page']))
  3291. {
  3292. $page = $this->input->post('page',true);
  3293. $perpage = $this->input->post('perpage',true);
  3294. $timetk = $this->input->post('timetk',true);
  3295. $timetj = $this->input->post('timetj',true);
  3296. $shop = $this->input->post('shop',true);
  3297. $expressstate = $this->input->post('expressstate',true);
  3298. $fs = $this->input->post('fs',true);
  3299. $state = $this->input->post('state',true);
  3300. $express = $this->input->post('express',true);
  3301. $orderinfo = $this->input->post('orderinfo',true);
  3302. $number = $this->input->post('number',true);
  3303. $waybill = $this->input->post('waybill',true);
  3304. $wlyc = $this->input->post('wlyc',true);
  3305. $wltype = $this->input->post('wltype',true);
  3306. $source = $this->input->post('source',true);
  3307. $xztime = $this->input->post('xztime',true);
  3308. $timetk = strtotime($timetk);
  3309. $timetj = strtotime($timetj);
  3310. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3311. if($timetk && $timetj)
  3312. {
  3313. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  3314. }
  3315. if($xztime == 'librarytime')
  3316. {
  3317. $order_str = "librarytime desc";
  3318. }
  3319. else if($xztime == 'dtime')
  3320. {
  3321. $order_str = "dtime desc";
  3322. }
  3323. else if ($xztime == 'wlfstime')
  3324. {
  3325. $order_str = "wlfstime desc";
  3326. }
  3327. if($shop)
  3328. {
  3329. $where .= " and shop = '$shop'";
  3330. }
  3331. if($expressstate != '')
  3332. {
  3333. $where .= " and expressstate = '$expressstate'";
  3334. }
  3335. if($fs)
  3336. {
  3337. if($fs == '1')
  3338. {
  3339. $where .= " and wlcontent != ''";
  3340. }
  3341. if($fs == '2')
  3342. {
  3343. $where .= " and wlerror != ''";
  3344. }
  3345. if($fs == '3')
  3346. {
  3347. $where .= " and wlcontent = '' and shouldmoney > 100";
  3348. }
  3349. else if($fs == '4')
  3350. {
  3351. $where .= " and wltype = '1'";
  3352. }
  3353. }
  3354. if($state)
  3355. {
  3356. $where .= " and state = '$state'";
  3357. }
  3358. if($express)
  3359. {
  3360. $where .= " and express = '$express'";
  3361. }
  3362. if($orderinfo)
  3363. {
  3364. $where .= " and orderinfo = '$orderinfo'";
  3365. }
  3366. if($number)
  3367. {
  3368. $where .= " and number = '$number'";
  3369. }
  3370. if($waybill)
  3371. {
  3372. $where .= " and waybill = '$waybill'";
  3373. }
  3374. if($wlyc!='')
  3375. {
  3376. $where .= " and wlyc = '$wlyc'";
  3377. }
  3378. if($wltype!='')
  3379. {
  3380. $where .= " and wltype = '$wltype'";
  3381. }
  3382. if($source)
  3383. {
  3384. if($source == 1)
  3385. {
  3386. $where .= " and source = '$source'";
  3387. }
  3388. else
  3389. {
  3390. $where .= " and source != '1'";
  3391. }
  3392. }
  3393. if(empty($page))
  3394. {
  3395. $start = 0;
  3396. $perpage = 1;
  3397. }
  3398. else
  3399. {
  3400. $start = ($page - 1)*$perpage;
  3401. }
  3402. //取得信息列表
  3403. $info_list = $this->fullordertt->find_all($where,'id,orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,wlcontent,wlerror,excontent,wltype',$order_str,$start,$perpage);
  3404. //格式化数据
  3405. foreach ($info_list as $key=>$value)
  3406. {
  3407. $f = $this->fullordertt->read($value['id']);
  3408. $info_list[$key]['number'] = "<p>".$value['number']."</p>"."<p>".$f['email']."</p>";
  3409. $country = $this->country->read($value['country']);
  3410. $info_list[$key]['country'] = "<p>".$country['name']."</p><p>".$f['phone']."</p>";
  3411. //$state = $this->typeclass->read($value['state']);
  3412. //$info_list[$key]['state'] = $state['title'];
  3413. if($value['library'] == 1)
  3414. {
  3415. $info_list[$key]['library'] = "未出库";
  3416. }
  3417. else if($value['library'] == 2)
  3418. {
  3419. $info_list[$key]['library'] = "已出库";
  3420. }
  3421. else if($value['library'] == 3)
  3422. {
  3423. $info_list[$key]['library'] = "已退库";
  3424. }
  3425. if($value['librarytime'] == '0')
  3426. {
  3427. $info_list[$key]['librarytime'] = '无';
  3428. }
  3429. else
  3430. {
  3431. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']).'<br>'.$f['shouldmoney'];
  3432. }
  3433. if($value['expressstate'] == 0)
  3434. {
  3435. $info_list[$key]['expressstate'] = "无信息";
  3436. }
  3437. else if($value['expressstate'] == 2)
  3438. {
  3439. $info_list[$key]['expressstate'] = "已取件";
  3440. }
  3441. else if($value['expressstate'] == 3)
  3442. {
  3443. $info_list[$key]['expressstate'] = "在途中";
  3444. }
  3445. else if($value['expressstate'] == 4)
  3446. {
  3447. $info_list[$key]['expressstate'] = "到达目的地国".$value['expressstate'];
  3448. }
  3449. else if($value['expressstate'] == 5)
  3450. {
  3451. $info_list[$key]['expressstate'] = "即将派送";
  3452. }
  3453. else if($value['expressstate'] == 6)
  3454. {
  3455. $info_list[$key]['expressstate'] = "已签收";
  3456. }
  3457. else if($value['expressstate'] == 1)
  3458. {
  3459. $info_list[$key]['expressstate'] = "派送异常";
  3460. }
  3461. $express = $this->express->read($value['express']);
  3462. $info_list[$key]['express'] = $express['servicename'];
  3463. if($value['wltype'] == '0')
  3464. {
  3465. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>禁止发送</b></p>";
  3466. }
  3467. else
  3468. {
  3469. $info_list[$key]['wltype'] = "<p class='ckn'><b class='wlfsxx' data-id='".$value['id']."' data-q='1'>允许发送</b></p>";
  3470. }
  3471. if($f['wlyc'] == '0')
  3472. {
  3473. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='1'>加入异常</b></p>";
  3474. }
  3475. else if($f['wlyc'] == '1')
  3476. {
  3477. $info_list[$key]['wltype'] .= "<p class='yc'><b class='wlyc' data-id='".$value['id']."' data-t='2'>物流异常</b></p>";
  3478. }
  3479. else if($f['wlyc'] == '2')
  3480. {
  3481. $info_list[$key]['wltype'] .= "<p><b>异常已处理</b></p>";
  3482. }
  3483. if(stripos($value['excontent'],'<br />') !== false)
  3484. {
  3485. $excontent = explode('<br />',$value['excontent']);
  3486. $info_list[$key]['excontent'] = '<i class="method fa fa-list-ul" data-t="'.$value['excontent'].'"></i> '.$excontent[0];
  3487. }
  3488. }
  3489. $total = $this->fullordertt->find_count($where);
  3490. $pagenum = ceil($total/$perpage);
  3491. $over = $total-($start+$perpage);
  3492. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3493. echo json_encode($rows);exit;
  3494. }
  3495. if(isset($post['q']))
  3496. {
  3497. $id = $this->input->post('id',true);
  3498. $f = $this->fullordertt->read($id);
  3499. $wl = ($f['wltype']=='0')?1:0;
  3500. $wltitle = ($f['wltype']=='0')?'已禁发送':'已允发送';
  3501. if($this->fullordertt->save(array('wltype'=>$wl),$id))
  3502. {
  3503. echo json_encode(array('msg'=>'ckn','id'=>$id,'wltitle'=>$wltitle,'success'=>true));exit;
  3504. }
  3505. else
  3506. {
  3507. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$wltitle,'success'=>false));exit;
  3508. }
  3509. }
  3510. if(isset($post['t']))
  3511. {
  3512. $id = $this->input->post('id',true);
  3513. $f = $this->fullordertt->read($id);
  3514. $t = $this->input->post('t',true);
  3515. $yc = ($f['wlyc']=='0')?1:2;
  3516. $yctitle = ($f['wlyc']=='0')?'物流异常':'异常已处理';
  3517. if($this->fullordertt->save(array('wlyc'=>$yc),$id))
  3518. {
  3519. echo json_encode(array('msg'=>'yc','id'=>$id,'wltitle'=>$yctitle,'success'=>true));exit;
  3520. }
  3521. else
  3522. {
  3523. echo json_encode(array('msg'=>'失败,请重试','id'=>$id,'wltitle'=>$yctitle,'success'=>false));exit;
  3524. }
  3525. }
  3526. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  3527. $this->data['notice'] = $notice;
  3528. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3529. $this->data['wlshop'] = $wlshop;
  3530. $this->data['express'] = $this->express->find_all();
  3531. $this->_Template('fullordertt_wl',$this->data);
  3532. }
  3533. //审核订单
  3534. public function _review()
  3535. {
  3536. $user = $this->user->get_api($_SESSION['api']);
  3537. if($user)
  3538. {
  3539. $fgshop = "";$sid = "";
  3540. $user = explode('|',trim($user['shop'],'|'));
  3541. foreach ($user as $value)
  3542. {
  3543. $sid .= " id = ".$value." or";
  3544. $fgshop .= " shop = ".$value." or";
  3545. }
  3546. $fgshop = " and (".rtrim($fgshop,'or').")";
  3547. }
  3548. $post = $this->input->post(NULL, TRUE);
  3549. if(isset($post['page']))
  3550. {
  3551. $page = $this->input->post('page',true);
  3552. $perpage = $this->input->post('perpage',true);
  3553. $source = $this->input->post('source',true);
  3554. $warehouse = $this->input->post('warehouse',true);
  3555. $express = $this->input->post('express',true);
  3556. $orderremarks = $this->input->post('orderremarks',true);
  3557. $shop = $this->input->post('shop',true);
  3558. $review = $this->input->post('review',true);
  3559. $orderinfo = $this->input->post('orderinfo',true);
  3560. $shipremarks = $this->input->post('shipremarks',true);
  3561. $number = $this->input->post('number',true);
  3562. $timetk = $this->input->post('timetk',true);
  3563. $timetj = $this->input->post('timetj',true);
  3564. $timetk = strtotime($timetk);
  3565. $timetj = strtotime($timetj);
  3566. $where = "mergeid = 0 and state = '207'".$fgshop;
  3567. if($timetk && $timetj)
  3568. {
  3569. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3570. }
  3571. if($source)
  3572. {
  3573. if($source == '2d')
  3574. {
  3575. $where .= " and source >= '2'";
  3576. }
  3577. else
  3578. {
  3579. $where .= " and source = '$source'";
  3580. }
  3581. }
  3582. if($review)
  3583. {
  3584. $where .= " and review = '$review'";
  3585. }
  3586. else
  3587. {
  3588. $where .= " and ((review = '2' and source = '1') or (review = '1' and source >= '2'))";
  3589. }
  3590. if($shop)
  3591. {
  3592. $where .= " and shop = '$shop'";
  3593. }
  3594. if($warehouse)
  3595. {
  3596. $where .= " and type = '$warehouse'";
  3597. }
  3598. if($express)
  3599. {
  3600. $where .= " and express = '$express'";
  3601. }
  3602. if($orderremarks)
  3603. {
  3604. $where .= " and orderremarks like '%$orderremarks%'";
  3605. }
  3606. if($orderinfo)
  3607. {
  3608. $where .= " and orderinfo = '$orderinfo'";
  3609. }
  3610. if($number)
  3611. {
  3612. $where .= " and number = '$number'";
  3613. }
  3614. if($shipremarks)
  3615. {
  3616. $where .= " and shipremarks like '%$shipremarks%'";
  3617. }
  3618. //数据排序
  3619. $order_str = "id desc";
  3620. if(empty($page))
  3621. {
  3622. $start = 0;
  3623. $perpage = 1;
  3624. }
  3625. else
  3626. {
  3627. $start = ($page - 1)*$perpage;
  3628. }
  3629. //取得信息列表
  3630. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,client,express,dtime,shouldmoney,review,orderremarks');
  3631. //格式化数据
  3632. foreach ($info_list as $key=>$value)
  3633. {
  3634. $lr = $this->fullordertt->read($value['id']);
  3635. $shop = $this->shop->read($value['shop']);
  3636. $info_list[$key]['shop'] = $shop['shopname'];
  3637. $warehouse = $this->warehouse->read($value['type']);
  3638. $info_list[$key]['type'] = $warehouse['title'];
  3639. $express = $this->express->read($value['express']);
  3640. $info_list[$key]['express'] = $express['servicename'];
  3641. $info_list[$key]['dtime'] = '<p>'.date('Y-m-d',$value['dtime']).'</p><p>'.date('H:i:s',$value['dtime']).'</p>';
  3642. if($value['review'] == 1)
  3643. {
  3644. $info_list[$key]['review'] = "未送审";
  3645. }
  3646. else if($value['review'] == 2)
  3647. {
  3648. $info_list[$key]['review'] = "待审核";
  3649. }
  3650. else if($value['review'] == 3)
  3651. {
  3652. $info_list[$key]['review'] = "不通过";
  3653. }
  3654. else if($value['review'] == 4)
  3655. {
  3656. $info_list[$key]['review'] = "取消重审";
  3657. }
  3658. else if($value['review'] == 5)
  3659. {
  3660. $info_list[$key]['review'] = "审核通过";
  3661. }
  3662. else if($value['review'] == 6)
  3663. {
  3664. $info_list[$key]['review'] = "自动通过";
  3665. }
  3666. /**
  3667. $info_list[$key]['library'] = "";
  3668. if($value['review'] == 1)
  3669. {
  3670. $info_list[$key]['library'] = "<p><b class='focz' data-type='6' data-id='".$value['id']."'>审核通过</b></p>";
  3671. }
  3672. if($value['review'] == 2)
  3673. {
  3674. $info_list[$key]['library'] = "<p><b class='focz' data-type='5' data-id='".$value['id']."'>审核通过</b></p><p><b class='focz' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3675. }
  3676. else if($value['review'] == 3)
  3677. {
  3678. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='5' data-id='".$value['id']."'>审核通过</b></p>";
  3679. }
  3680. else if($value['review'] == 5)
  3681. {
  3682. $info_list[$key]['library'] = "<p><b class='fullorderttreview' data-type='3' data-id='".$value['id']."'>不通过</b></p>";
  3683. }
  3684. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$lr['currencytitle'];
  3685. $lr['hl'] = $lr['hl']==0?6.71:$lr['hl'];
  3686. $cost = $lr['cost']/$lr['hl'];
  3687. $currencytitle = $lr['budget']-$lr['refundj']-$cost-$lr['expressmoney'];
  3688. $info_list[$key]['currencytitle'] = sprintf("%.2f",$currencytitle).' '.$lr['currencytitle'];
  3689. **/
  3690. }
  3691. $total = $this->fullordertt->find_count($where);
  3692. $pagenum = ceil($total/$perpage);
  3693. $over = $total-($start+$perpage);
  3694. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3695. echo json_encode($rows);exit;
  3696. }
  3697. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  3698. $this->data['shop'] = $wlshop;
  3699. $this->_Template('fullordertt_review',$this->data);
  3700. }
  3701. public function _wlbz($arg_array)
  3702. {
  3703. $post = $this->input->post(NULL, TRUE);
  3704. if(isset($post['id']))
  3705. {
  3706. $id = $this->input->post('id',true);
  3707. $post['wlbz'] = $this->input->post('wlbz',true);
  3708. if($post['wlbz'] == '')
  3709. {
  3710. echo json_encode(array('msg'=>'备注不能为空','success'=>false));exit;
  3711. }
  3712. if($this->fullordertt->save($post,$id))
  3713. {
  3714. echo json_encode(array('msg'=>'修改成功','id'=>$id,'success'=>true));exit;
  3715. }
  3716. else
  3717. {
  3718. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  3719. }
  3720. }
  3721. $arg_array = $arg_array[0];
  3722. $fullordertt = $this->fullordertt->read($arg_array);
  3723. $this->data['fullordertt'] = $fullordertt;
  3724. $this->_Template('fullordertt_wlbz',$this->data);
  3725. }
  3726. //导出资金统计excel
  3727. public function _fmexcel()
  3728. {
  3729. $user = $this->user->get_api($_SESSION['api']);
  3730. if($user)
  3731. {
  3732. $fgshop = "";$sid = "";
  3733. $user = explode('|',trim($user['shop'],'|'));
  3734. foreach ($user as $value)
  3735. {
  3736. $fgshop .= " shop = ".$value." or";
  3737. $sid .= " id = ".$value." or";
  3738. }
  3739. }
  3740. if(isset($_GET['excel']))
  3741. {
  3742. $timetk = $this->input->get('timetk',true);
  3743. $timetj = $this->input->get('timetj',true);
  3744. $shop = $this->input->get('shop',true);
  3745. $source = $this->input->get('source',true);
  3746. $state = $this->input->get('state',true);
  3747. $type = $this->input->get('type',true);
  3748. $orderinfo = $this->input->get('orderinfo',true);
  3749. $user = $this->input->get('user',true);
  3750. $name = $this->input->get('name',true);
  3751. $timetk = strtotime($timetk);
  3752. $timetj = strtotime($timetj);
  3753. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  3754. if($timetk && $timetj)
  3755. {
  3756. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3757. }
  3758. if($shop)
  3759. {
  3760. $where .= " and shop = '$shop'";
  3761. }
  3762. if($source)
  3763. {
  3764. $where .= " and source = '$source'";
  3765. }
  3766. if($state)
  3767. {
  3768. if($state == 1)
  3769. {
  3770. $where .= " and state = '$state'";
  3771. }
  3772. }
  3773. if($type)
  3774. {
  3775. $where .= " and type = '$type'";
  3776. }
  3777. if($orderinfo)
  3778. {
  3779. $where .= " and orderinfo = '$orderinfo'";
  3780. }
  3781. if($user)
  3782. {
  3783. $where .= " and user = '$user'";
  3784. }
  3785. if($name)
  3786. {
  3787. $where .= " and name = '$name'";
  3788. }
  3789. //取得信息列表
  3790. $info_list = $this->fullordertt->find_all($where,'id,shop,user,number,orderinfo,client,country,dtime,ftime,express,waybill,shouldmoney,refund,currency,budget,fpdata,hl,currencytitle');
  3791. //格式化数据
  3792. $i = 1;$shouldmoney = 0;$refund = 0;$budget = 0;$currency = 0;$hl=1;
  3793. foreach ($info_list as $key=>$value)
  3794. {
  3795. $info_list[$key]['id'] = $i;
  3796. if($value['currencytitle'] != "CNY")
  3797. {
  3798. $hl=$value['hl'];
  3799. }
  3800. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3801. $budget=$budget+($value['budget']*$hl);
  3802. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3803. $refund=$refund+($value['refund']*$hl);
  3804. $shop = $this->shop->read($value['shop']);
  3805. $info_list[$key]['shop'] = $shop['shopname'];
  3806. $info_list[$key]['user'] = $shop['shopuser'];
  3807. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3808. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3809. $country = $this->country->read($value['country']);
  3810. $info_list[$key]['country'] = $country['name'];
  3811. $express = $this->express->read($value['express']);
  3812. $info_list[$key]['express'] = $express['servicename'];
  3813. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3814. $info_list[$key]['refund'] = $value['refund'].' '.$value['currencytitle'];
  3815. $info_list[$key]['budget'] = $value['budget'].' '.$value['currencytitle'];
  3816. $info_list[$key]['currency'] = sprintf("%.2f",$value['shouldmoney']-$value['budget']).' '.$value['currencytitle'];
  3817. $fpdata = array();
  3818. if(stripos($value['fpdata'],';') !== false)
  3819. {
  3820. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3821. foreach ($fpdata as $ke=>$va)
  3822. {
  3823. $v = explode('|',rtrim($va,'|'));
  3824. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3825. }
  3826. }
  3827. $info_list[$key]['fpdata'] = $fpdata;
  3828. $i++;
  3829. }
  3830. $data = array($shouldmoney.' CNY',$refund.' CNY',$currency.' CNY',$budget.' CNY');
  3831. $title = "订单资金信息";
  3832. $titlename = "<table border=1>
  3833. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3834. <tr>
  3835. <td>NO.</td>
  3836. <td>店铺</td>
  3837. <td>负责人</td>
  3838. <td>编号</td>
  3839. <td>订单号</td>
  3840. <td>客户姓名</td>
  3841. <td>国家</td>
  3842. <td>订单日期</td>
  3843. <td>发货日期</td>
  3844. <td>快递公司</td>
  3845. <td>运单号</td>
  3846. <td>订单金额</td>
  3847. <td>退款金额</td>
  3848. <td>手续费</td>
  3849. <td>预估金额</td>
  3850. <td>
  3851. <table border=1>
  3852. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  3853. <tr>
  3854. <td>产品</td>
  3855. <td>条数</td>
  3856. <td>数量</td>
  3857. </tr>
  3858. </table>
  3859. </td>
  3860. <td>总条数</td>
  3861. </tr>
  3862. </table>";
  3863. $filename = $title.".xls";
  3864. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td><td>".$data[1]."</td><td>".$data[2]."</td><td>".$data[3]."</td></tr>\n";
  3865. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  3866. }
  3867. }
  3868. //导出订单excel
  3869. public function _fdexcel()
  3870. {
  3871. if(isset($_GET['excel']))
  3872. {
  3873. $page = $this->input->post('page',true);
  3874. $perpage = $this->input->post('perpage',true);
  3875. $timetk = $this->input->post('timetk',true);
  3876. $timetj = $this->input->post('timetj',true);
  3877. $shop = $this->input->post('shop',true);
  3878. $source = $this->input->post('source',true);
  3879. $state = $this->input->post('state',true);
  3880. $review = $this->input->post('review',true);
  3881. $express = $this->input->post('express',true);
  3882. $orderinfo = $this->input->post('orderinfo',true);
  3883. $user = $this->input->post('user',true);
  3884. $name = $this->input->post('name',true);
  3885. $waybill = $this->input->post('waybill',true);
  3886. $timetk = strtotime($timetk);
  3887. $timetj = strtotime($timetj);
  3888. $where = "1=1 and mergeid = 0";
  3889. if($timetk && $timetj)
  3890. {
  3891. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3892. }
  3893. if($shop)
  3894. {
  3895. $where .= " and shop = '$shop'";
  3896. }
  3897. if($source)
  3898. {
  3899. $where .= " and source = '$source'";
  3900. }
  3901. if($state)
  3902. {
  3903. $where .= " and state = '$state'";
  3904. }
  3905. if($review)
  3906. {
  3907. $where .= " and review = '$review'";
  3908. }
  3909. if($express)
  3910. {
  3911. $where .= " and express = '$express'";
  3912. }
  3913. if($orderinfo)
  3914. {
  3915. $where .= " and orderinfo = '$orderinfo'";
  3916. }
  3917. if($user)
  3918. {
  3919. $where .= " and user = '$user'";
  3920. }
  3921. if($name)
  3922. {
  3923. $where .= " and name = '$name'";
  3924. }
  3925. if($waybill)
  3926. {
  3927. $where .= " and waybill = '$waybill'";
  3928. }
  3929. //取得信息列表
  3930. $info_list = $this->fullordertt->find_all($where,'id,shop,number,orderinfo,source,client,name,address,city,zipcode,province,country,phone,dtime,ftime,state,shouldmoney,express,waybill,orderremarks,clientremarks,fpdata,hl,currencytitle');
  3931. //格式化数据
  3932. $i = 1;$shouldmoney = 0;$hl=1;
  3933. foreach ($info_list as $key=>$value)
  3934. {
  3935. $info_list[$key]['id'] = $i;
  3936. if($value['source'] == 1)
  3937. {
  3938. $info_list[$key]['source'] = "线下订单";
  3939. }
  3940. else if($value['source'] == 2)
  3941. {
  3942. $info_list[$key]['source'] = "PC订单";
  3943. }
  3944. else if($value['source'] == 3)
  3945. {
  3946. $info_list[$key]['source'] = "手机订单";
  3947. }
  3948. if($value['currencytitle'] != "CNY")
  3949. {
  3950. $hl=$value['hl'];
  3951. }
  3952. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3953. $shop = $this->shop->read($value['shop']);
  3954. $info_list[$key]['shop'] = $shop['shopname'];
  3955. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3956. $info_list[$key]['ftime'] = date('Y-m-d H:i:s',$value['ftime']);
  3957. $state = $this->typeclass->read($value['state']);
  3958. $info_list[$key]['state'] = $state['title'];
  3959. $country = $this->country->read($value['country']);
  3960. $info_list[$key]['country'] = $country['name'];
  3961. $express = $this->express->read($value['express']);
  3962. $info_list[$key]['express'] = $express['servicename'];
  3963. $info_list[$key]['shouldmoney'] = $value['shouldmoney'].' '.$value['currencytitle'];
  3964. $fpdata = array();
  3965. if(stripos($value['fpdata'],';') !== false)
  3966. {
  3967. $fpdata = explode(';',rtrim($value['fpdata'],';'));
  3968. foreach ($fpdata as $ke=>$va)
  3969. {
  3970. $v = explode('|',rtrim($va,'|'));
  3971. $fpdata[$ke] = array($v[4],$v[5],$v[6],$v[5]*$v[6]);//内容,条数,数量,总条数
  3972. }
  3973. }
  3974. $info_list[$key]['fpdata'] = $fpdata;
  3975. $i++;
  3976. }
  3977. $data = array($shouldmoney.' CNY');
  3978. $title = "订单信息表";
  3979. $titlename = "<table border=1>
  3980. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  3981. <tr>
  3982. <td>NO.</td>
  3983. <td>店铺</td>
  3984. <td>编号</td>
  3985. <td>订单号</td>
  3986. <td>订单类型</td>
  3987. <td>客户姓名</td>
  3988. <td>收件人名称</td>
  3989. <td>收货人地址</td>
  3990. <td>城市</td>
  3991. <td>邮编</td>
  3992. <td>州</td>
  3993. <td>国家</td>
  3994. <td>收件电话</td>
  3995. <td>订单日期</td>
  3996. <td>发货日期</td>
  3997. <td>订单状态</td>
  3998. <td>订单金额</td>
  3999. <td>快递公司</td>
  4000. <td>运单号</td>
  4001. <td>订单备注</td>
  4002. <td>客户备注</td>
  4003. <td>
  4004. <table border=1>
  4005. <tr><td colspan='3' align='center'>订单产品信息</td></tr>
  4006. <tr>
  4007. <td>产品</td>
  4008. <td>条数</td>
  4009. <td>数量</td>
  4010. </tr>
  4011. </table>
  4012. </td>
  4013. <td>总条数</td>
  4014. </tr>
  4015. </table>";
  4016. $filename = $title.".xls";
  4017. $tail = "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>合计:</td><td>".$data[0]."</td></tr>\n";
  4018. $this->excel->get_fz($info_list,$titlename,$filename,$tail);
  4019. }
  4020. }
  4021. public function _black()
  4022. {
  4023. $post = $this->input->post(NULL, TRUE);
  4024. if(isset($post['bd']))
  4025. {
  4026. $bd = $this->input->post('bd',true);
  4027. $rows = $this->fullordertt->read($bd);
  4028. $post['shop'] = $rows['shop'];
  4029. $post['source'] = 1;
  4030. $post['name'] = $rows['client'];
  4031. $post['email'] = $rows['email'];
  4032. $post['phone'] = $rows['phone'];
  4033. $post['country'] = $rows['country'];
  4034. $post['money'] = $rows['shouldmoney'];
  4035. $post['num'] = 1;
  4036. $post['time'] = $rows['dtime'];
  4037. $post['province'] = $rows['province'];
  4038. $post['city'] = $rows['city'];
  4039. $post['street'] = $rows['street'];
  4040. $post['address'] = $rows['address'];
  4041. $post['address2'] = $rows['address2'];
  4042. $post['zipcode'] = $rows['zipcode'];
  4043. $post['type'] = 2;
  4044. if($this->customertt->insert($post))
  4045. {
  4046. $this->fullordertt->save(array('black'=>1),$bd);
  4047. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4048. }
  4049. else
  4050. {
  4051. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4052. }
  4053. }
  4054. }
  4055. public function _ryf()
  4056. {
  4057. $post = $this->input->post(NULL, TRUE);
  4058. if(isset($post['bd']))
  4059. {
  4060. $bd = $this->input->post('bd',true);
  4061. $d = $this->fullordertt->read($bd);
  4062. if($d['state'] == 207 || $d['state'] == 207)//订单状态为等待发货或等待部分发货才可更改为允许发货
  4063. {
  4064. if($d['print'] < 3)//打印状态为未打印
  4065. {
  4066. $print = 1;//未打印
  4067. $libraryconfirm = 1;//不允许出库
  4068. $a = "订单未打印,";
  4069. }
  4070. else//已打印订单
  4071. {
  4072. $libraryconfirm = 2;//允许出库
  4073. $a = "";
  4074. }
  4075. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4076. {
  4077. echo json_encode(array('msg'=>'操作成功','success'=>true));exit;
  4078. }
  4079. else
  4080. {
  4081. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4082. }
  4083. }
  4084. if($this->fullordertt->save(array('librarynot'=>$a,'libraryconfirm'=>$libraryconfirm,'print'=>$print),$bd))
  4085. {
  4086. echo json_encode(array('msg'=>'操作失败!订单未非发货状态','success'=>false));exit;
  4087. }
  4088. else
  4089. {
  4090. echo json_encode(array('msg'=>'操作失败,请重试','success'=>false));exit;
  4091. }
  4092. }
  4093. }
  4094. public function _fsstate()
  4095. {
  4096. $post = $this->input->post(NULL, TRUE);
  4097. if(isset($post['s']))
  4098. {
  4099. $id_arr = $this->input->post('s');
  4100. $id_arr = explode(',',$id_arr);
  4101. if(!$id_arr)
  4102. {
  4103. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  4104. }
  4105. foreach ($id_arr as $v)
  4106. {
  4107. $data = $this->fullordertt->read($v);
  4108. $warehouse = $this->warehouse->read($data['type']);
  4109. $fs = $this->notice->get_ordertatus($data['state']);
  4110. if($fs)
  4111. {
  4112. $ck = $this->_email($fs['content'],$data,$warehouse['company']);
  4113. if($ck == 1)
  4114. {
  4115. $this->fullordertt->save(array('fscontent'=>date('Y-m-d H:i:s',time()).'已发送:'.$fs['title'].' - '),$v);
  4116. }
  4117. }
  4118. }
  4119. echo json_encode(array('msg'=>'发送完成!','success'=>true));exit;
  4120. }
  4121. }
  4122. public function _power()
  4123. {
  4124. $user = $this->user->get_api($_SESSION['api']);
  4125. $post = $this->input->post(NULL, TRUE);
  4126. if(isset($post['id']))
  4127. {
  4128. $id = $this->input->post('id',true);
  4129. $fullordertt = $this->fullordertt->read($id);
  4130. $express = $this->express->read($fullordertt['express']);
  4131. $warehouse = $this->warehouse->read($fullordertt['type']);
  4132. if(($warehouse['zd'] == '1' || stripos($fullordertt['whlabel'],'z|') !== false) && $fullordertt['library'] == '2')
  4133. {
  4134. echo json_encode(array('msg'=>'需要先退库释放库存后才可重置!','success'=>false));exit;
  4135. }
  4136. /**
  4137. if($fullordertt['print'] == '3' && isset($express['iscode']) && ($express['iscode'] == 'ARAMEX' || $express['iscode'] == 'TOLL' || $express['iscode'] == 'FEDEX'))
  4138. {
  4139. $lj = $this->ali->get_lj($fullordertt['number'],2,'订单修改');
  4140. if($lj != '1' && $lj != '订单不存在')
  4141. {
  4142. echo json_encode(array('msg'=>$lj,'success'=>false));exit;
  4143. }
  4144. }
  4145. **/
  4146. $warehouse = $this->warehouse->read($fullordertt['warehouse']);
  4147. $typeclass = $this->typeclass->read($fullordertt['state']);
  4148. $express = $this->express->read($fullordertt['express']);
  4149. $printtype = array(1=>'运单',2=>'发货单',3=>'不打印单据');
  4150. $teset['number']=$fullordertt['number'];
  4151. $teset['orderinfo']=$fullordertt['orderinfo'];
  4152. $teset['shop']=$fullordertt['shop'];
  4153. $teset['user']=$user['userid'];
  4154. $teset['ip']=$this->input->ip_address();
  4155. $teset['time']=time();
  4156. $teset['warehouse']=(isset($warehouse['title']))?$warehouse['title']:'未选择';
  4157. $teset['state']=(isset($typeclass['title']))?$typeclass['spare']:'未选择';
  4158. $teset['express']=(isset($express['title']))?$express['servicename']:'未选择';
  4159. $teset['printtype']=(isset($printtype[$fullordertt['printtype']]))?$printtype[$fullordertt['printtype']]:'未选择';
  4160. $teset['reviewtime']=($fullordertt['reviewtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['reviewtime']):'无';
  4161. $teset['printtime']=($fullordertt['printtime'] > '0')?date('Y-m-d H:i:s',$fullordertt['printtime']):'无';
  4162. $teset['librarytime']=($fullordertt['librarytime'] > '0')?date('Y-m-d H:i:s',$fullordertt['librarytime']):'无';
  4163. $teset['shipremarks']=$fullordertt['shipremarks'];
  4164. $teset['fpdata']=$fullordertt['fpdata'];
  4165. $teset['oldwaybill']=$fullordertt['oldwaybill'];
  4166. $teset['oldprinttime']=$fullordertt['oldprinttime'];
  4167. if($fullordertt['printtype'] == 1)
  4168. {
  4169. if($fullordertt['waybill'] != '' && stripos($fullordertt['oldwaybill'],$fullordertt['waybill']) === false)
  4170. {
  4171. $teset['oldwaybill'] .= '-'.date('Ymd',$fullordertt['printtime']).'/'.$fullordertt['waybill'];
  4172. $teset['oldprinttime'] .= '-'.$fullordertt['printtime'];
  4173. }
  4174. }
  4175. $review = ($fullordertt['source']==1)?2:1;//线下单审核状态直接为待审核
  4176. if(!$this->fullreset->insert($teset))
  4177. {
  4178. echo json_encode(array('msg'=>'重置失败,请重试','success'=>true));exit;
  4179. }
  4180. if($this->fullordertt->save(array('library'=>1,'librarytime'=>0,'libraryconfirm'=>2,'print'=>1,'printtime'=>0,'printnumber'=>0,'retreattime'=>0,'librarynot'=>'订单未打印,未审核或未通过','review'=>$review,'reviewtime'=>0,'state'=>207,'waybill'=>'','waybill2'=>'','oldwaybill'=>$teset['oldwaybill'],'oldprinttime'=>$teset['oldprinttime'],'dlzemail'=>0,'yhs'=>0,'failed'=>''),$id))
  4181. {
  4182. echo json_encode(array('msg'=>'重置成功!如需再次提交,请先保存、再提交','success'=>true));exit;
  4183. }
  4184. else
  4185. {
  4186. echo json_encode(array('msg'=>'重置失败,请重试','success'=>false));exit;
  4187. }
  4188. }
  4189. }
  4190. public function _expresstype()
  4191. {
  4192. $post = $this->input->post(NULL, TRUE);
  4193. if(isset($post['id']))
  4194. {
  4195. $id = $this->input->post('id',true);
  4196. $data = $this->express->read($id);
  4197. echo json_encode(array('msg'=>$data['type'],'success'=>true));exit;
  4198. }
  4199. }
  4200. public function _email($content,$data,$shopname)
  4201. {
  4202. $express = $this->express->read($data['express']);
  4203. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  4204. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  4205. $content = str_replace($t,$h,$content);
  4206. $this->load->library('email');
  4207. $config['protocol'] = 'smtp';
  4208. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  4209. $config['smtp_port'] = 465;
  4210. $config['smtp_user'] = 'service@email.supernovahair.com';
  4211. $config['smtp_pass'] = 'LONGyihair374';
  4212. $config['smtp_crypto'] = 'ssl';
  4213. $config['crlf'] = "\r\n";
  4214. $config['newline'] = "\r\n";
  4215. $this->email->initialize($config);
  4216. $this->email->from('service@email.supernovahair.com',$shopname);
  4217. $this->email->to($data['email']);//收件
  4218. $this->email->subject('The product you purchased has a new progress');//标题
  4219. $this->email->message($content);//内容
  4220. if ( ! $this->email->send())
  4221. {
  4222. return 2;
  4223. }
  4224. else
  4225. {
  4226. return 1;
  4227. }
  4228. }
  4229. public function _error()
  4230. {
  4231. if(isset($_SESSION['api']))
  4232. {
  4233. $user = $this->user->get_api($_SESSION['api']);
  4234. $usp = $user;
  4235. $fgshop = "";$sid = "";
  4236. $user = explode('|',trim($user['shop'],'|'));
  4237. foreach ($user as $value)
  4238. {
  4239. $fgshop .= " shop = ".$value." or";
  4240. $sid .= " id = ".$value." or";
  4241. }
  4242. }
  4243. $post = $this->input->post(NULL, TRUE);
  4244. if(isset($post['page']))
  4245. {
  4246. $page = $this->input->post('page',true);
  4247. $perpage = $this->input->post('perpage',true);
  4248. $orderinfo = $this->input->post('orderinfo',true);
  4249. $waybill = $this->input->post('waybill',true);
  4250. $number = $this->input->post('number',true);
  4251. $timetk = $this->input->post('timetk',true);
  4252. $timetj = $this->input->post('timetj',true);
  4253. $timetk = strtotime($timetk);
  4254. $timetj = strtotime($timetj);
  4255. $where = "failed !='' and mergeid = 0 and print != 3 and (".rtrim($fgshop,'or').")";
  4256. if($orderinfo)
  4257. {
  4258. $where .= " and orderinfo = '$orderinfo'";
  4259. }
  4260. if($waybill)
  4261. {
  4262. $where .= " and waybill = '$waybill'";
  4263. }
  4264. if($number)
  4265. {
  4266. $where .= " and number = '$number'";
  4267. }
  4268. if($timetk && $timetj)
  4269. {
  4270. $timetj = $timetj+24*3600;
  4271. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4272. }
  4273. //数据排序
  4274. $order_str = "dtime desc";
  4275. if(empty($page))
  4276. {
  4277. $start = 0;
  4278. $perpage = 1;
  4279. }
  4280. else
  4281. {
  4282. $start = ($page - 1)*$perpage;
  4283. }
  4284. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,express,failed,operation',$order_str,$start,$perpage);
  4285. //格式化数据
  4286. foreach ($info_list as $key=>$value)
  4287. {
  4288. $ud = $this->fullordertt->read($value['id']);
  4289. $shop = $this->shop->read($value['shop']);
  4290. $info_list[$key]['shop'] = $shop['shopname'];
  4291. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4292. $warehouse = $this->warehouse->read($value['type']);
  4293. $warehousetitle = $warehouse['title'];
  4294. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4295. $info_list[$key]['type'] = $warehousetitle;
  4296. if($value['express'] != 0)
  4297. {
  4298. $express = $this->express->read($value['express']);
  4299. $expressservicename = $express['servicename'];
  4300. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4301. $info_list[$key]['express'] = $expressservicename;
  4302. }
  4303. else
  4304. {
  4305. $info_list[$key]['express'] = "无";
  4306. }
  4307. $x = "";
  4308. if($ud['review'] >4 && $ud['print'] == 1)
  4309. {
  4310. $x = "<p class='ckn'><b class='fojzof' data-type='8' data-id='".$value['id']."'>允许打印</b></p>";
  4311. }
  4312. else
  4313. {
  4314. $x = "<p class='ckn'><b class='fojzof' data-type='9' data-id='".$value['id']."'>关闭</b></p>";
  4315. }
  4316. $info_list[$key]['operation'] = $x;
  4317. }
  4318. $total = $this->fullordertt->find_count($where);
  4319. $pagenum = ceil($total/$perpage);
  4320. $over = $total-($start+$perpage);
  4321. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4322. echo json_encode($rows);exit;
  4323. }
  4324. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4325. $this->data['wlshop'] = $wlshop;
  4326. $this->data['express'] = $this->express->find_all();
  4327. $user = $this->user->get_api($_SESSION['api']);
  4328. $powerid = $this->power->read($user['power']);
  4329. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4330. $pid = '';
  4331. foreach ($powertext as $v)
  4332. {
  4333. $pid .= " id = ".$v." or";
  4334. }
  4335. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4336. $this->data['fullorderexcel'] = $fullorderexcel;
  4337. $this->_Template('fullordertt_error',$this->data);
  4338. }
  4339. public function _yc()
  4340. {
  4341. if(isset($_SESSION['api']))
  4342. {
  4343. $user = $this->user->get_api($_SESSION['api']);
  4344. $usp = $user;
  4345. $fgshop = "";$sid = "";
  4346. $user = explode('|',trim($user['shop'],'|'));
  4347. foreach ($user as $value)
  4348. {
  4349. $fgshop .= " shop = ".$value." or";
  4350. $sid .= " id = ".$value." or";
  4351. }
  4352. }
  4353. $post = $this->input->post(NULL, TRUE);
  4354. if(isset($post['page']))
  4355. {
  4356. $page = $this->input->post('page',true);
  4357. $perpage = $this->input->post('perpage',true);
  4358. $orderinfo = $this->input->post('orderinfo',true);
  4359. $waybill = $this->input->post('waybill',true);
  4360. $number = $this->input->post('number',true);
  4361. $timetk = $this->input->post('timetk',true);
  4362. $timetj = $this->input->post('timetj',true);
  4363. $timetk = strtotime($timetk);
  4364. $timetj = strtotime($timetj);
  4365. $where = "library = 2 and state = 214 and (".rtrim($fgshop,'or').")";
  4366. if($orderinfo)
  4367. {
  4368. $where .= " and orderinfo = '$orderinfo'";
  4369. }
  4370. if($waybill)
  4371. {
  4372. $where .= " and waybill = '$waybill'";
  4373. }
  4374. if($number)
  4375. {
  4376. $where .= " and number = '$number'";
  4377. }
  4378. if($timetk && $timetj)
  4379. {
  4380. $timetj = $timetj+24*3600;
  4381. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4382. }
  4383. //数据排序
  4384. $order_str = "dtime desc";
  4385. if(empty($page))
  4386. {
  4387. $start = 0;
  4388. $perpage = 1;
  4389. }
  4390. else
  4391. {
  4392. $start = ($page - 1)*$perpage;
  4393. }
  4394. $info_list = $this->fullordertt->find_all($where,'id,shop,type,orderinfo,number,state,dtime,express,waybill,library,operation',$order_str,$start,$perpage);
  4395. //格式化数据
  4396. foreach ($info_list as $key=>$value)
  4397. {
  4398. $ud = $this->fullordertt->read($value['id']);
  4399. $shop = $this->shop->read($value['shop']);
  4400. $info_list[$key]['shop'] = $shop['shopname'];
  4401. $info_list[$key]['orderinfo'] = "<h9 class='window' data-h='/fullordertt/edit/".$value['id']."' data-t='订单号:".$value['orderinfo']."'>".$value['orderinfo']."<p>";
  4402. $warehouse = $this->warehouse->read($value['type']);
  4403. $warehousetitle = $warehouse['title'];
  4404. if($value['type'] != 1){$warehousetitle = "<font style='color:#f64b4b'>".$warehouse['title']."</font>";}
  4405. $info_list[$key]['type'] = $warehousetitle;
  4406. if($value['express'] != 0)
  4407. {
  4408. $express = $this->express->read($value['express']);
  4409. $expressservicename = $express['servicename'];
  4410. if($value['express'] != 1){$expressservicename = "<font style='color:#f64b4b'>".$express['servicename']."</font>";}
  4411. $info_list[$key]['express'] = $expressservicename;
  4412. }
  4413. else
  4414. {
  4415. $info_list[$key]['express'] = "无";
  4416. }
  4417. $typeclass = $this->typeclass->read($value['state']);
  4418. $info_list[$key]['state'] = "<font style='font-size: 13px;'>".$typeclass['spare']."</font>";
  4419. $info_list[$key]['dtime'] = '<p style="font-size: 13px;">'.date('Y-m-d',$ud['dtime']).'</p><p style="font-size: 13px;">'.date('H:i:s',$ud['dtime']).'</p>';
  4420. if($value['library'] == 1 && $ud['printtype'] == 3)
  4421. {
  4422. $info_list[$key]['library'] = "不需要";
  4423. }
  4424. else if($value['library'] == 1 && $ud['printtype'] != 3)
  4425. {
  4426. $info_list[$key]['library'] = "未出库";
  4427. }
  4428. else if($value['library'] == 2)
  4429. {
  4430. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['librarytime']).'</p><p>'.date('H:i:s',$ud['librarytime']).'出库</p>';
  4431. }
  4432. else if($value['library'] == 3)
  4433. {
  4434. $info_list[$key]['library'] = '<p>'.date('Y-m-d',$ud['retreattime']).'</p><p>'.date('H:i:s',$ud['retreattime']).'退库</p>';
  4435. }
  4436. $info_list[$key]['operation'] = "<p class='ckn'><b class='ycyc' data-id='".$value['id']."'>移 出</b></p>";
  4437. }
  4438. $total = $this->fullordertt->find_count($where);
  4439. $pagenum = ceil($total/$perpage);
  4440. $over = $total-($start+$perpage);
  4441. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4442. echo json_encode($rows);exit;
  4443. }
  4444. if(isset($post['id']))
  4445. {
  4446. $id = $this->input->post('id',true);
  4447. $data = $this->fullordertt->read($id);
  4448. if($this->fullordertt->save(array('state'=>217),$id))
  4449. {
  4450. echo json_encode(array('msg'=>'移除成功','id'=>$id,'success'=>true));exit;
  4451. }
  4452. else
  4453. {
  4454. echo json_encode(array('msg'=>"操作失败请重试",'success'=>false));exit;
  4455. }
  4456. }
  4457. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  4458. $this->data['wlshop'] = $wlshop;
  4459. $this->data['express'] = $this->express->find_all();
  4460. $user = $this->user->get_api($_SESSION['api']);
  4461. $powerid = $this->power->read($user['power']);
  4462. $powertext = explode('|',trim($powerid['excelid'],'|'));
  4463. $pid = '';
  4464. foreach ($powertext as $v)
  4465. {
  4466. $pid .= " id = ".$v." or";
  4467. }
  4468. $fullorderexcel = $this->fullorderexcel->find_all("type = '100006' and (".rtrim($pid,'or').")",'*','idorder desc');//导出模板
  4469. $this->data['fullorderexcel'] = $fullorderexcel;
  4470. $this->_Template('fullordertt_yc',$this->data);
  4471. }
  4472. //验证地址
  4473. public function _yzaddress()
  4474. {
  4475. $post = $this->input->post(NULL, TRUE);
  4476. if(isset($post['address']))
  4477. {
  4478. $address = $this->input->post('address',true);
  4479. $address2 = $this->input->post('address2',true);
  4480. $city = $this->input->post('city',true);
  4481. $province = $this->input->post('province',true);
  4482. $zipcode = $this->input->post('zipcode',true);
  4483. $barcode = $this->usps->get_address(array('address'=>$address,'address2'=>$address2,'city'=>$city,'province'=>$province,'zipcode'=>$zipcode));
  4484. echo $barcode;
  4485. }
  4486. }
  4487. //清除退货信息
  4488. public function _clearreturn()
  4489. {
  4490. $post = $this->input->post(NULL, TRUE);
  4491. if(isset($post['orderinfo']))
  4492. {
  4493. $orderinfo = $this->input->post('orderinfo',true);
  4494. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4495. $fu = 'fullordertt';
  4496. if(!$data)
  4497. {
  4498. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4499. $fu = 'fullorder_smt';
  4500. }
  4501. $this->$fu->save(array('library'=>'2','retreattime'=>'0','returndata'=>''),$data['id']);
  4502. echo json_encode(array('msg'=>'清除成功!','success'=>true));exit;
  4503. }
  4504. }
  4505. //订单退货
  4506. public function _return()
  4507. {
  4508. $post = $this->input->post(NULL, TRUE);
  4509. if(isset($post['orderinfo']))
  4510. {
  4511. $orderinfo = $this->input->post('orderinfo',true);
  4512. $data = $this->fullordertt->get_orderinfo($orderinfo);
  4513. $fu = 'fullordertt';
  4514. if(!$data)
  4515. {
  4516. $data = $this->fullorder_smt->get_orderinfo($orderinfo);
  4517. $fu = 'fullorder_smt';
  4518. }
  4519. $bctime = date('Ymd',time());
  4520. if($data['returndata'] != "")
  4521. {
  4522. echo json_encode(array('msg'=>'请求失败,已有Return Label信息!','success'=>false));exit;
  4523. }
  4524. $barcode = $this->usps->get_return($data);
  4525. if(isset($barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription']))
  4526. {
  4527. echo json_encode(array('msg'=>$barcode['errors']['ExternalReturnLabelError']['InternalErrorDescription'],'success'=>false));exit;
  4528. }
  4529. else if(isset($barcode['TrackingNumber']))
  4530. {
  4531. $pdf = $this->_pdf($barcode['ReturnLabel'],'t-'.$barcode['TrackingNumber'],$bctime);
  4532. $read = 'PostalRouting:'.$barcode['PostalRouting'].' - TrackingNumber:<a href="/data/pdf/'.$bctime.'/'.'t-'.$barcode['TrackingNumber'].'.pdf" target="_blank">'.$barcode['TrackingNumber'].'</a>';
  4533. $this->$fu->save(array('returndata'=>$read),$data['id']);
  4534. echo json_encode(array('msg'=>'生成Return Label成功!','data'=>$read,'success'=>true));exit;
  4535. }
  4536. else
  4537. {
  4538. echo json_encode(array('msg'=>'请求失败,请稍后重试!','cs'=>$barcode,'success'=>false));exit;
  4539. }
  4540. }
  4541. }
  4542. public function _pdf($pdf,$title,$bctime)
  4543. {
  4544. $pdf_path = './data/pdf/'.$bctime.'/';
  4545. $file_base64 = $pdf;
  4546. $file_base64 = preg_replace('/data:.*;base64,/i', '', $file_base64);
  4547. $file_base64 = base64_decode($file_base64);
  4548. if(!is_dir($pdf_path))mkdir($pdf_path,0777); //上传目录不存在则创建
  4549. file_put_contents($pdf_path.$title.'.pdf',$file_base64);
  4550. return $bctime;
  4551. }
  4552. public function _find($find)
  4553. {
  4554. preg_match_all('/\d+/',$find,$n);
  4555. $a = '';
  4556. foreach($n[0] as $v)
  4557. {
  4558. $a .= $v;
  4559. }
  4560. return $a;
  4561. }
  4562. public function _dqpm()
  4563. {
  4564. if(isset($_SESSION['api']))
  4565. {
  4566. $user = $this->user->get_api($_SESSION['api']);
  4567. $usp = $user;
  4568. $fgshop = "";$sid = "";
  4569. $usersp = explode('|',trim($user['shop'],'|'));
  4570. foreach ($usersp as $value)
  4571. {
  4572. $fgshop .= " shop = ".$value." or";
  4573. $sid .= " id = ".$value." or";
  4574. }
  4575. }
  4576. $post = $this->input->post(NULL, TRUE);
  4577. if(isset($post['page']))
  4578. {
  4579. $timetk = $this->input->post('timetk',true);
  4580. $timetj = $this->input->post('timetj',true);
  4581. $timetk = strtotime($timetk);
  4582. $timetj = strtotime($timetj);
  4583. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  4584. if($timetk && $timetj)
  4585. {
  4586. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  4587. }
  4588. //数据排序
  4589. $order_str = "dtime desc";
  4590. if(empty($page))
  4591. {
  4592. $start = 0;
  4593. $perpage = 1;
  4594. }
  4595. else
  4596. {
  4597. $start = ($page - 1)*$perpage;
  4598. }
  4599. $continentdata = '';
  4600. $continent = array();//陆地板块
  4601. $num = $this->fullordertt->find_count($where);//订单总数量
  4602. $country = $this->country->find_all('1=1','id,continent,ename,zname');
  4603. foreach ($country as $k=>$v)
  4604. {
  4605. $tc = $this->typeclass->read($v['continent']);
  4606. $continent[$v['continent']] = array(0=>$tc['title'],1=>0,2=>'');
  4607. }
  4608. foreach ($country as $k=>$v)
  4609. {
  4610. $n = $this->fullordertt->find_count($where.' and country = "'.$v['id'].'"');
  4611. $country[$k]['continent'] = $continent[$v['continent']][0];//此国家数量
  4612. $country[$k]['zname'] = '<a href="/fullordertt/dqpmprovince/'.$v['id'].'/'.$timetk.'/'.$timetj.'">'.$v['zname'].'</a>';//此国家数量
  4613. $country[$k]['num'] = $n;//此国家数量
  4614. $country[$k]['zb'] = (sprintf("%.4f",$n/$num)*100).'%';//此国家占比
  4615. $continent[$v['continent']]['1'] += $n;//此洲数量增加;
  4616. }
  4617. array_multisort(array_column($continent, '1'), SORT_DESC, $continent);
  4618. array_multisort(array_column($country, 'num'), SORT_DESC, $country);
  4619. foreach ($continent as $k=>$v)
  4620. {
  4621. $continentdata .= $v['0'].' 总量:'.$v['1'].' 占比:'.(sprintf("%.4f",$v['1']/$num)*100).'%&nbsp;&nbsp; - &nbsp;&nbsp;';
  4622. }
  4623. echo json_encode(array('ewnr'=>$continentdata,'rows'=>$country,'total'=>count($country),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4624. }
  4625. $this->_Template('fullordertt_dqpm',$this->data);
  4626. }
  4627. public function _dqpmprovince($arg_array)
  4628. {
  4629. if(isset($_SESSION['api']))
  4630. {
  4631. $user = $this->user->get_api($_SESSION['api']);
  4632. $usp = $user;
  4633. $fgshop = "";$sid = "";
  4634. $usersp = explode('|',trim($user['shop'],'|'));
  4635. foreach ($usersp as $value)
  4636. {
  4637. $fgshop .= " shop = ".$value." or";
  4638. $sid .= " id = ".$value." or";
  4639. }
  4640. }
  4641. $post = $this->input->post(NULL, TRUE);
  4642. if(isset($post['page']))
  4643. {
  4644. $country = $this->input->post('country',true);
  4645. $timetk = $this->input->post('timetk',true);
  4646. $timetj = $this->input->post('timetj',true);
  4647. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4648. $province = array();
  4649. $city_list = $this->fullordertt->find_all($where,'id,province');
  4650. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4651. foreach ($city_list as $k=>$v)
  4652. {
  4653. $v['province'] = strtoupper(trim($v['province'],' '));
  4654. if(isset($ToState[$v['province']]))
  4655. {
  4656. $v['province'] = $ToState[$v['province']];
  4657. }
  4658. if(!isset($province[$v['province']]))
  4659. {
  4660. $province[$v['province']] = array('id'=>$v['id'],'province'=>'<a href="/fullordertt/ddpmdata/'.$country.'/'.$timetk.'/'.$timetj.'/'.strtoupper($v['province']).'">'.$v['province'].'</a>','num'=>0,'zb'=>'');
  4661. }
  4662. $province[$v['province']]['num'] += 1;
  4663. }
  4664. array_multisort(array_column($province, 'num'), SORT_DESC, $province);
  4665. $province = array_values($province);
  4666. foreach ($province as $k=>$v)
  4667. {
  4668. $province[$k]['zb'] = (sprintf("%.4f",$v['num']/count($city_list))*100).'%';
  4669. }
  4670. echo json_encode(array('rows'=>($province),'total'=>count($province),'over'=>0,'pagenum'=>1,'success'=>true));exit;
  4671. }
  4672. $this->data['arg_array'] = $arg_array;
  4673. $this->_Template('fullordertt_dqpmprovince',$this->data);
  4674. }
  4675. public function _ddpmdata($arg_array)
  4676. {
  4677. $arg_array[3] = str_replace('%20',' ',$arg_array[3]);
  4678. if(isset($_SESSION['api']))
  4679. {
  4680. $user = $this->user->get_api($_SESSION['api']);
  4681. $usp = $user;
  4682. $fgshop = "";$sid = "";
  4683. $usersp = explode('|',trim($user['shop'],'|'));
  4684. foreach ($usersp as $value)
  4685. {
  4686. $fgshop .= " shop = ".$value." or";
  4687. $sid .= " id = ".$value." or";
  4688. }
  4689. }
  4690. $post = $this->input->post(NULL, TRUE);
  4691. if(isset($post['page']))
  4692. {
  4693. $page = $this->input->post('page',true);
  4694. $perpage = $this->input->post('perpage',true);
  4695. $province = $this->input->post('province',true);
  4696. $timetk = $this->input->post('timetk',true);;
  4697. $timetj = $this->input->post('timetj',true);;
  4698. $country = $this->input->post('country',true);;
  4699. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4700. if($province)
  4701. {
  4702. $where .= " and province = '$province'";
  4703. }
  4704. $order_str = "dtime desc";
  4705. if(empty($page))
  4706. {
  4707. $start = 0;
  4708. $perpage = 1;
  4709. }
  4710. else
  4711. {
  4712. $start = ($page - 1)*$perpage;
  4713. }
  4714. $info_list = $this->fullordertt->find_all($where,'id,orderinfo,number,shipremarks,shouldmoney',$order_str,$start,$perpage);
  4715. $total = $this->fullordertt->find_count($where);
  4716. $pagenum = ceil($total/$perpage);
  4717. $over = $total-($start+$perpage);
  4718. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4719. echo json_encode($rows);exit;
  4720. }
  4721. $province = array();
  4722. $city_list = $this->fullordertt->find_all("mergeid = 0 and dtime > '$arg_array[1]' and dtime < '$arg_array[2]' and country = '$arg_array[0]' and (".rtrim($fgshop,'or').")",'province');
  4723. $ToState = array('AL'=>'alabama','AK'=>'alaska','AZ'=>'arizona','AR'=>'arkansas','CA'=>'california','CO'=>'colorado','CT'=>'connecticut','DE'=>'delaware','FL'=>'florida','GA'=>'georgia','HI'=>'hawaii','ID'=>'idaho','IL'=>'illinois','IN'=>'indiana','IA'=>'iowa','KS'=>'kansas','KY'=>'kentucky','LA'=>'louisiana','ME'=>'maine','MD'=>'maryland','MA'=>'massachusetts','MI'=>'michigan','MN'=>'minnesota','MS'=>'mississippi','MO'=>'missouri','MT'=>'montana','NE'=>'nebraska','NV'=>'nevada','NH'=>'new hampshire','NJ'=>'new jersey','NM'=>'new mexico','NY'=>'new york','NC'=>'north carolina','ND'=>'north dakota','OH'=>'ohio','OK'=>'oklahoma','OR'=>'oregon','PA'=>'pennsylvania','RI'=>'rhode island','SC'=>'south carolina','SD'=>'south dakota','TN'=>'tennessee','TX'=>'texas','UT'=>'utah','VT'=>'vermont','VA'=>'virginia','WA'=>'washington','WV'=>'west virginia','WI'=>'wisconsin','WY'=>'wyoming','DC'=>'district of columbia','VI'=>'virgin islands');
  4724. foreach ($city_list as $k=>$v)
  4725. {
  4726. $v['province'] = strtoupper(trim($v['province'],' '));
  4727. if(isset($ToState[$v['province']]))
  4728. {
  4729. $v['province'] = $ToState[$v['province']];
  4730. }
  4731. $province[$v['province']] = array('province'=>$v['province']);
  4732. }
  4733. $this->data['province'] = $province;
  4734. $this->data['arg_array'] = $arg_array;
  4735. $this->_Template('fullordertt_ddpmdata',$this->data);
  4736. }
  4737. public function _ddpmexcel($arg_array)
  4738. {
  4739. if(isset($_SESSION['api']))
  4740. {
  4741. $user = $this->user->get_api($_SESSION['api']);
  4742. $usp = $user;
  4743. $fgshop = "";$sid = "";
  4744. $usersp = explode('|',trim($user['shop'],'|'));
  4745. foreach ($usersp as $value)
  4746. {
  4747. $fgshop .= " shop = ".$value." or";
  4748. $sid .= " id = ".$value." or";
  4749. }
  4750. }
  4751. $province = $this->input->get('province',true);
  4752. $timetk = $arg_array[1];
  4753. $timetj = $arg_array[2];
  4754. $country = $arg_array[0];
  4755. $where = "mergeid = 0 and dtime > '$timetk' and dtime < '$timetj' and country = '$country' and (".rtrim($fgshop,'or').")";
  4756. if($province)
  4757. {
  4758. $where .= " and province = '$province'";
  4759. }
  4760. $order_str = "dtime desc";
  4761. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,shipremarks,shouldmoney',$order_str);
  4762. $country = $this->country->read($arg_array[0]);
  4763. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  4764. $titlename = "<table border=1>
  4765. <tr><th colspan='4' align='left'><h3>".$title."<h3></th></tr>
  4766. <tr>
  4767. <td>订单号</td>
  4768. <td>订单编号</td>
  4769. <td>仓库品名</td>
  4770. <td>订单金额</td>
  4771. </tr>
  4772. </table>";
  4773. $filename = $title.".xls";
  4774. $tail = "\n";
  4775. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4776. }
  4777. public function _statedc()
  4778. {
  4779. $user = $this->user->get_api($_SESSION['api']);
  4780. if($user)
  4781. {
  4782. $fgshop = "";$sid = "";
  4783. $user = explode('|',trim($user['shop'],'|'));
  4784. foreach ($user as $value)
  4785. {
  4786. $fgshop .= " shop = ".$value." or";
  4787. $sid .= " id = ".$value." or";
  4788. }
  4789. }
  4790. $post = $this->input->get(NULL, TRUE);
  4791. if(isset($post['timetk']))
  4792. {
  4793. $page = $this->input->get('page',true);
  4794. $perpage = $this->input->get('perpage',true);
  4795. $timetk = $this->input->get('timetk',true);
  4796. $timetj = $this->input->get('timetj',true);
  4797. $shop = $this->input->get('shop',true);
  4798. $source = $this->input->get('source',true);
  4799. $state = $this->input->get('state',true);
  4800. $review = $this->input->get('review',true);
  4801. $express = $this->input->get('express',true);
  4802. $fs = $this->input->get('fs',true);
  4803. $orderinfo = $this->input->get('orderinfo',true);
  4804. $number = $this->input->get('number',true);
  4805. $user = $this->input->get('user',true);
  4806. $name = $this->input->get('name',true);
  4807. $waybill = $this->input->get('waybill',true);
  4808. $expressstate = $this->input->get('expressstate',true);
  4809. $wltype = $this->input->get('wltype',true);
  4810. $wlyc = $this->input->get('wlyc',true);
  4811. $xztime = $this->input->get('xztime',true);
  4812. $timetk = strtotime($timetk);
  4813. $timetj = strtotime($timetj);
  4814. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  4815. if($timetk && $timetj)
  4816. {
  4817. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  4818. }
  4819. if($xztime == 'librarytime')
  4820. {
  4821. $order_str = "librarytime desc";
  4822. }
  4823. else if($xztime == 'dtime')
  4824. {
  4825. $order_str = "dtime desc";
  4826. }
  4827. if($shop)
  4828. {
  4829. $where .= " and shop = '$shop'";
  4830. }
  4831. if($source)
  4832. {
  4833. if($source == 11)
  4834. {
  4835. $where .= " and source != '1'";
  4836. }
  4837. else
  4838. {
  4839. $where .= " and source = '$source'";
  4840. }
  4841. }
  4842. if($fs)
  4843. {
  4844. if($fs == '2')
  4845. {
  4846. $where .= " and exstateerror != ''";
  4847. }
  4848. else
  4849. {
  4850. $where .= " and exstateerror = ''";
  4851. }
  4852. }
  4853. if($state)
  4854. {
  4855. $where .= " and state = '$state'";
  4856. }
  4857. if($review)
  4858. {
  4859. $where .= " and review = '$review'";
  4860. }
  4861. if($expressstate != "")
  4862. {
  4863. $where .= " and expressstate = '$expressstate'";
  4864. }
  4865. if($wltype != "")
  4866. {
  4867. $where .= " and wltype = '$wltype'";
  4868. }
  4869. if($wlyc != "")
  4870. {
  4871. $where .= " and wlyc = '$wlyc'";
  4872. }
  4873. if($express)
  4874. {
  4875. $where .= " and express = '$express'";
  4876. }
  4877. if($orderinfo)
  4878. {
  4879. $where .= " and orderinfo = '$orderinfo'";
  4880. }
  4881. if($number)
  4882. {
  4883. $where .= " and number = '$number'";
  4884. }
  4885. if($user)
  4886. {
  4887. $where .= " and user = '$user'";
  4888. }
  4889. if($name)
  4890. {
  4891. $where .= " and name = '$name'";
  4892. }
  4893. if($waybill)
  4894. {
  4895. $where .= " and waybill = '$waybill'";
  4896. }
  4897. if(empty($page))
  4898. {
  4899. $start = 0;
  4900. $perpage = 1;
  4901. }
  4902. else
  4903. {
  4904. $start = ($page - 1)*$perpage;
  4905. }
  4906. //取得信息列表
  4907. $info_list = $this->fullordertt->find_all($where,'shop,number,country,library,librarytime,expressstate,express,waybill,content,exstateerror,excontent',$order_str);
  4908. //格式化数据
  4909. foreach ($info_list as $key=>$value)
  4910. {
  4911. $shop = $this->shop->read($value['shop']);
  4912. $info_list[$key]['shop'] = $shop['shopname'];
  4913. $country = $this->country->read($value['country']);
  4914. $info_list[$key]['country'] = $country['name'];
  4915. //$state = $this->typeclass->read($value['state']);
  4916. //$info_list[$key]['state'] = $state['title'];
  4917. if($value['library'] == 1)
  4918. {
  4919. $info_list[$key]['library'] = "未出库";
  4920. }
  4921. else if($value['library'] == 2)
  4922. {
  4923. $info_list[$key]['library'] = "已出库";
  4924. }
  4925. else if($value['library'] == 3)
  4926. {
  4927. $info_list[$key]['library'] = "已退库";
  4928. }
  4929. if($value['librarytime'] == '0')
  4930. {
  4931. $info_list[$key]['librarytime'] = '无';
  4932. }
  4933. else
  4934. {
  4935. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  4936. }
  4937. if($value['expressstate'] == 0)
  4938. {
  4939. $info_list[$key]['expressstate'] = "无信息";
  4940. }
  4941. else if($value['expressstate'] == 2)
  4942. {
  4943. $info_list[$key]['expressstate'] = "已取件";
  4944. }
  4945. else if($value['expressstate'] == 3)
  4946. {
  4947. $info_list[$key]['expressstate'] = "在途中";
  4948. }
  4949. else if($value['expressstate'] == 4)
  4950. {
  4951. $info_list[$key]['expressstate'] = "到达目的地国";
  4952. }
  4953. else if($value['expressstate'] == 5)
  4954. {
  4955. $info_list[$key]['expressstate'] = "即将派送";
  4956. }
  4957. else if($value['expressstate'] == 6)
  4958. {
  4959. $info_list[$key]['expressstate'] = "已签收";
  4960. }
  4961. else if($value['expressstate'] == 1)
  4962. {
  4963. $info_list[$key]['expressstate'] = "派送异常";
  4964. }
  4965. $express = $this->express->read($value['express']);
  4966. $info_list[$key]['express'] = $express['servicename'];
  4967. }
  4968. }
  4969. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  4970. $titlename = "<table border=1>
  4971. <tr>
  4972. <td>店铺名称</td>
  4973. <td>编号</td>
  4974. <td>收件人国家</td>
  4975. <td>出库状态</td>
  4976. <td>发货时间</td>
  4977. <td>物流状态</td>
  4978. <td>快递公司</td>
  4979. <td>运单号</td>
  4980. <td>消息状态</td>
  4981. <td>错误提示</td>
  4982. <td>物流信息</td>
  4983. </tr>
  4984. </table>";
  4985. $filename = $title.".xls";
  4986. $tail = "\n";
  4987. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  4988. }
  4989. public function _statedcwl()
  4990. {
  4991. $user = $this->user->get_api($_SESSION['api']);
  4992. if($user)
  4993. {
  4994. $fgshop = "";$sid = "";
  4995. $user = explode('|',trim($user['shop'],'|'));
  4996. foreach ($user as $value)
  4997. {
  4998. $fgshop .= " shop = ".$value." or";
  4999. $sid .= " id = ".$value." or";
  5000. }
  5001. }
  5002. $post = $this->input->get(NULL, TRUE);
  5003. if(isset($post['timetk']))
  5004. {
  5005. $dowid = $this->input->get('a');
  5006. $wid = "";
  5007. if($dowid != "")
  5008. {
  5009. $id_arr = explode(',',rtrim($dowid,','));
  5010. $wid .= " id = 0 or";
  5011. foreach ($id_arr as $v)
  5012. {
  5013. $wid .= " id = '$v' or";
  5014. }
  5015. $wid = " and".rtrim($wid,'or');
  5016. }
  5017. $page = $this->input->get('page',true);
  5018. $perpage = $this->input->get('perpage',true);
  5019. $timetk = $this->input->get('timetk',true);
  5020. $timetj = $this->input->get('timetj',true);
  5021. $shop = $this->input->get('shop',true);
  5022. $expressstate = $this->input->get('expressstate',true);
  5023. $fs = $this->input->get('fs',true);
  5024. $state = $this->input->get('state',true);
  5025. $express = $this->input->get('express',true);
  5026. $orderinfo = $this->input->get('orderinfo',true);
  5027. $number = $this->input->get('number',true);
  5028. $waybill = $this->input->get('waybill',true);
  5029. $wlyc = $this->input->get('wlyc',true);
  5030. $wltype = $this->input->get('wltype',true);
  5031. $source = $this->input->get('source',true);
  5032. $xztime = $this->input->get('xztime',true);
  5033. $timetk = strtotime($timetk);
  5034. $timetj = strtotime($timetj);
  5035. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5036. if($timetk && $timetj)
  5037. {
  5038. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5039. }
  5040. if($xztime == 'librarytime')
  5041. {
  5042. $order_str = "librarytime desc";
  5043. }
  5044. else if($xztime == 'dtime')
  5045. {
  5046. $order_str = "dtime desc";
  5047. }
  5048. if($shop)
  5049. {
  5050. $where .= " and shop = '$shop'";
  5051. }
  5052. if($expressstate)
  5053. {
  5054. $where .= " and expressstate = '$expressstate'";
  5055. }
  5056. if($fs)
  5057. {
  5058. if($fs == '1')
  5059. {
  5060. $where .= " and wlcontent != ''";
  5061. }
  5062. if($fs == '2')
  5063. {
  5064. $where .= " and wlerror != ''";
  5065. }
  5066. if($fs == '3')
  5067. {
  5068. $where .= " and wlcontent = '' and shouldmoney > 100";
  5069. }
  5070. else if($fs == '4')
  5071. {
  5072. $where .= " and wltype = '1'";
  5073. }
  5074. }
  5075. if($state)
  5076. {
  5077. $where .= " and state = '$state'";
  5078. }
  5079. if($express)
  5080. {
  5081. $where .= " and express = '$express'";
  5082. }
  5083. if($orderinfo)
  5084. {
  5085. $where .= " and orderinfo = '$orderinfo'";
  5086. }
  5087. if($number)
  5088. {
  5089. $where .= " and number = '$number'";
  5090. }
  5091. if($waybill)
  5092. {
  5093. $where .= " and waybill = '$waybill'";
  5094. }
  5095. if($wlyc!='')
  5096. {
  5097. $where .= " and wlyc = '$wlyc'";
  5098. }
  5099. if($wltype!='')
  5100. {
  5101. $where .= " and wltype = '$wltype'";
  5102. }
  5103. if($source)
  5104. {
  5105. if($source == 1)
  5106. {
  5107. $where .= " and source = '$source'";
  5108. }
  5109. else
  5110. {
  5111. $where .= " and source != '1'";
  5112. }
  5113. }
  5114. $info_list = $this->fullordertt->find_all($where.$wid,'orderinfo,number,country,library,librarytime,expressstate,express,waybill,wlbz,orderremarks,shipremarks,wlfstime,email,phone,wlcontent,wlerror,excontent',$order_str);
  5115. //格式化数据
  5116. foreach ($info_list as $key=>$value)
  5117. {
  5118. $country = $this->country->read($value['country']);
  5119. $info_list[$key]['country'] = $country['name'];
  5120. //$state = $this->typeclass->read($value['state']);
  5121. //$info_list[$key]['state'] = $state['title'];
  5122. if($value['library'] == 1)
  5123. {
  5124. $info_list[$key]['library'] = "未出库";
  5125. }
  5126. else if($value['library'] == 2)
  5127. {
  5128. $info_list[$key]['library'] = "已出库";
  5129. }
  5130. else if($value['library'] == 3)
  5131. {
  5132. $info_list[$key]['library'] = "已退库";
  5133. }
  5134. if($value['librarytime'] == '0')
  5135. {
  5136. $info_list[$key]['librarytime'] = '无';
  5137. }
  5138. else
  5139. {
  5140. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  5141. }
  5142. if($value['expressstate'] == 0)
  5143. {
  5144. $info_list[$key]['expressstate'] = "无信息";
  5145. }
  5146. else if($value['expressstate'] == 2)
  5147. {
  5148. $info_list[$key]['expressstate'] = "已取件";
  5149. }
  5150. else if($value['expressstate'] == 3)
  5151. {
  5152. $info_list[$key]['expressstate'] = "在途中";
  5153. }
  5154. else if($value['expressstate'] == 4)
  5155. {
  5156. $info_list[$key]['expressstate'] = "到达目的地国";
  5157. }
  5158. else if($value['expressstate'] == 5)
  5159. {
  5160. $info_list[$key]['expressstate'] = "即将派送";
  5161. }
  5162. else if($value['expressstate'] == 6)
  5163. {
  5164. $info_list[$key]['expressstate'] = "已签收";
  5165. }
  5166. else if($value['expressstate'] == 1)
  5167. {
  5168. $info_list[$key]['expressstate'] = "派送异常";
  5169. }
  5170. $info_list[$key]['wlfstime'] = date('Y-m-d H:i:s',$value['wlfstime']);
  5171. $express = $this->express->read($value['express']);
  5172. $info_list[$key]['express'] = $express['servicename'];
  5173. $info_list[$key]['excontent'] = str_replace('<br />','',$value['excontent']);
  5174. }
  5175. }
  5176. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5177. $titlename = "<table border=1>
  5178. <tr>
  5179. <td>订单号</td>
  5180. <td>编号</td>
  5181. <td>收件人国家</td>
  5182. <td>出库状态</td>
  5183. <td>出库时间</td>
  5184. <td>物流状态</td>
  5185. <td>快递公司</td>
  5186. <td>运单号</td>
  5187. <td>物流备注</td>
  5188. <td>订单备注</td>
  5189. <td>仓库品名</td>
  5190. <td>发送时间</td>
  5191. <td>邮箱</td>
  5192. <td>电话</td>
  5193. <td>邮件发送</td>
  5194. <td>错误提示</td>
  5195. <td>物流信息</td>
  5196. </tr>
  5197. </table>";
  5198. $filename = $title.".xls";
  5199. $tail = "\n";
  5200. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  5201. }
  5202. public function _waybillemail()
  5203. {
  5204. $user = $this->user->get_api($_SESSION['api']);
  5205. if($user)
  5206. {
  5207. $fgshop = "";$sid = "";
  5208. $user = explode('|',trim($user['shop'],'|'));
  5209. foreach ($user as $value)
  5210. {
  5211. $fgshop .= " shop = ".$value." or";
  5212. $sid .= " id = ".$value." or";
  5213. }
  5214. }
  5215. $post = $this->input->post(NULL, TRUE);
  5216. if(isset($post['page']))
  5217. {
  5218. $page = $this->input->post('page',true);
  5219. $perpage = $this->input->post('perpage',true);
  5220. $timetk = $this->input->post('timetk',true);
  5221. $timetj = $this->input->post('timetj',true);
  5222. $shop = $this->input->post('shop',true);
  5223. $expressstate = $this->input->post('expressstate',true);
  5224. $fs = $this->input->post('fs',true);
  5225. $state = $this->input->post('state',true);
  5226. $express = $this->input->post('express',true);
  5227. $orderinfo = $this->input->post('orderinfo',true);
  5228. $number = $this->input->post('number',true);
  5229. $waybill = $this->input->post('waybill',true);
  5230. $dlzemail = $this->input->post('dlzemail',true);
  5231. $xztime = $this->input->post('xztime',true);
  5232. $timetk = strtotime($timetk);
  5233. $timetj = strtotime($timetj);
  5234. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5235. if($timetk && $timetj)
  5236. {
  5237. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5238. }
  5239. $order_str = $xztime." desc";
  5240. if($shop)
  5241. {
  5242. $where .= " and shop = '$shop'";
  5243. }
  5244. if($expressstate)
  5245. {
  5246. $where .= " and expressstate = '$expressstate'";
  5247. }
  5248. if($state)
  5249. {
  5250. $where .= " and state = '$state'";
  5251. }
  5252. if($express)
  5253. {
  5254. $where .= " and express = '$express'";
  5255. }
  5256. if($orderinfo)
  5257. {
  5258. $where .= " and orderinfo = '$orderinfo'";
  5259. }
  5260. if($number)
  5261. {
  5262. $where .= " and number = '$number'";
  5263. }
  5264. if($waybill)
  5265. {
  5266. $where .= " and waybill = '$waybill'";
  5267. }
  5268. if($dlzemail != '')
  5269. {
  5270. $where .= " and dlzemail = '$dlzemail'";
  5271. }
  5272. if(empty($page))
  5273. {
  5274. $start = 0;
  5275. $perpage = 1;
  5276. }
  5277. else
  5278. {
  5279. $start = ($page - 1)*$perpage;
  5280. }
  5281. //取得信息列表
  5282. $info_list = $this->fullordertt->find_all($where,'id,shop,orderinfo,number,country,library,librarytime,express,waybill,dlzemail,dlzemailtime',$order_str,$start,$perpage);
  5283. //格式化数据
  5284. foreach ($info_list as $key=>$value)
  5285. {
  5286. $shop = $this->shop->read($value['shop']);
  5287. $info_list[$key]['shop'] = $shop['shopname'];
  5288. $country = $this->country->read($value['country']);
  5289. $info_list[$key]['country'] = $country['name'];
  5290. //$state = $this->typeclass->read($value['state']);
  5291. //$info_list[$key]['state'] = $state['title'];
  5292. if($value['library'] == 1)
  5293. {
  5294. $info_list[$key]['library'] = "未出库";
  5295. }
  5296. else if($value['library'] == 2)
  5297. {
  5298. $info_list[$key]['library'] = "已出库";
  5299. }
  5300. else if($value['library'] == 3)
  5301. {
  5302. $info_list[$key]['library'] = "已退库";
  5303. }
  5304. if($value['librarytime'] == '0')
  5305. {
  5306. $info_list[$key]['librarytime'] = '无';
  5307. }
  5308. else
  5309. {
  5310. $info_list[$key]['librarytime'] = date('Y-m-d',$value['librarytime']).'<br>'.date('H:i:s',$value['librarytime']);
  5311. }
  5312. $express = $this->express->read($value['express']);
  5313. $info_list[$key]['express'] = $express['servicename'];
  5314. if($value['dlzemail'] == '1')
  5315. {
  5316. $info_list[$key]['dlzemail'] = '发送成功';
  5317. }
  5318. else if ($value['dlzemail'] == '2')
  5319. {
  5320. $info_list[$key]['dlzemail'] = '发送失败';
  5321. }
  5322. else
  5323. {
  5324. $info_list[$key]['dlzemail'] = '';
  5325. }
  5326. $info_list[$key]['dlzemailtime'] = ($value['dlzemailtime']>0)?date('Y-m-d H:i:s',$value['dlzemailtime']):'';
  5327. }
  5328. $total = $this->fullordertt->find_count($where);
  5329. $pagenum = ceil($total/$perpage);
  5330. $over = $total-($start+$perpage);
  5331. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  5332. echo json_encode($rows);exit;
  5333. }
  5334. $notice = $this->notice->find_all("type = '2' and (".rtrim($fgshop,'or').")");
  5335. $this->data['notice'] = $notice;
  5336. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  5337. $this->data['wlshop'] = $wlshop;
  5338. $this->data['express'] = $this->express->find_all();
  5339. $this->_Template('fullordertt_waybillemail',$this->data);
  5340. }
  5341. public function _khdd()
  5342. {
  5343. $dt = 0;$fgshop = "shop = 0";$sid = 'id = 0';
  5344. if(isset($_SESSION['api']))
  5345. {
  5346. $user = $this->user->get_api($_SESSION['api']);
  5347. $usp = $user;
  5348. $fgshop = "";$sid = "";
  5349. $usersp = explode('|',trim($user['shop'],'|'));
  5350. foreach ($usersp as $value)
  5351. {
  5352. $fgshop .= " shop = ".$value." or";
  5353. $sid .= " id = ".$value." or";
  5354. }
  5355. if($user['vip'] == 1)
  5356. {
  5357. $vip = 1;
  5358. }
  5359. else
  5360. {
  5361. $vip = 0;
  5362. }
  5363. }
  5364. $post = $this->input->post(NULL, TRUE);
  5365. if(isset($_GET['excel']))
  5366. {
  5367. $page = $this->input->get('page',true);
  5368. $perpage = $this->input->get('perpage',true);
  5369. $warehouse = $this->input->get('warehouse',true);
  5370. $timetk = $this->input->get('timetk',true);
  5371. $timetj = $this->input->get('timetj',true);
  5372. $shop = $this->input->get('shop',true);
  5373. $source = $this->input->get('source',true);
  5374. $state = $this->input->get('state',true);
  5375. $review = $this->input->get('review',true);
  5376. $type = $this->input->get('type',true);
  5377. $express = $this->input->get('express',true);
  5378. $orderinfo = $this->input->get('orderinfo',true);
  5379. $user = $this->input->get('user',true);
  5380. $client = $this->input->get('name',true);
  5381. $waybill = $this->input->get('waybill',true);
  5382. $number = $this->input->get('number',true);
  5383. $email = $this->input->get('email',true);
  5384. $phone = $this->input->get('phone',true);
  5385. $dlz = $this->input->get('dlz',true);
  5386. $print = $this->input->get('print',true);
  5387. $library = $this->input->get('library',true);
  5388. $js = $this->input->get('js',true);
  5389. $exstate = $this->input->get('exstate',true);
  5390. $xztime = $this->input->get('xztime',true);
  5391. $libraryconfirm = $this->input->get('libraryconfirm',true);
  5392. $timetk = strtotime($timetk);
  5393. $timetj = strtotime($timetj);
  5394. $plorder = $this->input->get('pl',true);
  5395. $paypal = $this->input->get('paypal',true);
  5396. $zf = $this->input->get('zf',true);
  5397. $pay = $this->input->get('pay',true);
  5398. $excel = $this->input->get('excel',true);
  5399. $where = "1=1 and mergeid = 0 and (".rtrim($fgshop,'or').")";
  5400. if($warehouse)
  5401. {
  5402. $where .= " and type = '$warehouse'";
  5403. }
  5404. if($timetk && $timetj)
  5405. {
  5406. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  5407. }
  5408. if($shop)
  5409. {
  5410. $where .= " and shop = '$shop'";
  5411. }
  5412. if($source)
  5413. {
  5414. if($source == '2d')
  5415. {
  5416. $where .= " and source >= '2'";
  5417. }
  5418. else
  5419. {
  5420. $where .= " and source = '$source'";
  5421. }
  5422. }
  5423. if($state)
  5424. {
  5425. $where .= " and state = '$state'";
  5426. }
  5427. if($review)
  5428. {
  5429. $where .= " and review = '$review'";
  5430. }
  5431. if($type)
  5432. {
  5433. $where .= " and type = '$type'";
  5434. }
  5435. if($express)
  5436. {
  5437. $where .= " and express = '$express'";
  5438. }
  5439. if($orderinfo)
  5440. {
  5441. $where .= " and orderinfo = '$orderinfo'";
  5442. }
  5443. if($user)
  5444. {
  5445. $where .= " and user = '$user'";
  5446. }
  5447. if($client)
  5448. {
  5449. $where .= " and client like '%$client%'";
  5450. }
  5451. if($waybill)
  5452. {
  5453. $where .= " and waybill = '$waybill'";
  5454. }
  5455. if($number)
  5456. {
  5457. $where .= " and number = '$number'";
  5458. }
  5459. if($email)
  5460. {
  5461. $where .= " and email = '$email'";
  5462. }
  5463. if($phone)
  5464. {
  5465. $where .= " and phone like '%$phone%'";
  5466. }
  5467. if($library)
  5468. {
  5469. $where .= " and library = '$library'";
  5470. }
  5471. if($print)
  5472. {
  5473. $where .= " and print = '$print'";
  5474. }
  5475. if($dlz != '')
  5476. {
  5477. $where .= " and dlz = '$dlz'";
  5478. }
  5479. if($js)
  5480. {
  5481. $where .= " and js = '$js'";
  5482. }
  5483. if($exstate)
  5484. {
  5485. $where .= " and exstate = '$exstate'";
  5486. }
  5487. if($libraryconfirm)
  5488. {
  5489. $where .= " and libraryconfirm = '$libraryconfirm'";
  5490. }
  5491. if($paypal)
  5492. {
  5493. $where .= " and paypal = '$paypal'";
  5494. }
  5495. if($pay)
  5496. {
  5497. $where .= " and pay = '$pay'";
  5498. }
  5499. if($zf)
  5500. {
  5501. if($zf == 1)
  5502. {
  5503. $where .= " and paypal not like '%-%-%-%'";
  5504. }
  5505. else
  5506. {
  5507. $where .= " and paypal like '%-%-%-%'";
  5508. }
  5509. }
  5510. if($plorder)
  5511. {
  5512. $plorderinfo = '';$plnumber = '';$pln = 0;
  5513. $plorder = explode(',',trim($plorder,','));
  5514. foreach ($plorder as $value)
  5515. {
  5516. if(is_numeric($value))
  5517. {
  5518. $plorderinfo .= " orderinfo = ".$value." or";
  5519. }
  5520. else if($value != '')
  5521. {
  5522. $plorderinfo .= " number = '".$value."' or";
  5523. }
  5524. }
  5525. if($pln > 0)
  5526. {
  5527. $where .= " and (".rtrim($plorderinfo,'or').") and (".rtrim($plnumber,'or').")";
  5528. }
  5529. else
  5530. {
  5531. $where .= " and (".rtrim($plorderinfo,'or').")";
  5532. }
  5533. }
  5534. //数据排序
  5535. $order_str = "dtime desc";
  5536. if(empty($page))
  5537. {
  5538. $start = 0;
  5539. $perpage = 1;
  5540. }
  5541. else
  5542. {
  5543. $start = ($page - 1)*$perpage;
  5544. }
  5545. if($excel == '1')
  5546. {
  5547. $shop = array();
  5548. $shopdata = $this->shop->find_all("type = '269'");
  5549. foreach ($shopdata as $v)
  5550. {
  5551. $shop[$v['id']] = array('t'=>$v['brandname'],'z'=>0,'l'=>0,'x'=>0);//店铺名称,总客户,老客户,新客户
  5552. }
  5553. $oldnumber = 0;$newnumber = 0;
  5554. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where '.$where)->result_array();
  5555. foreach ($info_list as $key=>$v)
  5556. {
  5557. $shop[$v['shop']]['z'] += 1;
  5558. $num = $this->fullordertt->find_count("email = '".$v['email']."' and shop = '".$v['shop']."' and ".$xztime." < '$timetj'");
  5559. if($num > 1)
  5560. {
  5561. $shop[$v['shop']]['l'] += 1;
  5562. }
  5563. else
  5564. {
  5565. $shop[$v['shop']]['x'] += 1;
  5566. }
  5567. if(isset($v['email']) && $usp['excelpass'] == '1')
  5568. {
  5569. $emailpass = $this->setting->get_excelpass($v['email']);
  5570. $info_list[$key]['email'] = $emailpass;
  5571. }
  5572. }
  5573. $title = date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5574. $titlename = "<table border=1>
  5575. <tr>
  5576. <td>店铺</td>
  5577. <td>客户数</td>
  5578. <td>老客户数</td>
  5579. <td>新客户数</td>
  5580. </tr>
  5581. </table>";
  5582. $filename = $title.".xls";
  5583. $tail = "\n";
  5584. $this->excel->get_fz2($shop,$titlename,$filename,$tail);
  5585. }
  5586. else if($excel == '2' || $excel == '3')
  5587. {
  5588. $kh = array();
  5589. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5590. foreach ($info_list as $key=>$v)
  5591. {
  5592. $k = $this->fullordertt->find_all("shop = '".$v['shop']."' and email = '".$v['email']."' and ".$xztime." < '$timetj'",'name,email,dtime,shouldmoney','dtime desc');
  5593. if($excel == 2 && count($k) > 1)
  5594. {
  5595. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5596. }
  5597. if($excel == 3 && count($k) < 2)
  5598. {
  5599. $kh[] = array($k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),count($k),array_sum(array_column($k,'shouldmoney')));
  5600. }
  5601. if(isset($v['email']) && $usp['excelpass'] == '1')
  5602. {
  5603. $emailpass = $this->setting->get_excelpass($v['email']);
  5604. $info_list[$key]['email'] = $emailpass;
  5605. }
  5606. }
  5607. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5608. $titlename = "<table border=1>
  5609. <tr>
  5610. <td>名称</td>
  5611. <td>邮箱</td>
  5612. <td>最后购买时间</td>
  5613. <td>购买次数</td>
  5614. <td>购买总额</td>
  5615. </tr>
  5616. </table>";
  5617. $filename = $title.".xls";
  5618. $tail = "\n";
  5619. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5620. }
  5621. else if($excel == '4' || $excel == '5')
  5622. {
  5623. $kh = array();
  5624. $info_list = $this->db->query('select distinct shop,email from crowd_fullordertt where email != "" and '.$where)->result_array();
  5625. foreach ($info_list as $key=>$value)
  5626. {
  5627. $k = $this->fullordertt->find_all("shop = '".$value['shop']."' and email = '".$value['email']."' and ".$xztime." < '$timetj'",'orderinfo,state,product,name,email,dtime,shouldmoney','dtime desc');
  5628. if($excel == 4 && count($k) > 1)
  5629. {
  5630. foreach ($k as $v)
  5631. {
  5632. $typeclass = $this->typeclass->read($v['state']);
  5633. $kh[] = array($v['orderinfo'],$typeclass['spare'],$v['product'],$v['name'],$v['email'],date("Y-m-d H:i:s",$v['dtime']),$v['shouldmoney']);
  5634. }
  5635. }
  5636. if($excel == 5 && count($k) < 2)
  5637. {
  5638. if(!isset($k[0]['state']))
  5639. {
  5640. $typeclass = $k[0]['state'].'-数据字典无此信息';
  5641. }
  5642. else
  5643. {
  5644. $typeclass = $this->typeclass->read($k[0]['state']);
  5645. }
  5646. $kh[] = array($k[0]['orderinfo'],$typeclass['spare'],$k[0]['product'],$k[0]['name'],$k[0]['email'],date("Y-m-d H:i:s",$k[0]['dtime']),$k[0]['shouldmoney']);
  5647. }
  5648. if(isset($value['email']) && $usp['excelpass'] == '1')
  5649. {
  5650. $emailpass = $this->setting->get_excelpass($value['email']);
  5651. $info_list[$key]['email'] = $emailpass;
  5652. }
  5653. }
  5654. $title = $country['zname'].date('Y-m-d',$timetk).'-'.date('Y-m-d',$timetj);
  5655. $titlename = "<table border=1>
  5656. <tr>
  5657. <td>订单号</td>
  5658. <td>订单状态</td>
  5659. <td>产品名</td>
  5660. <td>客户名</td>
  5661. <td>客户邮箱</td>
  5662. <td>下单时间</td>
  5663. <td>订单金额</td>
  5664. </tr>
  5665. </table>";
  5666. $filename = $title.".xls";
  5667. $tail = "\n";
  5668. $this->excel->get_fz2($kh,$titlename,$filename,$tail);
  5669. }
  5670. }
  5671. }
  5672. public function _klarnadata()
  5673. {
  5674. $post = $this->input->post(NULL, TRUE);
  5675. if(isset($post['number']))
  5676. {
  5677. $number = $this->input->post('number',true);
  5678. $data = $this->fullordertt->get_number($number);
  5679. $shop = $this->shop->read($data['shop']);
  5680. $f = '';
  5681. if($data['pay'] == '23')
  5682. {
  5683. $url = 'https://api-na.klarna.com/ordermanagement/v1/orders/'.$data['paypal'];
  5684. $header[] = "Content-Type:application/json";
  5685. $header[] = "Authorization: Basic ".base64_encode($shop['klarnaname'].":".$shop['klarnapass']);
  5686. $ch = curl_init();
  5687. curl_setopt($ch, CURLOPT_URL, $url);
  5688. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5689. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5690. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5691. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5692. $res = curl_exec($ch);
  5693. curl_close($ch);
  5694. $res = json_decode($res,true);
  5695. if(isset($res['fraud_status']) && $shop['klarnaname'] != '')
  5696. {
  5697. $f = (($res['fraud_status'] == 'ACCEPTED')?1:2).'|<strong>'.$res['purchase_currency'].($res['order_amount']/100).'</strong> , '.(($res['fraud_status'] != 'ACCEPTED')?'<font style="color:#f00">'.$res['fraud_status'].'</font>':$res['fraud_status']).' , description:'.$res['initial_payment_method']['description'].' , number of installments:'.$res['initial_payment_method']['number_of_installments'].'|'.$res['billing_address']['street_address'].(($res['billing_address']['street_address2']!='')?' '.$res['billing_address']['street_address2']:'').','.$res['billing_address']['city'].','.$res['billing_address']['region'].','.$res['billing_address']['postal_code'].','.$res['billing_address']['country'].','.$res['billing_address']['given_name'].' '.$res['billing_address']['family_name'].','.$res['billing_address']['phone'].','.$res['billing_address']['email'].'|'.$res['shipping_address']['street_address'].(($res['shipping_address']['street_address2']!='')?' '.$res['shipping_address']['street_address2']:'').','.$res['shipping_address']['city'].','.$res['shipping_address']['region'].','.$res['shipping_address']['postal_code'].','.$res['shipping_address']['country'].','.$res['shipping_address']['given_name'].' '.$res['shipping_address']['family_name'].','.$res['shipping_address']['phone'].','.$res['shipping_address']['email'];
  5698. }
  5699. }
  5700. else if($data['pay'] == '22' && $shop['paypalname'] != '')
  5701. {
  5702. $f = $this->paypal->data($data['paypal'],$shop);
  5703. }
  5704. else if(($data['pay'] == '26') && $shop['afterpayname'] != '')
  5705. {
  5706. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5707. $header[] = "Accept:application/json";
  5708. $header[] = "User-Agent: Readme.io API Simulator'";
  5709. $header[] = "Authorization: Basic ".base64_encode($shop['afterpayname'].":".$shop['afterpaypass']);
  5710. $ch = curl_init();
  5711. curl_setopt($ch, CURLOPT_URL, $url);
  5712. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5713. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5714. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5715. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5716. $res = curl_exec($ch);
  5717. curl_close($ch);
  5718. $res = json_decode($res,true);
  5719. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5720. {
  5721. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  5722. $f = str_replace(',,',',',$f);
  5723. }
  5724. }
  5725. else if(($data['pay'] == '27') && $shop['clearpayname'] != '')
  5726. {
  5727. $url = 'https://global-api.afterpay.com/v2/payments?ids='.$data['paypal'];
  5728. $header[] = "Accept:application/json";
  5729. $header[] = "User-Agent: Readme.io API Simulator'";
  5730. $header[] = "Authorization: Basic ".base64_encode($shop['clearpayname'].":".$shop['clearpaypass']);
  5731. $ch = curl_init();
  5732. curl_setopt($ch, CURLOPT_URL, $url);
  5733. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5734. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5735. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5736. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5737. $res = curl_exec($ch);
  5738. curl_close($ch);
  5739. $res = json_decode($res,true);
  5740. if(isset($res['results'][0]['orderDetails']['consumer']['email']))
  5741. {
  5742. $f = $res['results'][0]['orderDetails']['consumer']['email'].'|'.$res['results'][0]['orderDetails']['billing']['line1'].','.$res['results'][0]['orderDetails']['billing']['line2'].','.$res['results'][0]['orderDetails']['billing']['area1'].','.$res['results'][0]['orderDetails']['billing']['region'].','.$res['results'][0]['orderDetails']['billing']['postcode'].','.$res['results'][0]['orderDetails']['billing']['countryCode'].','.$res['results'][0]['orderDetails']['billing']['name'].','.$res['results'][0]['orderDetails']['billing']['phoneNumber'].'|'.$res['results'][0]['orderDetails']['shipping']['line1'].','.$res['results'][0]['orderDetails']['shipping']['line2'].','.$res['results'][0]['orderDetails']['shipping']['area1'].','.$res['results'][0]['orderDetails']['shipping']['region'].','.$res['results'][0]['orderDetails']['shipping']['postcode'].','.$res['results'][0]['orderDetails']['shipping']['countryCode'].','.$res['results'][0]['orderDetails']['shipping']['name'].','.$res['results'][0]['orderDetails']['shipping']['phoneNumber'];
  5743. $f = str_replace(',,',',',$f);
  5744. }
  5745. }
  5746. else if($data['pay'] == '1211')
  5747. {
  5748. $url = 'https://api.stripe.com/v1/payment_intents/'.$data['paypal'];
  5749. $header[] = "Authorization:Bearer ".$shop['stripe'];
  5750. $ch = curl_init();
  5751. curl_setopt($ch, CURLOPT_URL, $url);
  5752. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  5753. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  5754. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  5755. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  5756. $res = curl_exec($ch);
  5757. curl_close($ch);
  5758. $res = json_decode($res,true);
  5759. $f = '';
  5760. if(isset($res['shipping']['name']))
  5761. {
  5762. $line = ($res['shipping']['address']['line2'] != '')?$res['shipping']['address']['line1'].' '.$res['shipping']['address']['line2']:$res['shipping']['address']['line1'];
  5763. $f = 'stripe|'.json_encode(array('name'=>$res['shipping']['name'],'email'=>$res['receipt_email'],'address'=>$line.','.$res['shipping']['address']['city'].','.$res['shipping']['address']['state'].','.$res['shipping']['address']['postal_code'].','.$res['shipping']['address']['country'].','.$res['shipping']['phone'],'shouldmoney'=>$res['amount']/100));
  5764. }
  5765. }
  5766. else
  5767. {
  5768. echo json_encode(array('msg'=>'此店铺没有对接信息','success'=>false));exit;
  5769. }
  5770. if($f != '')
  5771. {
  5772. if($this->fullordertt->save(array('klarnadata'=>$f),$data['id']))
  5773. {
  5774. echo json_encode(array('msg'=>'获取成功,请关闭此页重新打开','success'=>true));exit;
  5775. }
  5776. else
  5777. {
  5778. echo json_encode(array('msg'=>'写入失败,请重试','success'=>false));exit;
  5779. }
  5780. }
  5781. else
  5782. {
  5783. echo json_encode(array('msg'=>'获取失败,请稍后重试','cl'=>base64_encode($shop['afterpayname'].":".$shop['afterpaypass']),'a'=>$data['paypal'],'success'=>false));exit;
  5784. }
  5785. }
  5786. }
  5787. public function _kcyz($warehouse,$whlabel,$id,$shop,$number)
  5788. {
  5789. if(!$whlabel || $whlabel == '|')
  5790. {
  5791. return array('t'=>1,'m'=>json_encode(array('t'=>1,'msg'=>'请先添加产品信息!','success'=>false)));exit;
  5792. }
  5793. $w = $this->warehouse->read($warehouse);
  5794. if($w['zd'] != 1)
  5795. {
  5796. return 1;
  5797. }
  5798. $pp = explode('|',trim($whlabel,'|'));
  5799. $x = 0;$save = array();
  5800. foreach ($pp as $va)
  5801. {
  5802. $num = explode('-',$va);
  5803. if($number)
  5804. {
  5805. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and (shop IS NULL or shop = '')");//通用
  5806. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and (zd = '$number' or zd = '') and shop like '%,".$shop.",%'");//专属
  5807. }
  5808. else
  5809. {
  5810. $whlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and (shop IS NULL or shop = '')");//通用
  5811. $shopwhlabel = $this->whlabel->find_all("state = 0 and number = '$num[0]' and warehouse = '$warehouse' and zd = '' and shop like '%,".$shop.",%'");//专属
  5812. }
  5813. $x++;
  5814. if(count($whlabel)+count($shopwhlabel) < $num[1])
  5815. {
  5816. $save[] = $x-1;continue;//提前先加X不然出错,所以要减1
  5817. }
  5818. }
  5819. return $save;
  5820. }
  5821. public function _epod()
  5822. {
  5823. $post = $this->input->post(NULL, TRUE);
  5824. if(isset($post['number']))
  5825. {
  5826. $number = $this->input->post('number',true);
  5827. $data = $this->fullordertt->get_number($number);
  5828. if(is_file('./data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf'))
  5829. {
  5830. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].'/data/epod/'.date('Y',time()).'/epod-'.$data['waybill'].'.pdf','success'=>true));exit;
  5831. }
  5832. else
  5833. {
  5834. $epod = $this->dhl->get_epod($data);
  5835. if($epod['c'] == 1)
  5836. {
  5837. echo json_encode(array('msg'=>'http://'.$_SERVER['HTTP_HOST'].$epod['d'],'success'=>true));exit;
  5838. }
  5839. else
  5840. {
  5841. echo json_encode(array('msg'=>$epod['d'],'success'=>false));exit;
  5842. }
  5843. }
  5844. }
  5845. }
  5846. public function _zw($arg_array)
  5847. {
  5848. $arg_array = $arg_array[0];$fpdata = array();
  5849. $fullordertt = $this->fullordertt->read($arg_array);
  5850. $fullordertt['shipremarks'] = str_replace(array('<','>'),array('&lt;','&gt;'),$fullordertt['shipremarks']);
  5851. $fullordertt['parameter'] = str_replace(",","---",$fullordertt['parameter']);
  5852. $this->data['fullordertt'] = $fullordertt;
  5853. $this->data['countrys'] = $this->country->find_all();
  5854. $this->data['express'] = $this->express->find_all();
  5855. $warehouse = $this->warehouse->read($fullordertt['type']);
  5856. if(stripos($fullordertt['fpdata'],';') !== false)
  5857. {
  5858. $fpdata = explode(';',rtrim($fullordertt['fpdata'],';'));
  5859. foreach ($fpdata as $k=>$v)
  5860. {
  5861. $xxv = explode('|',$v);
  5862. if(isset($xxv[9]) && stripos($xxv[9],$warehouse['hz']) !== false && $warehouse['hz'] != '' && $warehouse['zd'] == 1)
  5863. {
  5864. $xxv['zd'] = "<p>已占单</p>";
  5865. $bdck = $warehouse['bdck'];
  5866. if(stripos($xxv[9],'~') !== false)
  5867. {
  5868. $dxxv = explode('~',trim($xxv[9],'~'));
  5869. foreach ($dxxv as $val)
  5870. {
  5871. $wzid = $this->$bdck->read(trim($val,$warehouse['hz']));
  5872. if($wzid['details'] != '')
  5873. {
  5874. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  5875. }
  5876. }
  5877. }
  5878. else
  5879. {
  5880. $wzid = $this->$bdck->read(trim($xxv[9],$warehouse['hz']));
  5881. if($wzid['details'] != '')
  5882. {
  5883. $xxv['zd'] .= '<p>位置:'.$wzid['details'].' - '.$wzid['cpid'].'</p>';
  5884. }
  5885. }
  5886. }
  5887. $fpdata[$k] = $xxv;
  5888. }
  5889. }
  5890. $this->data['fpdata'] = $fpdata;
  5891. $this->data['fpdata'] = $fpdata;
  5892. $thfpdataxs = array();
  5893. if($fullordertt['thfpdata'] != '')
  5894. {
  5895. $thfpdata = explode(';',trim($fullordertt['thfpdata'],';'));
  5896. foreach ($thfpdata as $k=>$v)
  5897. {
  5898. $thxs = explode('~',trim($v,'~'));
  5899. $thxs[0] = explode('|',trim($thxs[0],'|'));
  5900. $thxs[1] = explode('|',trim($thxs[1],'|'));
  5901. $thfpdataxs[] = array("<p>".$thxs[0][1]."<i class='fa fa-level-down'></i></p><p>".$thxs[1][1]."</p>","<p>".$thxs[0][2]."</p><p>".$thxs[1][2]."</p>","<p>旧</p><p>新</p>",$thxs[1][0]);
  5902. }
  5903. }
  5904. $this->data['thfpdata'] = $thfpdataxs;
  5905. $shop = $this->shop->read($fullordertt['shop']);
  5906. $this->data['et'] = $shop['estimaterate'];//此店铺配置预计到帐金额比例
  5907. $is = 0;
  5908. if($shop['type'] == 269)//判断是否独立站,269是独立站
  5909. {
  5910. $is = 1;
  5911. }
  5912. $this->data['is'] = $is;
  5913. //单项开始
  5914. $warehouse = $this->warehouse->read($fullordertt['warehouse']);//发货仓库
  5915. $state = $this->typeclass->read($fullordertt['state']);//订单状态
  5916. $country = $this->country->read($fullordertt['country']);//国家
  5917. if($fullordertt['capital'] == 1)
  5918. {
  5919. $capital = '暂未支付';
  5920. }
  5921. else if($fullordertt['capital'] == 2)
  5922. {
  5923. $capital = '部分支付';
  5924. }
  5925. else if($fullordertt['capital'] == 3)
  5926. {
  5927. $capital = '全部支付';
  5928. }
  5929. if($fullordertt['printtype'] == 1)
  5930. {
  5931. $printtype = '运单';
  5932. }
  5933. else if($fullordertt['printtype'] == 2)
  5934. {
  5935. $printtype = '发货单';
  5936. }
  5937. else if($fullordertt['printtype'] == 3)
  5938. {
  5939. $printtype = '不打印单据';
  5940. }
  5941. else
  5942. {
  5943. $printtype = '未选择';
  5944. }
  5945. $this->data['warehouse'] = $warehouse['title'];
  5946. $this->data['state'] = $state['title'];
  5947. $this->data['capital'] = $capital;
  5948. $this->data['country'] = $country['name'];
  5949. $this->data['printtype'] = $printtype;
  5950. //单项结束
  5951. /** 历史运单号展示并下载PDF 打印时间需要2019-3-21 0点之后有记录 **/
  5952. $downwaybill = '';$dwls = array();
  5953. $oldwaybill = explode('-',ltrim($fullordertt['oldwaybill'],'-'));
  5954. if(isset($oldwaybill[0][1]))
  5955. {
  5956. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  5957. foreach ($oldwaybill as $v)
  5958. {
  5959. $dw = explode('/',$v);
  5960. if(isset($dw[1]))
  5961. {
  5962. if(stripos($downwaybill,$dw[1]) === false)
  5963. {
  5964. $dwls[$dw[1]] = 1;
  5965. $downwaybill .= '<a href="/data/pdf/'.$dw[0].'/y-'.$dw[1].'.pdf" target="_blank">'.$dw[1].'</a>、';
  5966. }
  5967. }
  5968. }
  5969. }
  5970. if($fullordertt['printtype'] == 1)
  5971. {
  5972. if($fullordertt['waybill'] != '' && !isset($dwls[$fullordertt['waybill']]))
  5973. {
  5974. $downwaybill = '<a href="/data/pdf/'.date('Ymd',$fullordertt['printtime']).'/y-'.$fullordertt['waybill'].'.pdf" target="_blank">'.$fullordertt['waybill'].'</a>、'.$downwaybill;
  5975. }
  5976. }
  5977. $this->data['downwaybill'] = rtrim($downwaybill,'、');
  5978. /** 历史打印时间 **/
  5979. $printtime = '';
  5980. if($fullordertt['oldprinttime'])
  5981. {
  5982. $pte = explode('-',rtrim($fullordertt['oldprinttime'],'-'));
  5983. foreach ($pte as $v)
  5984. {
  5985. $printtime .= date('Y-m-d H:i:s',$v).'、';
  5986. }
  5987. }
  5988. $this->data['printtime'] = rtrim($printtime,'、');
  5989. $product = '';
  5990. $fullordertt['product'] = str_replace("'","",$fullordertt['product']);
  5991. if($fullordertt['link'] != '' && $fullordertt['source'] != '1')
  5992. {
  5993. $pt = explode(',',$fullordertt['product']);
  5994. $lk = explode(',',$fullordertt['link']);
  5995. for($i=0;$i<count($pt);$i++)
  5996. {
  5997. if(isset($lk[$i]))
  5998. {
  5999. $octs = $this->colourorderts->get_texturl($pt[$i],$lk[$i]);
  6000. }
  6001. else
  6002. {
  6003. $octs = '';
  6004. }
  6005. $a = $octs?'<font style="color:#'.$octs['colour'].'">'.$pt[$i].'</font>':$pt[$i];
  6006. //$a = (stripos($pt[$i],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($pt[$i],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($pt[$i],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($pt[$i],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($pt[$i],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($pt[$i],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($pt[$i],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($pt[$i],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($pt[$i],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$pt[$i].'</font>':$pt[$i];
  6007. if(isset($lk[$i]))
  6008. {
  6009. $product .= ($product != '')?' , <a href="'.$lk[$i].'" target="_blank">'.$a.'</a>':'<a href="'.$lk[$i].'" target="_blank">'.$a.'</a>';
  6010. }
  6011. else
  6012. {
  6013. $product .= ($product != '')?' , '.$a:$a;
  6014. }
  6015. }
  6016. }
  6017. else
  6018. {
  6019. $octs = $this->colourorderts->get_text($fullordertt['product']);
  6020. $a = $octs?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  6021. //$a = (stripos($fullordertt['product'],'Lace Front Wig Body Wave Human Hair Wigs Pre Plucked Brazilian Virgin Hair') !== false || stripos($fullordertt['product'],'Deep Wave Wig 100 Human Hair Swiss Lace Curly Hair Lace Front Wig') !== false || stripos($fullordertt['product'],'Alipearl Lace Front Wig Silky Straight 100% Virgin Human Hair') !== false || stripos($fullordertt['product'],'Long Wigs Water Wave Lace Front Wigs Natural Wave Wigs For Sale') !== false || stripos($fullordertt['product'],'Deep Wave Long Hair Wigs Lace Front Wigs Cheap Human Hair Wigs') !== false || stripos($fullordertt['product'],'Long Wigs Loose Deep Wave Lace Front Wigs For Black Women') !== false || stripos($fullordertt['product'],'Long Black Wigs Body Wave Lace Front Wigs With Baby Hair') !== false || stripos($fullordertt['product'],'Long Curly Wigs Lace Front Wigs Human Hair Lace Front Wigs') !== false || stripos($fullordertt['product'],'Blonde Skunk Stripe Hair Natural Body Wave Hairstyle Lace Wigs for Women') !== false)?'<font style="color:#F39">'.$fullordertt['product'].'</font>':$fullordertt['product'];
  6022. $product = $a;
  6023. }
  6024. $this->data['product'] = $product;
  6025. $out = $this->systemtransfer->find_all("number = '".$fullordertt['number']."'");
  6026. $outread = '';
  6027. if($out)
  6028. {
  6029. foreach ($out as $val)
  6030. {
  6031. $list = '';
  6032. $rk = explode('|',trim($val['rk'],'|'));
  6033. $rktime = explode('|',trim($val['rktime'],'|'));
  6034. $zw = array();
  6035. $t = $this->transfer->find_all("1=1");
  6036. foreach ($t as $v)
  6037. {
  6038. $zw[$v['id']] = $v['title'];
  6039. }
  6040. if($val['rk'] != '' && count($rk) > 0)
  6041. {
  6042. for($i=0;$i<count($rk);$i++)
  6043. {
  6044. if(!isset($rktime[$i]))
  6045. {
  6046. $list .= $zw[$cz[$i]];
  6047. }
  6048. else
  6049. {
  6050. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  6051. }
  6052. }
  6053. }
  6054. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  6055. }
  6056. }
  6057. else
  6058. {
  6059. $systemwigsout = $this->systemwigsout->find_all("number = '".$fullordertt['number']."'");
  6060. $outread = array();
  6061. if($systemwigsout)
  6062. {
  6063. foreach ($systemwigsout as $v)
  6064. {
  6065. if($v['czwarehouse'] == 37)
  6066. {
  6067. $outread[] = '华荣厂';
  6068. }
  6069. else if($v['czwarehouse'] == 0)
  6070. {
  6071. $outread[] = '龙盈厂';
  6072. }
  6073. $cz = explode('|',trim($v['cz'],'|'));
  6074. $cztime = explode('|',trim($v['cztime'],'|'));
  6075. $zw = $this->transfer->get_list();
  6076. if($v['cz'] != '' && count($cz) > 0)
  6077. {
  6078. for($i=0;$i<count($cz);$i++)
  6079. {
  6080. if(!isset($cztime[$i]))
  6081. {
  6082. $outread[] = $zw[$cz[$i]].' -&gt; ';
  6083. }
  6084. else
  6085. {
  6086. $outread[] = $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  6087. }
  6088. }
  6089. $outread[] = '<br>';
  6090. }
  6091. }
  6092. }
  6093. }
  6094. $klarnacolor = '';
  6095. if($fullordertt['klarnadata'] !='')
  6096. {
  6097. $klarnadata = explode('|',$fullordertt['klarnadata']);
  6098. if($klarnadata[0] == 'paypal' || $klarnadata[0] == 'stripe')
  6099. {
  6100. $klarnadata[1] = json_decode($klarnadata[1],true);
  6101. if($klarnadata[0] == 'stripe' && $klarnadata[1]['shouldmoney'] != $fullordertt['shouldmoney'] && $fullordertt['pay'] == 1211)
  6102. {
  6103. $klarnacolor = 'style="color:#F00"';
  6104. }
  6105. }
  6106. else if($klarnadata[0]!=1 && $fullordertt['pay']!=26 && $fullordertt['pay']!=27 && $fullordertt['pay']!=1211)
  6107. {
  6108. $klarnacolor = 'style="color:#F00"';
  6109. }
  6110. if($fullordertt['pay'] == 23)//klarna
  6111. {
  6112. $ToState = array('alabama'=>'AL','alaska'=>'AK','arizona'=>'AZ','arkansas'=>'AR','california'=>'CA','colorado'=>'CO','connecticut'=>'CT','delaware'=>'DE','florida'=>'FL','georgia'=>'GA','hawaii'=>'HI','idaho'=>'ID','illinois'=>'IL','indiana'=>'IN','iowa'=>'IA','kansas'=>'KS','kentucky'=>'KY','louisiana'=>'LA','maine'=>'ME','maryland'=>'MD','massachusetts'=>'MA','michigan'=>'MI','minnesota'=>'MN','mississippi'=>'MS','missouri'=>'MO','montana'=>'MT','nebraska'=>'NE','nevada'=>'NV','new hampshire'=>'NH','new jersey'=>'NJ','new mexico'=>'NM','new york'=>'NY','north carolina'=>'NC','north dakota'=>'ND','ohio'=>'OH','oklahoma'=>'OK','oregon'=>'OR','pennsylvania'=>'PA','rhode island'=>'RI','south carolina'=>'SC','south dakota'=>'SD','tennessee'=>'TN','texas'=>'TX','utah'=>'UT','vermont'=>'VT','virginia'=>'VA','washington'=>'WA','west virginia'=>'WV','wisconsin'=>'WI','wyoming'=>'WY','district of columbia'=>'DC','virgin islands'=>'VI','guam'=>'GU','puerto rico'=>'PR');
  6113. $ToState = array_flip($ToState);
  6114. $klarnadata3 = str_replace(' ','',$klarnadata[3]);
  6115. $city = str_replace(' ','',$fullordertt['city']);
  6116. $klarnadataaddress = explode($city,$klarnadata3);
  6117. if(isset($klarnadataaddress[1]))
  6118. {
  6119. $klarnadata3 = $city.$klarnadataaddress[1];
  6120. $klarnadatacolor = explode(',',$klarnadata3);
  6121. unset($klarnadatacolor[4]);
  6122. unset($klarnadatacolor[6]);
  6123. if(isset($ToState[$klarnadatacolor[1]]))
  6124. {
  6125. $klarnadatacolor[1] = ucwords($ToState[$klarnadatacolor[1]]);
  6126. }
  6127. $klarnadata['color'] = $klarnadataaddress[0].implode(",",$klarnadatacolor);
  6128. }
  6129. else
  6130. {
  6131. $klarnadata['color'] = $klarnadata3;
  6132. }
  6133. }
  6134. }
  6135. else
  6136. {
  6137. $klarnadata = '';
  6138. }
  6139. $p = explode('-',$fullordertt['paypal']);
  6140. $this->data['klarnacolor'] = $klarnacolor;
  6141. $this->data['klarnadata'] = $klarnadata;
  6142. $this->data['systemwigsout'] = $outread;
  6143. $this->_Template('fullordertt_zw',$this->data);
  6144. }
  6145. public function _dcdxyz()
  6146. {
  6147. $post = $this->input->get(NULL, TRUE);
  6148. if(isset($post['timetk']))
  6149. {
  6150. $timetk = $this->input->get('timetk',true);
  6151. $timetj = $this->input->get('timetj',true);
  6152. $timetk = strtotime($timetk);
  6153. $timetj = strtotime($timetj);
  6154. $where = "oldwaybill != ''";
  6155. if($timetk && $timetj)
  6156. {
  6157. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6158. }
  6159. //数据排序
  6160. $order_str = "dtime desc";
  6161. //取得信息列表
  6162. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,oldwaybill',$order_str);
  6163. $data = array();
  6164. foreach ($info_list as $key=>$value)
  6165. {
  6166. $ob = '';
  6167. $oldwaybill = explode('-',trim($value['oldwaybill'],'-'));
  6168. if(count($oldwaybill) < 2)
  6169. {
  6170. continue;
  6171. }
  6172. $oldwaybill = array_reverse($oldwaybill); //调整顺序
  6173. foreach ($oldwaybill as $v)
  6174. {
  6175. $dw = explode('/',$v);
  6176. if(isset($dw[1]))
  6177. {
  6178. $dwls[$dw[1]] = 1;
  6179. $ob .= $dw[1].'、';
  6180. }
  6181. }
  6182. $info_list[$key]['oldwaybill'] = trim($ob,'、');
  6183. $data[] = $info_list[$key];
  6184. }
  6185. $title = "多运单信息 ".date("Y-m-d");
  6186. $titlename = "<table border=1>
  6187. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6188. <tr>
  6189. <td>订单号</td>
  6190. <td>编号</td>
  6191. <td>运单号</td>
  6192. </tr>
  6193. </table>";
  6194. $filename = $title.".xls";
  6195. $tail = "\n";
  6196. $this->excel->get_fz2($data,$titlename,$filename,$tail);
  6197. }
  6198. }
  6199. public function _thxz()
  6200. {
  6201. $post = $this->input->get(NULL, TRUE);
  6202. if(isset($post['timetk']))
  6203. {
  6204. $timetk = $this->input->get('timetk',true);
  6205. $timetj = $this->input->get('timetj',true);
  6206. $timetk = strtotime($timetk);
  6207. $timetj = strtotime($timetj);
  6208. $where = "returndata != ''";
  6209. if($timetk && $timetj)
  6210. {
  6211. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  6212. }
  6213. //数据排序
  6214. $order_str = "dtime desc";
  6215. //取得信息列表
  6216. $info_list = $this->fullordertt->find_all($where,'orderinfo,number,returndata',$order_str);
  6217. foreach ($info_list as $key=>$value)
  6218. {
  6219. $ydh = explode('">',$value['returndata']);
  6220. $ydh = explode('</a>',$ydh[1]);
  6221. $info_list[$key]['returndata'] = $ydh[0];
  6222. $time = explode('pdf/',$value['returndata']);
  6223. $time = explode('/',$time[1]);
  6224. $info_list[$key]['time'] = $time[0];
  6225. }
  6226. $title = "退货订单信息 ".date("Y-m-d");
  6227. $titlename = "<table border=1>
  6228. <tr><th colspan='14' align='left'><h3>".$title."<h3></th></tr>
  6229. <tr>
  6230. <td>订单号</td>
  6231. <td>编号</td>
  6232. <td>退货运单号</td>
  6233. <td>退货时间</td>
  6234. </tr>
  6235. </table>";
  6236. $filename = $title.".xls";
  6237. $tail = "\n";
  6238. $this->excel->get_fz2($info_list,$titlename,$filename,$tail);
  6239. }
  6240. }
  6241. public function _ddcf()
  6242. {
  6243. $post = $this->input->post(NULL, TRUE);
  6244. if(isset($post['number']))
  6245. {
  6246. $number = $this->input->post('number',true);
  6247. $data = $this->fullordertt->get_number($number);
  6248. if(!$data)
  6249. {
  6250. echo json_encode(array('msg'=>'没有找到此订单','success'=>false));exit;
  6251. }
  6252. if($data['review'] != 1 && $data['review'] != 2)
  6253. {
  6254. echo json_encode(array('msg'=>'必须是 待审核 状态才能拆分','success'=>false));exit;
  6255. }
  6256. if($data['merge'] != 0)
  6257. {
  6258. echo json_encode(array('msg'=>'已合并的订单无法使用此拆分功能','success'=>false));exit;
  6259. }
  6260. $cfnum = explode('-',trim($number,'-'));
  6261. if(count($cfnum)> 4)
  6262. {
  6263. echo json_encode(array('msg'=>'只能在原单操作拆分','success'=>false));exit;
  6264. }
  6265. $num = $this->fullordertt->find_count("number like '".$number."%'");
  6266. $data['number'] = $data['number'].'-'.$num;
  6267. $data['orderinfo'] = $data['shop'].date('ymdHis',time()).rand(0,1);
  6268. $data['shouldmoney'] = 0;
  6269. $data['budget'] = 0;
  6270. $data['shipremarks'] = '';
  6271. $data['source'] = 1;
  6272. unset($data['id']);
  6273. unset($data['jweight']);
  6274. unset($data['fpcount']);
  6275. unset($data['returndata']);
  6276. unset($data['oldwaybill']);
  6277. unset($data['waybill']);
  6278. unset($data['printtime']);
  6279. if($this->fullordertt->insert($data))
  6280. {
  6281. echo json_encode(array('msg'=>'拆分成功!新订单编号:'.$data['number'],'success'=>true));exit;
  6282. }
  6283. else
  6284. {
  6285. echo json_encode(array('msg'=>'拆分失败,请重试','success'=>false));exit;
  6286. }
  6287. }
  6288. }
  6289. public function _cf() //合并订单拆分
  6290. {
  6291. $post = $this->input->post(NULL, TRUE);
  6292. if(isset($post['id']))
  6293. {
  6294. $id = $this->input->post('id',true);
  6295. $b = $this->fullordertt->read($id);
  6296. $order = array();
  6297. if($b['merge'] == $b['id'])
  6298. {
  6299. $data = $this->fullordertt->find_all("merge = '".$b['merge']."'");
  6300. foreach ($data as $v)
  6301. {
  6302. $a = $this->fullordertthb->get_orderinfo($v['orderinfo']);
  6303. if($a)
  6304. {
  6305. $this->fullordertt->save($a,$v['id']);
  6306. }
  6307. $order[] = $v['id'];
  6308. }
  6309. echo json_encode(array('msg'=>'拆分成功!','d'=>$order,'success'=>true));exit;
  6310. }
  6311. else
  6312. {
  6313. echo json_encode(array('msg'=>'拆分条件错误!','success'=>false));exit;
  6314. }
  6315. }
  6316. }
  6317. public function _pljzzd()
  6318. {
  6319. $post = $this->input->post(NULL, TRUE);
  6320. if(isset($post['s']))
  6321. {
  6322. $id_arr = $this->input->post('s');
  6323. $id_arr = explode(',',$id_arr);
  6324. if(!$id_arr)
  6325. {
  6326. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  6327. }
  6328. //循环删除记录
  6329. $this->db->trans_begin();
  6330. foreach ($id_arr as $value)
  6331. {
  6332. $post = $this->fullordertt->read($value);
  6333. $hbw = explode('|',trim($post['whlabel'],'|'));
  6334. $hbf = explode(';',trim($post['fpdata'],';'));
  6335. foreach ($hbw as $k=>$val)
  6336. {
  6337. $w = explode('-',$val);
  6338. $f = explode('|',$hbf[$k]);
  6339. $w[2] = "DNOTO";
  6340. $f[9] = "DNOTO";
  6341. $hbf[$k] = implode("|",$f);
  6342. $hbw[$k] = implode("-",$w);
  6343. }
  6344. $w = $this->whlabel->find_all("zd = '".$post['number']."'");
  6345. foreach ($w as $k=>$val)
  6346. {
  6347. $this->whlabel->save(array('zd'=>''),$val['id']);
  6348. }
  6349. $fpdata = implode(";",$hbf).';';
  6350. $whlabel = '|'.implode("|",$hbw).'|';
  6351. $this->fullordertt->save(array('fpdata'=>$fpdata,'whlabel'=>$whlabel),$post['id']);
  6352. }
  6353. if ($this->db->trans_status() === FALSE)
  6354. {
  6355. $this->db->trans_rollback();
  6356. }
  6357. else
  6358. {
  6359. $this->db->trans_commit();
  6360. }
  6361. echo json_encode(array('del'=>$id_arr,'msg'=>'操作成功,已暂时隐藏,可继续操作其它订单,刷新即可显示!','success'=>true));
  6362. }
  6363. }
  6364. }