Fullordertt.php 240 KB

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