Fullordertt.php 230 KB

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