Fullordertt.php 230 KB

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