Fullorderamz.php 227 KB

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