Fullorder.php 228 KB

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