Fullorder.php 236 KB

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