Fullorder.php 231 KB

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