Fullorder.php 237 KB

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