Fullordertt.php 232 KB

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