Fullorderamz.php 228 KB

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