Fullordertt.php 239 KB

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