Fullorder.php 213 KB

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