Fullorder.php 232 KB

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