Fullorder.php 238 KB

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