Fullorder.php 233 KB

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