Fullordertt.php 241 KB

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