Fullorder.php 232 KB

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