Fullorder.php 228 KB

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