Fullordertt.php 233 KB

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