Fullordertt.php 226 KB

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