Fullordertt.php 230 KB

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