Fullorderxw.php 212 KB

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