Fullorderamz.php 230 KB

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