Fullorder.php 229 KB

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