Fullordertt.php 234 KB

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