Fullorderamz.php 226 KB

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