Fullorderexcel.php 129 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Fullorderexcel 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_fullorderxw','fullorderxw');
  9. $this->load->_model('Model_fullorder_smt','fullorder_smt');
  10. $this->load->_model('Model_fullordersmt','fullordersmt');
  11. $this->load->_model('Model_fullorderamz','fullorderamz');
  12. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  13. $this->load->_model('Model_fullorderexcelclassid','fullorderexcelclassid');
  14. $this->load->_model('Model_shop','shop');
  15. $this->load->_model('Model_country','country');
  16. $this->load->_model('Model_warehouse','warehouse');
  17. $this->load->_model('Model_excel','excel');
  18. $this->load->_model('Model_notice','notice');
  19. $this->load->_model('Model_express','express');
  20. $this->load->_model('Model_api','api');
  21. $this->load->_model('Model_apismt','apismt');
  22. $this->load->_model('Model_usps','usps');
  23. $this->load->_model('Model_typeclass','typeclass');
  24. $this->load->_model('Model_systemwigsout','systemwigsout');
  25. $this->load->_model('Model_setting','setting');
  26. $this->load->_model('Model_customer','customer');
  27. $this->load->_model('Model_customersmt','customersmt');
  28. $this->load->_model('Model_orderurl','orderurl');
  29. $this->load->_model('Model_whlabel','whlabel');
  30. $this->load->_model('Model_whlabel_bh','whlabel_bh');
  31. $this->load->_model('Model_apiyy','apiyy');
  32. $this->load->_model('Model_classid','classid');
  33. $this->load->_model('Model_systemtransfer','systemtransfer');
  34. $this->load->_model('Model_transfer','transfer');
  35. $this->load->_model('Model_classid','classid');
  36. $this->load->_model('Model_whlabel_type','whlabel_type');
  37. $this->load->_model('Model_power','power');
  38. $this->load->_model('Model_productdescribe','productdescribe');
  39. $this->load->_model('Model_shopsku','shopsku');
  40. $this->load->_model('Model_is','is');
  41. $this->load->_model('Model_whlabel_qh','whlabel_qh');
  42. $this->load->_model('Model_emaildata','emaildata');
  43. $this->load->_model('Model_afspaypal','afspaypal');
  44. $this->load->_model('Model_producttitle','producttitle');
  45. $this->load->_model('Model_message','message');
  46. $this->load->_model("Model_logic_ding","logic_ding");
  47. $this->load->_model('Model_excelxh','excelxh');
  48. }
  49. //定义方法的调用规则 获取URI第二段值
  50. public function _remap($arg,$arg_array)
  51. {
  52. if($arg == 'excel')
  53. {
  54. $this->_excel();
  55. }
  56. else if($arg == 'excelhz')
  57. {
  58. $this->_excelhz();
  59. }
  60. else if($arg == 'add')
  61. {
  62. $this->_add();
  63. }
  64. else if($arg == 'edit')
  65. {
  66. $this->_edit($arg_array);
  67. }
  68. else if($arg == 'copy'){
  69. $this->_copy($arg_array);
  70. }
  71. else if($arg == 'del')
  72. {
  73. $this->_del();
  74. }
  75. else if($arg == 'rows')
  76. {
  77. $this->_rows();
  78. }
  79. else if($arg == 'waybill')
  80. {
  81. $this->_waybill($arg_array);
  82. }
  83. else if($arg == 'order')
  84. {
  85. $this->_order($arg_array);
  86. }
  87. else if($arg == 'xxpl')//线下批量导入
  88. {
  89. $this->_xxpl();
  90. }
  91. else if($arg == 'skuzh')//sku转中文
  92. {
  93. $this->_skuzh();
  94. }
  95. else if($arg == 'cs')
  96. {
  97. $this->_cs();
  98. }
  99. else if($arg == 'scwd')
  100. {
  101. $this->_scwd();
  102. }
  103. else if($arg == 'jmexcel')
  104. {
  105. $this->_jmexcel();
  106. }
  107. else if($arg == 'classid')
  108. {
  109. $this->_classid();
  110. }
  111. else if($arg == 'classidadd')
  112. {
  113. $this->_classidadd();
  114. }
  115. else if($arg == 'classidedit')
  116. {
  117. $this->_classidedit($arg_array);
  118. }
  119. else
  120. {
  121. $this->_index();
  122. }
  123. }
  124. //管理
  125. public function _index()
  126. {
  127. $post = $this->input->post(NULL, TRUE);
  128. if(isset($post['page']))
  129. {
  130. $page = $this->input->post('page',true);
  131. $perpage = $this->input->post('perpage',true);
  132. $type = $this->input->post('type',true);
  133. $where = "1=1 ";
  134. //数据排序
  135. $order_str = "id asc";
  136. if(empty($page))
  137. {
  138. $start = 0;
  139. $perpage = 1;
  140. }
  141. else
  142. {
  143. $start = ($page - 1)*$perpage;
  144. }
  145. if($type)
  146. {
  147. $where .= " and type = '$type'";
  148. }
  149. //取得信息列表
  150. $info_list = $this->fullorderexcel->find_all($where,'id,type,title',$order_str,$start,$perpage);
  151. foreach ($info_list as $k=>$v)
  152. {
  153. $classid = $this->fullorderexcelclassid->read($v['type']);
  154. $info_list[$k]['type'] = $classid['title'];
  155. $info_list[$k]['action'] = "<h9 class='window' data-h='/fullorderexcel/copy/".$v['id']."' style='color:#000'><span>复制表格</span></h9>";
  156. }
  157. $total = $this->fullorderexcel->find_count($where);
  158. $pagenum = ceil($total/$perpage);
  159. $over = $total-($start+$perpage);
  160. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  161. echo json_encode($rows);exit;
  162. }
  163. $classid = $this->fullorderexcelclassid->find_all();
  164. $this->data['classid'] = $classid;
  165. $this->_Template('fullorderexcel',$this->data);
  166. }
  167. //添加
  168. public function _add()
  169. {
  170. $post = $this->input->post(NULL, TRUE);
  171. if(isset($post['title']))
  172. {
  173. $post['title'] = $this->input->post('title',true);
  174. $post['type'] = $this->input->post('type',true);
  175. $post['content'] = $this->input->post('content',true);
  176. $post['contentzh'] = $this->input->post('contentzh',true);
  177. $addid = $this->fullorderexcel->insert($post);
  178. if($addid)
  179. {
  180. $adminid = $this->power->read(1);
  181. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  182. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  183. }
  184. else
  185. {
  186. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  187. }
  188. }
  189. $classid = $this->fullorderexcelclassid->find_all();
  190. $this->data['classid'] = $classid;
  191. $this->_Template('fullorderexcel_add',$this->data);
  192. }
  193. //修改
  194. public function _edit($arg_array)
  195. {
  196. $post = $this->input->post(NULL, TRUE);
  197. if(isset($post['id']))
  198. {
  199. $id = $this->input->post('id',true);
  200. $post['title'] = $this->input->post('title',true);
  201. $post['type'] = $this->input->post('type',true);
  202. $post['content'] = $this->input->post('content',true);
  203. $post['contentzh'] = $this->input->post('contentzh',true);
  204. if($this->fullorderexcel->save($post,$id))
  205. {
  206. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  207. }
  208. else
  209. {
  210. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  211. }
  212. }
  213. $arg_array = $arg_array[0];
  214. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  215. $this->data['fullorderexcel'] = $fullorderexcel;
  216. $classid = $this->fullorderexcelclassid->find_all();
  217. $this->data['classid'] = $classid;
  218. $this->_Template('fullorderexcel_edit',$this->data);
  219. }
  220. public function _copy($arg_array)
  221. {
  222. $post = $this->input->post(NULL, TRUE);
  223. if(isset($post['id']))
  224. {
  225. $post['title'] = $this->input->post('title',true);
  226. $post['type'] = $this->input->post('type',true);
  227. $post['content'] = $this->input->post('content',true);
  228. $post['contentzh'] = $this->input->post('contentzh',true);
  229. unset($post['id']);
  230. $addid =$this->fullorderexcel->insert($post);
  231. if($addid)
  232. {
  233. $adminid = $this->power->read(1);
  234. $this->power->save(array("excelid"=>$adminid['excelid'].$addid.'|',"exceltext"=>$adminid['exceltext'].$post['title'].'|'),$adminid['id']);
  235. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  236. }
  237. else
  238. {
  239. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  240. }
  241. }
  242. $arg_array = $arg_array[0];
  243. $fullorderexcel = $this->fullorderexcel->read($arg_array);
  244. $this->data['fullorderexcel'] = $fullorderexcel;
  245. $classid = $this->fullorderexcelclassid->find_all();
  246. $this->data['classid'] = $classid;
  247. $this->_Template('fullorderexcel_copy',$this->data);
  248. }
  249. //删除
  250. public function _del()
  251. {
  252. $post = $this->input->post(NULL, TRUE);
  253. if(isset($post['s']))
  254. {
  255. $id_arr = $this->input->post('s');
  256. $id_arr = explode(',',$id_arr);
  257. if(!$id_arr)
  258. {
  259. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  260. }
  261. //循环删除记录
  262. foreach ($id_arr as $v)
  263. {
  264. $this->fullorderexcel->remove($v);
  265. }
  266. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  267. }
  268. }
  269. //获取数据
  270. public function _rows()
  271. {
  272. $post = $this->input->post(NULL, TRUE);
  273. if(isset($post['id']))
  274. {
  275. $id = $this->input->post('id',true);
  276. $fullorderexcel = $this->fullorderexcel->read($id);
  277. $content = explode('|',rtrim($fullorderexcel['content'],'|'));
  278. $contentzh = explode('|',rtrim($fullorderexcel['contentzh'],'|'));
  279. $data = array();
  280. for($i=0;$i<count($content);$i++)
  281. {
  282. $a = explode('-',$content[$i]);
  283. $b = explode('-',$contentzh[$i]);
  284. $data[] = array(0=>$a[1],1=>$b[1]);
  285. }
  286. echo json_encode(array('rows'=>($data),'success'=>true));
  287. }
  288. }
  289. //导出订单excel
  290. public function _excel()
  291. {
  292. $fgshop = "";$sid = "";$excelshop="";
  293. if(isset($_SESSION['api']))
  294. {
  295. $user = $this->user->get_api($_SESSION['api']);
  296. $usp = $user;
  297. $usersp = explode('|',trim($user['shop'],'|'));
  298. foreach ($usersp as $value)
  299. {
  300. $fgshop .= " shop = ".$value." or";
  301. $sid .= " id = ".$value." or";
  302. }
  303. $userexcel = explode('|',trim($user['excelshop'],'|'));
  304. if($user['excelshop'] == '')
  305. {
  306. echo "没有下载权限";exit;
  307. }
  308. foreach ($userexcel as $value)
  309. {
  310. $excelshop .= " shop = ".$value." or";
  311. }
  312. if($excelshop != "")
  313. {
  314. $excelshop = "(".rtrim($excelshop,'or').")";
  315. }
  316. }
  317. if(isset($_GET['fexcel']))
  318. {
  319. $typeclass = array();
  320. $tclass = $this->typeclass->find_all();
  321. foreach ($tclass as $v)
  322. {
  323. $typeclass[$v['id']] = $v;
  324. }
  325. $dowid = $this->input->get('a');
  326. $wid = "";
  327. if($dowid != "")
  328. {
  329. $id_arr = explode(',',rtrim($dowid,','));
  330. $wid .= " id = 0 or";
  331. foreach ($id_arr as $v)
  332. {
  333. $wid .= " id = '$v' or";
  334. }
  335. $wid = " and".rtrim($wid,'or');
  336. }
  337. $fexcel = $this->input->get('fexcel',true);
  338. $page = $this->input->get('page',true);
  339. $perpage = $this->input->get('perpage',true);
  340. $warehouse = $this->input->get('warehouse',true);
  341. $timetk = $this->input->get('timetk',true);
  342. $timetj = $this->input->get('timetj',true);
  343. $shop = $this->input->get('shop',true);
  344. $source = $this->input->get('source',true);
  345. $state = $this->input->get('state',true);
  346. $review = $this->input->get('review',true);
  347. $type = $this->input->get('type',true);
  348. $express = $this->input->get('express',true);
  349. $orderinfo = $this->input->get('orderinfo',true);
  350. $user = $this->input->get('user',true);
  351. $client = $this->input->get('name',true);
  352. $waybill = $this->input->get('waybill',true);
  353. $number = $this->input->get('number',true);
  354. $email = $this->input->get('email',true);
  355. $dlz = $this->input->get('dlz',true);
  356. $library = $this->input->get('library',true);
  357. $libraryconfirm = $this->input->get('libraryconfirm',true);
  358. $print = $this->input->get('print',true);
  359. $timetkk = $this->input->get('timetkk',true);
  360. $timetjj = $this->input->get('timetjj',true);
  361. $xztime = $this->input->get('xztime',true);
  362. $country = $this->input->get('country',true);
  363. $zf = $this->input->get('zf',true);
  364. $pay = $this->input->get('pay',true);
  365. $phone = $this->input->get('phone',true);
  366. $so = $this->input->get('so',true);
  367. $sfxh = $this->input->get('sfxh',true);
  368. $xdcs = $this->input->get('xdcs',true);
  369. $xdcs = $this->input->get('xdcs',true);
  370. $dbapi = $this->input->get('dbapi',true);
  371. $dbapinocc = $this->input->get('dbapinocc',true);
  372. $orderurl = $this->input->get('orderurl',true);
  373. $timetk = strtotime($timetk);
  374. $timetj = strtotime($timetj);
  375. $timetkk = strtotime($timetkk);
  376. $timetjj = strtotime($timetjj);
  377. $productid = $this->input->get('productid',true);
  378. $px = $this->input->get('px',true);
  379. $fexcel = $this->fullorderexcel->read($fexcel);
  380. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  381. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  382. if($warehouse)
  383. {
  384. $where .= " and type = '$warehouse'";
  385. }
  386. if($xztime)
  387. {
  388. if($timetk && $timetj)
  389. {
  390. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  391. }
  392. if($timetkk && $timetjj)
  393. {
  394. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  395. }
  396. }
  397. else
  398. {
  399. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  400. }
  401. if($productid){
  402. $where .= " and extra_price IS NOT NULL and JSON_SEARCH(extra_price, 'one', '".$productid."', NULL, '$[*].product_id') IS NOT NULL";
  403. }
  404. if($library)
  405. {
  406. $where .= " and library = '$library'";
  407. }
  408. if($print)
  409. {
  410. $where .= " and print = '$print'";
  411. }
  412. if($shop)
  413. {
  414. $where .= " and shop = '$shop'";
  415. }
  416. if($source)
  417. {
  418. if($source == '2d')
  419. {
  420. $where .= " and source >= '2'";
  421. }
  422. else
  423. {
  424. $where .= " and source = '$source'";
  425. }
  426. }
  427. if($state)
  428. {
  429. $where .= " and state = '$state'";
  430. }
  431. if($review)
  432. {
  433. $where .= " and review = '$review'";
  434. }
  435. if($type)
  436. {
  437. $where .= " and type = '$type'";
  438. }
  439. if($express)
  440. {
  441. $where .= " and express = '$express'";
  442. }
  443. if($orderinfo)
  444. {
  445. $where .= " and orderinfo = '$orderinfo'";
  446. }
  447. if($user)
  448. {
  449. $where .= " and user = '$user'";
  450. }
  451. if($client)
  452. {
  453. $where .= " and client like '%$client%'";
  454. }
  455. if($waybill)
  456. {
  457. $where .= " and waybill = '$waybill'";
  458. }
  459. if($number)
  460. {
  461. $where .= " and number = '$number'";
  462. }
  463. if($email)
  464. {
  465. $where .= " and email = '$email'";
  466. }
  467. if($country)
  468. {
  469. $where .= " and country = '$country'";
  470. }
  471. if($dlz)
  472. {
  473. $where .= " and waybill != '' and dlz = 0";
  474. }
  475. if($libraryconfirm)
  476. {
  477. $where .= " and libraryconfirm = '$libraryconfirm'";
  478. }
  479. if($so)
  480. {
  481. $where .= " and shipremarks like '%$so%'";
  482. }
  483. if($pay)
  484. {
  485. $where .= " and pay = '$pay'";
  486. }
  487. if($phone)
  488. {
  489. $where .= " and phone = '$phone'";
  490. }
  491. if($sfxh != '')
  492. {
  493. $where .= " and sfxh = '$sfxh'";
  494. }
  495. if($orderurl)
  496. {
  497. $url = $this->orderurl->read($orderurl);
  498. $where .= " and link like '%".$url['url']."%'";
  499. }
  500. if($zf)
  501. {
  502. if($zf == 1)
  503. {
  504. $where .= " and paypal not like '%-%-%-%'";
  505. }
  506. else
  507. {
  508. $where .= " and paypal like '%-%-%-%'";
  509. }
  510. }
  511. $sj = $this->input->get('sj',true);
  512. if($sj)
  513. {
  514. $sj = $this->input->get('sj',true);
  515. }
  516. else
  517. {
  518. $sj = $classid['type'];
  519. }
  520. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  521. foreach ($fexceleq as $k=>$v)
  522. {
  523. $fexceleq[$k] = explode('-',$v);
  524. $num[$k] = $fexceleq[$k][0];
  525. }
  526. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  527. $feq = "";$kong = array();$sku9610 = ''; $goods_sku_list = [];
  528. foreach ($fexceleq as $k=>$v)
  529. {
  530. if(isset($v[1]))
  531. {
  532. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  533. {
  534. $feq .= 'klarnadata,';
  535. }
  536. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  537. {
  538. $feq .= 'fpdata,';
  539. }
  540. if(in_array($v[1],['gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata','lowefpdata'])){
  541. $goods_sku_list[] = $v[1];
  542. continue;
  543. }
  544. if($v[1] != 'kong')//空值去除
  545. {
  546. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  547. {
  548. if($v[1] == '9610sku')
  549. {
  550. $sku9610 = 1;
  551. }
  552. if($sj == 'fullordersmt')
  553. {
  554. $v[1] = 'sku';
  555. }
  556. else
  557. {
  558. $v[1] = 'issku';
  559. }
  560. }
  561. $feq .= $v[1].',';
  562. }
  563. else
  564. {
  565. $kong[$v[0]] = 1;
  566. }
  567. }
  568. }
  569. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  570. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  571. if(strpos($feq,'subtotal')!= false){
  572. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  573. }
  574. if(strpos($feq,'rowtotal')!= false){
  575. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  576. }
  577. if(strpos($feq,'product_id')!= false){
  578. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  579. }
  580. }
  581. //添加订单前缀
  582. $shopqz_list = [];
  583. if(strpos($feq,'shopqz') !== false){
  584. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  585. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  586. $shopqz_list = array_column($shop_list,'shortname','id');
  587. }
  588. $tt_cate_one = [];
  589. $tt_cate_two = [];
  590. if($sj == 'fullordertt'){
  591. if(strpos($feq,'ttcateone')!== false){
  592. $feq = str_replace('ttcateone,',"cate_one as ttcateone,",$feq);
  593. $tt_cate_one = $this->fullordertt->getCateOne();
  594. $tt_cate_two = $this->fullordertt->getCateTwo();
  595. }
  596. if(strpos($feq,'ttcatetwo')!== false){
  597. $feq = str_replace('ttcatetwo,',"cate_two as ttcatetwo,",$feq);
  598. }
  599. }
  600. //$dbapi_nocc
  601. if(strpos($feq,'dbapinocc')!= false){
  602. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  603. }
  604. //商品的规格展示 如果前面没有fpdata 需要加上
  605. if(count($goods_sku_list) > 0){
  606. if(strpos($feq,'fpdata,') === false){
  607. $feq = "fpdata,".$feq;
  608. }
  609. }
  610. $typeclass_lpdl = [];
  611. //料品大类
  612. if(strpos($feq,'lpdl')!= false){
  613. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  614. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  615. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  616. }
  617. $typeclass_lhdycc = [];
  618. //料号对应尺寸
  619. if(strpos($feq,'lhdycc')!= false){
  620. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  621. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  622. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  623. }
  624. $feq = rtrim($feq,',');
  625. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  626. foreach ($fexcelzhw as $k=>$v)
  627. {
  628. $fexcelzhw[$k] = explode('-',$v);
  629. $numb[$k] = $fexcelzhw[$k][0];
  630. }
  631. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  632. $fexcelzh = array();
  633. foreach ($fexcelzhw as $k=>$v)
  634. {
  635. $fexcelzh[] = $v[1];
  636. }
  637. if($px)
  638. {
  639. $order_str = $px." desc";
  640. }
  641. else
  642. {
  643. $order_str = "id desc";
  644. }
  645. // if($_GET['fexcel'] == '157'){
  646. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  647. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  648. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  649. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  650. // }
  651. //取得信息列表
  652. $info_list = $this->$sj->find_all($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str);
  653. //格式化数据
  654. $i = 1;$shouldmoney = 0;$hl=1;
  655. foreach ($info_list as $key=>$value)
  656. {
  657. $data = $this->$sj->read($value['id']);
  658. $data = str_replace(array("'"),array("’"),$data);
  659. if(isset($value['email']) && $usp['excelpass'] == '1')
  660. {
  661. $emailpass = $this->setting->get_excelpass($value['email']);
  662. $info_list[$key]['email'] = $emailpass;
  663. }
  664. if(isset($value['phone']) && $usp['excelpass'] == '1')
  665. {
  666. $phonepass = $this->setting->get_excelpass($value['phone']);
  667. $info_list[$key]['phone'] = $phonepass;
  668. }
  669. if(isset($value['currencytitle']))
  670. {
  671. if($value['currencytitle'] != "CNY")
  672. {
  673. $hl=$value['hl'];
  674. }
  675. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  676. $budget=$budget+($value['budget']*$hl);
  677. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  678. $refund=$refund+($value['refund']*$hl);
  679. }
  680. if(isset($value['shop']))
  681. {
  682. $shop = $this->shop->read($value['shop']);
  683. $info_list[$key]['shop'] = $shop['shopname'];
  684. }
  685. if(isset($value['dtime']))
  686. {
  687. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  688. }
  689. if(isset($value['printtime']))
  690. {
  691. if($value['printtime'] > 0)
  692. {
  693. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  694. }
  695. }
  696. if(isset($value['sku']))
  697. {
  698. if($sku9610 == '1')
  699. {
  700. $aesku = explode(';',$value['sku']);
  701. $aesku = $aesku[0];
  702. $aesku = explode(':',$aesku);
  703. if(count($aesku) > 1)
  704. {
  705. $aesku = $aesku[1];
  706. $aesku = str_replace('--','~',$aesku);
  707. $aesku = explode('-',$aesku);
  708. $aesku = $aesku[0];
  709. $aesku = str_replace('~','--',$aesku);
  710. $info_list[$key]['sku'] = $aesku;
  711. }
  712. else
  713. {
  714. $info_list[$key]['sku'] = '';
  715. }
  716. }
  717. else
  718. {
  719. $info_list[$key]['sku'] = $value['sku'];
  720. }
  721. }
  722. if(isset($value['issku']))
  723. {
  724. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  725. if($sku9610 == '1')
  726. {
  727. $aesku = explode(';',$value['issku']);
  728. $aesku = $aesku[0];
  729. $aesku = str_replace('--','~',$aesku);
  730. $aesku = explode('-',$aesku);
  731. $aesku = $aesku[0];
  732. $aesku = str_replace('~','--',$aesku);
  733. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  734. $info_list[$key]['issku'] = $aesku;
  735. }
  736. else
  737. {
  738. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  739. $info_list[$key]['issku'] = $value['issku'];
  740. }
  741. }
  742. if(isset($value['subtotal'])){
  743. $tmp_sub_str = "";
  744. $subtotal_list = json_decode($value['subtotal'],true);
  745. foreach($subtotal_list as $v){
  746. if(isset($v['sub_total'])){
  747. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  748. }else{
  749. $tmp_sub_str .= "0<br>";
  750. }
  751. }
  752. $info_list[$key]['subtotal'] = $tmp_sub_str;
  753. }
  754. if(isset($value['rowtotal'])){
  755. $tmp_sub_str = "";
  756. $subtotal_list = json_decode($value['rowtotal'],true);
  757. foreach($subtotal_list as $v){
  758. if(isset($v['row_total'])){
  759. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  760. }else{
  761. $tmp_sub_str .= "0<br>";
  762. }
  763. }
  764. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  765. }
  766. if(isset($value['shopqz'])){
  767. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  768. }
  769. if(isset($value['dbapinocc'])){
  770. $jmlist_nocc = '';
  771. $classid = $this->classid->sku();
  772. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  773. foreach ($dbapi as $va)
  774. {
  775. $jm_nocc = $classid;
  776. unset($jm_nocc[14]);
  777. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  778. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  779. $ts = explode('|',trim($features,'|'));
  780. if(stripos($ts[0],',') !== false)
  781. {
  782. $ft = explode(',',$ts[0]);
  783. $features = explode('-',trim($ft[1],'-'));
  784. $features[] = $ft[0];
  785. }
  786. else
  787. {
  788. $features = explode('-',trim($ts[0],'-'));
  789. }
  790. foreach($features as $k=>$v)
  791. {
  792. if($v != 0 && isset($typeclass[$v]))
  793. {
  794. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  795. {
  796. if($typeclass[$v]['jm'])
  797. {
  798. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  799. }
  800. }
  801. }
  802. }
  803. $jm_nocc = array_filter($jm_nocc);//去除空值
  804. $jm_nocc = implode("-",$jm_nocc);
  805. $jmlist_nocc .= $jm_nocc.'<br>';
  806. }
  807. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  808. }
  809. if(isset($value['lpdl'])){
  810. $tmp_lpdl_str ="";
  811. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  812. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  813. foreach($tmp_fpdata_arr as $v){
  814. if(empty($v)){
  815. continue;
  816. }
  817. $tmp_arr = explode('-',$v);
  818. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  819. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  820. }else{
  821. $tmp_lpdl_str .= " ";
  822. }
  823. }
  824. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  825. }
  826. if(isset($value['lhdycc'])){
  827. $tmp_lhdycc_str ="";
  828. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  829. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  830. foreach($tmp_fpdata_arr as $v){
  831. if(empty($v)){
  832. continue;
  833. }
  834. if(stripos($v,',') !== false){
  835. $tmp_arr = explode(',',$v);
  836. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  837. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  838. }else{
  839. $tmp_lhdycc_str .= "异常 <br>";
  840. }
  841. }else{
  842. $tmp_lhdycc_str .= "无 <br>";
  843. }
  844. }
  845. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  846. }
  847. if(isset($value['product_id'])){
  848. $tmp_product_id = "";
  849. $product_ids = json_decode($value['product_id'],true);
  850. foreach($product_ids as $v){
  851. if(isset($v['product_id'])){
  852. $tmp_product_id .= $v['product_id']."<br>";
  853. }else{
  854. $tmp_product_id .= "<br>";
  855. }
  856. }
  857. $info_list[$key]['product_id'] = $tmp_product_id;
  858. }
  859. if(isset($value['librarytime']))
  860. {
  861. if($value['librarytime'] > 0)
  862. {
  863. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  864. }
  865. }
  866. if(isset($value['buytime']))
  867. {
  868. if($value['buytime'] > 0)
  869. {
  870. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  871. }
  872. }
  873. if(isset($value['country']))
  874. {
  875. $country = $this->country->read($value['country']);
  876. $info_list[$key]['country'] = $country['name'];
  877. }
  878. if(isset($value['street']))//暂时用街道导出州二字码
  879. {
  880. if($data['country'] == 192)//如果是美国
  881. {
  882. $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');
  883. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  884. $data['province'] = trim($data['province'],' ');
  885. if(isset($ToState[strtolower($data['province'])]))
  886. {
  887. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  888. }
  889. else
  890. {
  891. $dataprovince = '';
  892. }
  893. $info_list[$key]['street'] = $dataprovince;
  894. }
  895. else
  896. {
  897. $info_list[$key]['street'] = '';
  898. }
  899. }
  900. if(isset($value['pay']))
  901. {
  902. $pay = $this->typeclass->read($value['pay']);
  903. $info_list[$key]['pay'] = $pay['title'];
  904. }
  905. if(isset($value['type']))
  906. {
  907. $type = $this->warehouse->read($value['type']);
  908. $info_list[$key]['type'] = $type['title'];
  909. }
  910. if(isset($value['express']))
  911. {
  912. $express = $this->express->read($value['express']);
  913. if($express)
  914. {
  915. $info_list[$key]['express'] = $express['servicename'];
  916. }
  917. else
  918. {
  919. $info_list[$key]['express'] = '未选择';
  920. }
  921. }
  922. if(isset($value['ccfpdata']))
  923. {
  924. $ccfpdata = explode(';',$value['fpdata']);
  925. $inc = 0;
  926. foreach ($ccfpdata as $v)
  927. {
  928. if(stripos($v,',') !== false)
  929. {
  930. $cc = explode(',',$v);
  931. $inctype = $this->typeclass->read($cc[0]);
  932. if(is_numeric($inctype['spare']))
  933. {
  934. if($inctype['spare'] > $inc)
  935. {
  936. $inc = $inctype['spare'];
  937. }
  938. }
  939. }
  940. }
  941. $info_list[$key]['ccfpdata'] = $inc.'inch';
  942. }
  943. if(isset($value['printtype']))
  944. {
  945. if($value['printtype'] == 1)
  946. {
  947. $info_list[$key]['printtype'] = '运单';
  948. }
  949. else if($value['printtype'] == 2)
  950. {
  951. $info_list[$key]['printtype'] = '发货单';
  952. }
  953. else if($value['printtype'] == 3)
  954. {
  955. $info_list[$key]['printtype'] = '不打印单据';
  956. }
  957. else
  958. {
  959. $info_list[$key]['printtype'] = '未选择';
  960. }
  961. }
  962. if(isset($value['exstate']))
  963. {
  964. if($value['exstate'] == '99')
  965. {
  966. $info_list[$key]['exstate'] = '未获取到物流信息';
  967. }
  968. else if($value['exstate'] == '1')
  969. {
  970. $info_list[$key]['exstate'] = '已揽收';
  971. }
  972. else if($value['exstate'] == '2')
  973. {
  974. $info_list[$key]['exstate'] = '在途中';
  975. }
  976. else if($value['exstate'] == '3')
  977. {
  978. $info_list[$key]['exstate'] = '派送中';
  979. }
  980. else if($value['exstate'] == '4')
  981. {
  982. $info_list[$key]['exstate'] = '已签收';
  983. }
  984. else if($value['exstate'] == '5')
  985. {
  986. $info_list[$key]['exstate'] = '派送异常';
  987. }
  988. else
  989. {
  990. $info_list[$key]['exstate'] = '';
  991. }
  992. }
  993. if(isset($value['link']))
  994. {
  995. if($value['link'] != '')
  996. {
  997. $link = explode(',',$value['link']);
  998. $info_list[$key]['link'] = $link[0];
  999. }
  1000. else
  1001. {
  1002. $info_list[$key]['link'] = '';
  1003. }
  1004. }
  1005. if(isset($value['klarnabill']))
  1006. {
  1007. $klarnadata = explode('|',$value['klarnadata']);
  1008. if(isset($klarnadata[2]))
  1009. {
  1010. $info_list[$key]['klarnabill'] = $klarnadata[2];
  1011. }
  1012. else
  1013. {
  1014. $info_list[$key]['klarnabill'] = '';
  1015. }
  1016. }
  1017. if(isset($value['klarnaship']))
  1018. {
  1019. $klarnadata = explode('|',$value['klarnadata']);
  1020. if(isset($klarnadata[3]))
  1021. {
  1022. $info_list[$key]['klarnaship'] = $klarnadata[3];
  1023. }
  1024. else
  1025. {
  1026. $info_list[$key]['klarnaship'] = '';
  1027. }
  1028. }
  1029. if(isset($value['afterpaybill']))
  1030. {
  1031. $klarnadata = explode('|',$value['klarnadata']);
  1032. if(isset($klarnadata[1]))
  1033. {
  1034. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  1035. }
  1036. else
  1037. {
  1038. $info_list[$key]['afterpaybill'] = '';
  1039. }
  1040. }
  1041. if(isset($value['afterpayship']))
  1042. {
  1043. $klarnadata = explode('|',$value['klarnadata']);
  1044. if(isset($klarnadata[2]))
  1045. {
  1046. $info_list[$key]['afterpayship'] = $klarnadata[2];
  1047. }
  1048. else
  1049. {
  1050. $info_list[$key]['afterpayship'] = '';
  1051. }
  1052. }
  1053. if(isset($value['PPname']))
  1054. {
  1055. $info_list[$key]['PPname'] = '';
  1056. $klarnadata = explode('|',$value['klarnadata']);
  1057. if(isset($klarnadata[1]))
  1058. {
  1059. $klarnadata = json_decode($klarnadata[1],true);
  1060. if(isset($klarnadata['name']))
  1061. {
  1062. $info_list[$key]['PPname'] = $klarnadata['name'];
  1063. }
  1064. }
  1065. }
  1066. if(isset($value['PPemail']))
  1067. {
  1068. $info_list[$key]['PPemail'] = '';
  1069. $klarnadata = explode('|',$value['klarnadata']);
  1070. if(isset($klarnadata[1]))
  1071. {
  1072. $klarnadata = json_decode($klarnadata[1],true);
  1073. if(isset($klarnadata['email']))
  1074. {
  1075. if($usp['excelpass'] == '1')
  1076. {
  1077. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  1078. }
  1079. else
  1080. {
  1081. $ppemailpass = $klarnadata['email'];
  1082. }
  1083. $info_list[$key]['PPemail'] = $ppemailpass;
  1084. }
  1085. }
  1086. }
  1087. if(isset($value['PPaddress']))
  1088. {
  1089. $info_list[$key]['PPaddress'] = '';
  1090. $klarnadata = explode('|',$value['klarnadata']);
  1091. if(isset($klarnadata[1]))
  1092. {
  1093. $klarnadata = json_decode($klarnadata[1],true);
  1094. if(isset($klarnadata['address']))
  1095. {
  1096. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  1097. }
  1098. }
  1099. }
  1100. if(isset($value['klarnadata']))
  1101. {
  1102. unset($info_list[$key]['klarnadata']);
  1103. }
  1104. if(isset($value['shippingmethod']))
  1105. {
  1106. $tax = explode('Tax:',$value['shippingmethod']);
  1107. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  1108. }
  1109. if(isset($value['systemwigsout']))
  1110. {
  1111. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  1112. $outread = '';
  1113. if($out)
  1114. {
  1115. foreach ($out as $val)
  1116. {
  1117. $list = '';
  1118. $rk = explode('|',trim($val['rk'],'|'));
  1119. $rktime = explode('|',trim($val['rktime'],'|'));
  1120. $zw = array();
  1121. $t = $this->transfer->find_all("1=1");
  1122. foreach ($t as $v)
  1123. {
  1124. $zw[$v['id']] = $v['title'];
  1125. }
  1126. if($val['rk'] != '' && count($rk) > 0)
  1127. {
  1128. for($i=0;$i<count($rk);$i++)
  1129. {
  1130. if(!isset($rktime[$i]))
  1131. {
  1132. $list .= $zw[$cz[$i]];
  1133. }
  1134. else
  1135. {
  1136. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  1137. }
  1138. }
  1139. }
  1140. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  1141. }
  1142. }
  1143. else
  1144. {
  1145. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  1146. if($systemwigsout)
  1147. {
  1148. foreach ($systemwigsout as $v)
  1149. {
  1150. $outread = '';
  1151. if($v['czwarehouse'] == 37)
  1152. {
  1153. $outread .= '华荣厂';
  1154. }
  1155. else if($v['czwarehouse'] == 0)
  1156. {
  1157. $outread .= '龙盈厂';
  1158. }
  1159. $cz = explode('|',trim($v['cz'],'|'));
  1160. $cztime = explode('|',trim($v['cztime'],'|'));
  1161. $zw = $this->transfer->get_list();
  1162. if($v['cz'] != '' && count($cz) > 0)
  1163. {
  1164. for($i=0;$i<count($cz);$i++)
  1165. {
  1166. if(!isset($cztime[$i]))
  1167. {
  1168. $outread .= $zw[$cz[$i]].' -&gt; ';
  1169. }
  1170. else
  1171. {
  1172. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  1173. }
  1174. }
  1175. $outread .= '<br>';
  1176. }
  1177. }
  1178. }
  1179. }
  1180. $info_list[$key]['systemwigsout'] = $outread;
  1181. }
  1182. if(isset($value['sourcetype']))
  1183. {
  1184. if($value['sourcetype'] == '1')
  1185. {
  1186. $info_list[$key]['sourcetype'] = '网红单';
  1187. }
  1188. else if($value['sourcetype'] == '2')
  1189. {
  1190. $info_list[$key]['sourcetype'] = '批发单';
  1191. }
  1192. else if($value['sourcetype'] == '3')
  1193. {
  1194. $info_list[$key]['sourcetype'] = '线下单';
  1195. }
  1196. else if($value['sourcetype'] == '4')
  1197. {
  1198. $info_list[$key]['sourcetype'] = '售后单';
  1199. }
  1200. else if($value['sourcetype'] == '5')
  1201. {
  1202. $info_list[$key]['sourcetype'] = '其它';
  1203. }
  1204. else
  1205. {
  1206. $info_list[$key]['sourcetype'] = '';
  1207. }
  1208. }
  1209. if(isset($value['js']))
  1210. {
  1211. if($value['js'] == '0')
  1212. {
  1213. $info_list[$key]['js'] = 'Ground Advantage';
  1214. }
  1215. else if($value['js'] == '1')
  1216. {
  1217. $info_list[$key]['js'] = 'PRIORITY';
  1218. }
  1219. else if($value['js'] == '2')
  1220. {
  1221. $info_list[$key]['js'] = 'EXPRESS';
  1222. }
  1223. else if($value['js'] == '3')
  1224. {
  1225. $info_list[$key]['js'] = 'IP';
  1226. }
  1227. else if($value['js'] == '4')
  1228. {
  1229. $info_list[$key]['js'] = 'FICP';
  1230. }
  1231. }
  1232. if(isset($value['ttcateone'])){
  1233. $info_list[$key]['ttcateone'] = isset($tt_cate_one[$value['ttcateone']])?$tt_cate_one[$value['ttcateone']]:'';
  1234. }
  1235. if(isset($value['ttcatetwo'])){
  1236. $str = "";
  1237. if(isset($tt_cate_two[$value['ttcateone']])){
  1238. if(isset($tt_cate_two[$value['ttcateone']][$value['ttcatetwo']])){
  1239. $str = $tt_cate_two[$value['ttcateone']][$value['ttcatetwo']];
  1240. }
  1241. }
  1242. $info_list[$key]['ttcatetwo'] = $str;
  1243. }
  1244. if(isset($value['type']))
  1245. {
  1246. $type = $this->warehouse->read($value['type']);
  1247. $info_list[$key]['type'] = $type['title'];
  1248. }
  1249. if(isset($value['xdcs']))
  1250. {
  1251. if($sj == 'fullorder')
  1252. {
  1253. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  1254. }
  1255. else
  1256. {
  1257. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  1258. }
  1259. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  1260. }
  1261. if(isset($value['dbapi']) || isset($value['scapi']))
  1262. {
  1263. $jmlist = '';$shuliang = '';
  1264. $classid = $this->classid->sku();
  1265. $dbapi = explode(';',trim($value['fpdata'],';'));
  1266. foreach ($dbapi as $va)
  1267. {
  1268. $pm = $classid;
  1269. $jm = $classid;
  1270. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1271. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1272. $ts = explode('|',trim($features,'|'));
  1273. if(stripos($ts[0],',') !== false)
  1274. {
  1275. $ft = explode(',',$ts[0]);
  1276. $features = explode('-',trim($ft[1],'-'));
  1277. $features[] = $ft[0];
  1278. }
  1279. else
  1280. {
  1281. $features = explode('-',trim($ts[0],'-'));
  1282. }
  1283. foreach($features as $k=>$v)
  1284. {
  1285. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1286. {
  1287. if($typeclass[$v]['bm'] != '')
  1288. {
  1289. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1290. }
  1291. }
  1292. if($v != 0 && isset($typeclass[$v]))
  1293. {
  1294. if($typeclass[$v]['classid'] == 13)
  1295. {
  1296. $dj = $typeclass[$v]['title'];
  1297. }
  1298. if($typeclass[$v]['classid'] == 8)
  1299. {
  1300. $ys = $typeclass[$v]['title'];
  1301. }
  1302. if($typeclass[$v]['classid'] == 15)
  1303. {
  1304. $hx = $typeclass[$v]['title'];
  1305. }
  1306. if(isset($pm[$typeclass[$v]['classid']]))
  1307. {
  1308. if($typeclass[$v]['title'] == '9A')
  1309. {
  1310. $pm[$typeclass[$v]['classid']] = '9A';
  1311. }
  1312. else if($typeclass[$v]['title'] == '10A')
  1313. {
  1314. $pm[$typeclass[$v]['classid']] = '10A';
  1315. }
  1316. else
  1317. {
  1318. $clzh = $typeclass[$v]['zh'];
  1319. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1320. {
  1321. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1322. $clzh = $clzh[0];
  1323. }
  1324. $pm[$typeclass[$v]['classid']] = $clzh;
  1325. }
  1326. }
  1327. if(isset($jm[$typeclass[$v]['classid']]))
  1328. {
  1329. if($typeclass[$v]['jm'])
  1330. {
  1331. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1332. }
  1333. }
  1334. }
  1335. }
  1336. $jm = array_filter($jm);//去除空值
  1337. $jm = implode("-",$jm);
  1338. $jmlist .= $jm.'<br>';
  1339. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1340. $pm = array_filter($pm);//去除空值
  1341. $zh = implode(" ",$pm);
  1342. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1343. }
  1344. if(isset($value['dbapi']))
  1345. {
  1346. $info_list[$key]['dbapi'] = $jmlist;
  1347. }
  1348. else
  1349. {
  1350. $info_list[$key]['scapi'] = $shuliang;
  1351. }
  1352. }
  1353. if(isset($value['dbapi']) && isset($value['scapi']))
  1354. {
  1355. $jmlist = '';$shuliang = '';
  1356. $classid = $this->classid->sku();
  1357. $dbapi = explode(';',trim($value['fpdata'],';'));
  1358. foreach ($dbapi as $va)
  1359. {
  1360. $pm = $classid;
  1361. $jm = $classid;
  1362. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  1363. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  1364. $ts = explode('|',trim($features,'|'));
  1365. if(stripos($ts[0],',') !== false)
  1366. {
  1367. $ft = explode(',',$ts[0]);
  1368. $features = explode('-',trim($ft[1],'-'));
  1369. $features[] = $ft[0];
  1370. }
  1371. else
  1372. {
  1373. $features = explode('-',trim($ts[0],'-'));
  1374. }
  1375. foreach($features as $k=>$v)
  1376. {
  1377. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  1378. {
  1379. if($typeclass[$v]['bm'] != '')
  1380. {
  1381. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  1382. }
  1383. }
  1384. if($v != 0 && isset($typeclass[$v]))
  1385. {
  1386. if($typeclass[$v]['classid'] == 13)
  1387. {
  1388. $dj = $typeclass[$v]['title'];
  1389. }
  1390. if($typeclass[$v]['classid'] == 8)
  1391. {
  1392. $ys = $typeclass[$v]['title'];
  1393. }
  1394. if($typeclass[$v]['classid'] == 15)
  1395. {
  1396. $hx = $typeclass[$v]['title'];
  1397. }
  1398. if(isset($pm[$typeclass[$v]['classid']]))
  1399. {
  1400. if($typeclass[$v]['title'] == '9A')
  1401. {
  1402. $pm[$typeclass[$v]['classid']] = '9A';
  1403. }
  1404. else if($typeclass[$v]['title'] == '10A')
  1405. {
  1406. $pm[$typeclass[$v]['classid']] = '10A';
  1407. }
  1408. else
  1409. {
  1410. $clzh = $typeclass[$v]['zh'];
  1411. if(stripos($typeclass[$v]['zh'],'|') !== false)
  1412. {
  1413. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  1414. $clzh = $clzh[0];
  1415. }
  1416. $pm[$typeclass[$v]['classid']] = $clzh;
  1417. }
  1418. }
  1419. if(isset($jm[$typeclass[$v]['classid']]))
  1420. {
  1421. if($typeclass[$v]['jm'])
  1422. {
  1423. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  1424. }
  1425. }
  1426. }
  1427. }
  1428. $jm = array_filter($jm);//去除空值
  1429. $jm = implode("-",$jm);
  1430. $jmlist .= $jm.'<br>';
  1431. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  1432. $pm = array_filter($pm);//去除空值
  1433. $zh = implode(" ",$pm);
  1434. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  1435. }
  1436. $info_list[$key]['dbapi'] = $jmlist;
  1437. $info_list[$key]['scapi'] = $shuliang;
  1438. }
  1439. if(isset($value['cpfpdata']))
  1440. {
  1441. $fpread = '';
  1442. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  1443. foreach ($cpfpdata as $v)
  1444. {
  1445. $va = explode('|',trim($v,'|'));
  1446. if(isset($va[1])){
  1447. $fpread .= $va[1].'; ';
  1448. }else{
  1449. $fpread .="合并单没有产品异常标记";
  1450. }
  1451. }
  1452. $info_list[$key]['cpfpdata'] = $fpread;
  1453. }
  1454. if(count($goods_sku_list) > 0){
  1455. $ret_goods_sku = $this->_getGoodsInfo($value,$goods_sku_list,$typeclass);
  1456. if(in_array("gradefpdata",$goods_sku_list)){
  1457. $info_list[$key]['gradefpdata'] = trim($ret_goods_sku['gradefpdata'],"<br>");
  1458. }
  1459. if(in_array("colorfpdata",$goods_sku_list)){
  1460. $info_list[$key]['colorfpdata'] = trim($ret_goods_sku['colorfpdata'],"<br>");
  1461. }
  1462. if(in_array("densityfpdata",$goods_sku_list)){
  1463. $info_list[$key]['densityfpdata'] = trim($ret_goods_sku['densityfpdata'],"<br>");
  1464. }
  1465. if(in_array("hairnumberfpdata",$goods_sku_list)){
  1466. $info_list[$key]['hairnumberfpdata'] = trim($ret_goods_sku['hairnumberfpdata'],"<br>");
  1467. }
  1468. if(in_array("lacetypefpdata",$goods_sku_list)){
  1469. $info_list[$key]['lacetypefpdata'] = trim($ret_goods_sku['lacetypefpdata'],"<br>");
  1470. }
  1471. //lowefpdata
  1472. if(in_array("lowefpdata",$goods_sku_list)){
  1473. $info_list[$key]['lowefpdata'] = trim($ret_goods_sku['lowefpdata'],"<br>");
  1474. }
  1475. }
  1476. unset($info_list[$key]['id']);
  1477. unset($info_list[$key]['fpdata']);
  1478. }
  1479. $fzh = "";
  1480. foreach ($fexcelzh as $v)
  1481. {
  1482. $fzh .= "<td>".$v."</td>";
  1483. }
  1484. $data = array($shouldmoney.' CNY');
  1485. $title = $fexcel['title'].'-'.date('Ymd',time());
  1486. $titlename = "<table border=1>
  1487. <tr>"
  1488. .$fzh.
  1489. "</tr>
  1490. </table>";
  1491. $tail = "\n";
  1492. $filename = $title.".xls";
  1493. $this->excelxh->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1494. }
  1495. }
  1496. //根据fpdata获取商品sku属性
  1497. private function _getGoodsInfo($value,$goods_sku_list,$typeclass){
  1498. $tmp_goods = explode(';',trim($value['fpdata'],';'));
  1499. $sku_gradefpdata_str = $sku_colorfpdata_str = $sku_densityfpdata_str = $sku_hairnumberfpdata_str = $sku_lacetypefpdata_str = $sku_lowefpdata_str = "";
  1500. foreach($tmp_goods as $tmp_goods_item){
  1501. $dq_goods_item = explode('|',trim($tmp_goods_item,'|'));
  1502. //'gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata'
  1503. $ddq_goods_item = explode('-',trim($dq_goods_item[0],'-'));
  1504. $now_good_sku_info = [];
  1505. foreach($ddq_goods_item as $ll){
  1506. if(!empty($typeclass[$ll])){
  1507. $now_good_sku_info[$typeclass[$ll]['classid']] = empty($typeclass[$ll]['jm'])? " --" : $typeclass[$ll]['jm'];
  1508. }
  1509. }
  1510. if(isset($now_good_sku_info[13])){
  1511. $sku_gradefpdata_str .= $now_good_sku_info[13]."<br/>";
  1512. }else{
  1513. $sku_gradefpdata_str .= " -- <br/>";
  1514. }
  1515. if(isset($now_good_sku_info[8])){
  1516. $sku_colorfpdata_str .= $now_good_sku_info[8]."<br/>";
  1517. }else{
  1518. $sku_colorfpdata_str .= " -- <br/>";
  1519. }
  1520. if(isset($now_good_sku_info[10])){
  1521. $sku_densityfpdata_str .= $now_good_sku_info[10]."<br/>";
  1522. }else{
  1523. $sku_densityfpdata_str .= " -- <br/>";
  1524. }
  1525. if(isset($now_good_sku_info[43])){
  1526. $sku_hairnumberfpdata_str .= $now_good_sku_info[43]."<br/>";
  1527. }else{
  1528. $sku_hairnumberfpdata_str .= " -- <br/>";
  1529. }
  1530. if(isset($now_good_sku_info[18])){
  1531. $sku_lacetypefpdata_str .= $now_good_sku_info[18]."<br/>";
  1532. }else{
  1533. $sku_lacetypefpdata_str .= " -- <br/>";
  1534. }
  1535. if(isset($now_good_sku_info[15])){
  1536. $sku_lowefpdata_str .= $now_good_sku_info[15]."<br/>";
  1537. }else{
  1538. $sku_lowefpdata_str .= " -- <br/>";
  1539. }
  1540. // if($typeclass[$ll]['classid'] == 13){
  1541. // //等级
  1542. // $sku_gradefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1543. // }elseif($typeclass[$ll]['classid'] == 8){
  1544. // //颜色
  1545. // $sku_colorfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1546. // }elseif($typeclass[$ll]['classid'] == 10){
  1547. // //密度
  1548. // $sku_densityfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1549. // }elseif($typeclass[$ll]['classid'] == 43){
  1550. // //人发头套编码
  1551. // $sku_hairnumberfpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1552. // }elseif($typeclass[$ll]['classid'] == 18){
  1553. // //头套种类
  1554. // $sku_lacetypefpdata_str .= empty($typeclass[$ll]['title'])? " --<br/>" : $typeclass[$ll]['title']."<br/>";
  1555. // }
  1556. }
  1557. return [
  1558. 'gradefpdata' => trim($sku_gradefpdata_str,"<br/>"),
  1559. 'colorfpdata' => trim($sku_colorfpdata_str,"<br/>"),
  1560. 'densityfpdata' => trim($sku_densityfpdata_str,"<br/>"),
  1561. 'hairnumberfpdata' => trim($sku_hairnumberfpdata_str,"<br/>"),
  1562. 'lacetypefpdata' => trim($sku_lacetypefpdata_str,"<br/>"),
  1563. 'lowefpdata'=>trim($sku_lowefpdata_str,"<br/>"),
  1564. ];
  1565. }
  1566. //导出订单excel
  1567. public function _excelhz()
  1568. {
  1569. $fgshop = "";$sid = "";$excelshop="";
  1570. if(isset($_SESSION['api']))
  1571. {
  1572. $user = $this->user->get_api($_SESSION['api']);
  1573. $usp = $user;
  1574. $usersp = explode('|',trim($user['shop'],'|'));
  1575. foreach ($usersp as $value)
  1576. {
  1577. $fgshop .= " shop = ".$value." or";
  1578. $sid .= " id = ".$value." or";
  1579. }
  1580. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1581. if($user['excelshop'] == '')
  1582. {
  1583. echo "没有下载权限";exit;
  1584. }
  1585. foreach ($userexcel as $value)
  1586. {
  1587. $excelshop .= " shop = ".$value." or";
  1588. }
  1589. if($excelshop != "")
  1590. {
  1591. $excelshop = "(".rtrim($excelshop,'or').")";
  1592. }
  1593. }
  1594. if(isset($_GET['fexcel']))
  1595. {
  1596. $typeclass = array();
  1597. $tclass = $this->typeclass->find_all();
  1598. foreach ($tclass as $v)
  1599. {
  1600. $typeclass[$v['id']] = $v;
  1601. }
  1602. $dowid = $this->input->get('a');
  1603. $wid = "";
  1604. if($dowid != "")
  1605. {
  1606. $id_arr = explode(',',rtrim($dowid,','));
  1607. $wid .= " id = 0 or";
  1608. foreach ($id_arr as $v)
  1609. {
  1610. $wid .= " id = '$v' or";
  1611. }
  1612. $wid = " and (".rtrim($wid,'or').") ";
  1613. }
  1614. $fexcel = $this->input->get('fexcel',true);
  1615. $page = $this->input->get('page',true);
  1616. $perpage = $this->input->get('perpage',true);
  1617. $warehouse = $this->input->get('warehouse',true);
  1618. $timetk = $this->input->get('timetk',true);
  1619. $timetj = $this->input->get('timetj',true);
  1620. $shop = $this->input->get('shop',true);
  1621. $source = $this->input->get('source',true);
  1622. $state = $this->input->get('state',true);
  1623. $review = $this->input->get('review',true);
  1624. $type = $this->input->get('type',true);
  1625. $express = $this->input->get('express',true);
  1626. $orderinfo = $this->input->get('orderinfo',true);
  1627. $user = $this->input->get('user',true);
  1628. $client = $this->input->get('name',true);
  1629. $waybill = $this->input->get('waybill',true);
  1630. $number = $this->input->get('number',true);
  1631. $email = $this->input->get('email',true);
  1632. $dlz = $this->input->get('dlz',true);
  1633. $library = $this->input->get('library',true);
  1634. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1635. $print = $this->input->get('print',true);
  1636. $timetkk = $this->input->get('timetkk',true);
  1637. $timetjj = $this->input->get('timetjj',true);
  1638. $xztime = $this->input->get('xztime',true);
  1639. $country = $this->input->get('country',true);
  1640. $zf = $this->input->get('zf',true);
  1641. $pay = $this->input->get('pay',true);
  1642. $phone = $this->input->get('phone',true);
  1643. $so = $this->input->get('so',true);
  1644. $sfxh = $this->input->get('sfxh',true);
  1645. $xdcs = $this->input->get('xdcs',true);
  1646. $xdcs = $this->input->get('xdcs',true);
  1647. $dbapi = $this->input->get('dbapi',true);
  1648. $dbapinocc = $this->input->get('dbapinocc',true);
  1649. $orderurl = $this->input->get('orderurl',true);
  1650. $timetk = strtotime($timetk);
  1651. $timetj = strtotime($timetj);
  1652. $timetkk = strtotime($timetkk);
  1653. $timetjj = strtotime($timetjj);
  1654. $px = $this->input->get('px',true);
  1655. $fexcel = $this->fullorderexcel->read($fexcel);
  1656. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  1657. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  1658. if($warehouse)
  1659. {
  1660. $where .= " and type = '$warehouse'";
  1661. }
  1662. if($xztime)
  1663. {
  1664. if($timetk && $timetj)
  1665. {
  1666. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  1667. }
  1668. if($timetkk && $timetjj)
  1669. {
  1670. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  1671. }
  1672. }
  1673. else
  1674. {
  1675. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1676. }
  1677. if($library)
  1678. {
  1679. $where .= " and library = '$library'";
  1680. }
  1681. if($print)
  1682. {
  1683. $where .= " and print = '$print'";
  1684. }
  1685. if($shop)
  1686. {
  1687. $where .= " and shop = '$shop'";
  1688. }
  1689. if($source)
  1690. {
  1691. if($source == '2d')
  1692. {
  1693. $where .= " and source >= '2'";
  1694. }
  1695. else
  1696. {
  1697. $where .= " and source = '$source'";
  1698. }
  1699. }
  1700. if($state)
  1701. {
  1702. $where .= " and state = '$state'";
  1703. }
  1704. if($review)
  1705. {
  1706. $where .= " and review = '$review'";
  1707. }
  1708. if($type)
  1709. {
  1710. $where .= " and type = '$type'";
  1711. }
  1712. if($express)
  1713. {
  1714. $where .= " and express = '$express'";
  1715. }
  1716. if($orderinfo)
  1717. {
  1718. $where .= " and orderinfo = '$orderinfo'";
  1719. }
  1720. if($user)
  1721. {
  1722. $where .= " and user = '$user'";
  1723. }
  1724. if($client)
  1725. {
  1726. $where .= " and client like '%$client%'";
  1727. }
  1728. if($waybill)
  1729. {
  1730. $where .= " and waybill = '$waybill'";
  1731. }
  1732. if($number)
  1733. {
  1734. $where .= " and number = '$number'";
  1735. }
  1736. if($email)
  1737. {
  1738. $where .= " and email = '$email'";
  1739. }
  1740. if($country)
  1741. {
  1742. $where .= " and country = '$country'";
  1743. }
  1744. if($dlz)
  1745. {
  1746. $where .= " and waybill != '' and dlz = 0";
  1747. }
  1748. if($libraryconfirm)
  1749. {
  1750. $where .= " and libraryconfirm = '$libraryconfirm'";
  1751. }
  1752. if($so)
  1753. {
  1754. $where .= " and shipremarks like '%$so%'";
  1755. }
  1756. if($pay)
  1757. {
  1758. $where .= " and pay = '$pay'";
  1759. }
  1760. if($phone)
  1761. {
  1762. $where .= " and phone = '$phone'";
  1763. }
  1764. if($sfxh != '')
  1765. {
  1766. $where .= " and sfxh = '$sfxh'";
  1767. }
  1768. if($orderurl)
  1769. {
  1770. $url = $this->orderurl->read($orderurl);
  1771. $where .= " and link like '%".$url['url']."%'";
  1772. }
  1773. if($zf)
  1774. {
  1775. if($zf == 1)
  1776. {
  1777. $where .= " and paypal not like '%-%-%-%'";
  1778. }
  1779. else
  1780. {
  1781. $where .= " and paypal like '%-%-%-%'";
  1782. }
  1783. }
  1784. $sj = $this->input->get('sj',true);
  1785. if($sj)
  1786. {
  1787. $sj = $this->input->get('sj',true);
  1788. }
  1789. else
  1790. {
  1791. $sj = $classid['type'];
  1792. }
  1793. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  1794. foreach ($fexceleq as $k=>$v)
  1795. {
  1796. $fexceleq[$k] = explode('-',$v);
  1797. $num[$k] = $fexceleq[$k][0];
  1798. }
  1799. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  1800. $feq = "";$kong = array();$sku9610 = '';$goods_sku_list = [];
  1801. foreach ($fexceleq as $k=>$v)
  1802. {
  1803. if(isset($v[1]))
  1804. {
  1805. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  1806. {
  1807. $feq .= 'klarnadata,';
  1808. }
  1809. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  1810. {
  1811. $feq .= 'fpdata,';
  1812. }
  1813. if(in_array($v[1],['gradefpdata','colorfpdata','densityfpdata','hairnumberfpdata','lacetypefpdata','lowefpdata'])){
  1814. $goods_sku_list[] = $v[1];
  1815. continue;
  1816. }
  1817. if($v[1] != 'kong')//空值去除
  1818. {
  1819. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  1820. {
  1821. if($v[1] == '9610sku')
  1822. {
  1823. $sku9610 = 1;
  1824. }
  1825. if($sj == 'fullordersmt')
  1826. {
  1827. $v[1] = 'sku';
  1828. }
  1829. else
  1830. {
  1831. $v[1] = 'issku';
  1832. }
  1833. }
  1834. $feq .= $v[1].',';
  1835. }
  1836. else
  1837. {
  1838. $kong[$v[0]] = 1;
  1839. }
  1840. }
  1841. }
  1842. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  1843. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  1844. if(strpos($feq,'subtotal')!= false){
  1845. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  1846. }
  1847. if(strpos($feq,'rowtotal')!= false){
  1848. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  1849. }
  1850. if(strpos($feq,'product_id')!= false){
  1851. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  1852. }
  1853. }
  1854. //添加订单前缀
  1855. $shopqz_list = [];
  1856. if(strpos($feq,'shopqz') !== false){
  1857. $feq = str_replace('shopqz,',"shop as shopqz,",$feq);
  1858. $shop_list = $this->shop->find_all("1 = 1","id,shortname");
  1859. $shopqz_list = array_column($shop_list,'shortname','id');
  1860. }
  1861. //$dbapi_nocc
  1862. if(strpos($feq,'dbapinocc')!= false){
  1863. $feq = str_replace('dbapinocc,',"fpdata as dbapinocc,",$feq);
  1864. }
  1865. $typeclass_lpdl = [];
  1866. //料品大类
  1867. if(strpos($feq,'lpdl')!= false){
  1868. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  1869. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  1870. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  1871. }
  1872. $typeclass_lhdycc = [];
  1873. //料号对应尺寸
  1874. if(strpos($feq,'lhdycc')!= false){
  1875. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  1876. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  1877. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  1878. }
  1879. $feq = rtrim($feq,',');
  1880. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  1881. foreach ($fexcelzhw as $k=>$v)
  1882. {
  1883. $fexcelzhw[$k] = explode('-',$v);
  1884. $numb[$k] = $fexcelzhw[$k][0];
  1885. }
  1886. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  1887. $fexcelzh = array();
  1888. foreach ($fexcelzhw as $k=>$v)
  1889. {
  1890. $fexcelzh[] = $v[1];
  1891. }
  1892. if($px)
  1893. {
  1894. $order_str = $px." desc";
  1895. }
  1896. else
  1897. {
  1898. $order_str = "id desc";
  1899. }
  1900. // if($_GET['fexcel'] == '157'){
  1901. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  1902. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  1903. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  1904. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  1905. // }
  1906. $extra = [
  1907. 'usp'=>$usp,
  1908. 'sku9610'=>$sku9610,
  1909. 'typeclass_lpdl'=>$typeclass_lpdl,
  1910. 'typeclass_lhdycc'=>$typeclass_lhdycc,
  1911. 'goods_sku_list'=>$goods_sku_list,
  1912. 'typeclass'=>$typeclass,
  1913. ];
  1914. $dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
  1915. $tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
  1916. $smt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordersmt',$extra);
  1917. $amz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorderamz',$extra);
  1918. $info_list = array_merge( $dlz_ret['info_list'],$tt_ret['info_list'],$smt_ret['info_list'],$amz_ret['info_list']);
  1919. $shouldmoney = $dlz_ret['shouldmoney']+$tt_ret['shouldmoney']+$smt_ret['shouldmoney']+$amz_ret['shouldmoney'];
  1920. $fzh = "";
  1921. foreach ($fexcelzh as $v)
  1922. {
  1923. $fzh .= "<td>".$v."</td>";
  1924. }
  1925. $data = array($shouldmoney.' CNY');
  1926. $title = $fexcel['title'].'-'.date('Ymd',time());
  1927. $titlename = "<table border=1>
  1928. <tr>"
  1929. .$fzh.
  1930. "</tr>
  1931. </table>";
  1932. $tail = "\n";
  1933. $filename = $title.".xls";
  1934. $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1935. }
  1936. }
  1937. public function _datahz($where,$field,$order_str,$sj,$extra){
  1938. $goods_sku_list = $extra['goods_sku_list'] ;
  1939. $typeclass = $extra['typeclass'];
  1940. //取得信息列表
  1941. $info_list = $this->$sj->find_all($where,$field,$order_str);
  1942. //格式化数据
  1943. $i = 1;$shouldmoney = 0;$hl=1;
  1944. $usp = $extra['usp'];
  1945. $sku9610 = $extra['sku9610'];
  1946. $typeclass_lpdl = $extra['typeclass_lpdl'];
  1947. $typeclass_lhdycc = $extra['typeclass_lhdycc'];
  1948. foreach ($info_list as $key=>$value)
  1949. {
  1950. $data = $this->$sj->read($value['id']);
  1951. $data = str_replace(array("'"),array("’"),$data);
  1952. if(isset($value['email']) && $usp['excelpass'] == '1')
  1953. {
  1954. $emailpass = $this->setting->get_excelpass($value['email']);
  1955. $info_list[$key]['email'] = $emailpass;
  1956. }
  1957. if(isset($value['phone']) && $usp['excelpass'] == '1')
  1958. {
  1959. $phonepass = $this->setting->get_excelpass($value['phone']);
  1960. $info_list[$key]['phone'] = $phonepass;
  1961. }
  1962. if(isset($value['currencytitle']))
  1963. {
  1964. if($value['currencytitle'] != "CNY")
  1965. {
  1966. $hl=$value['hl'];
  1967. }
  1968. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  1969. }
  1970. if(isset($value['shop']))
  1971. {
  1972. $shop = $this->shop->read($value['shop']);
  1973. $info_list[$key]['shop'] = $shop['shopname'];
  1974. }
  1975. if(isset($value['dtime']))
  1976. {
  1977. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  1978. }
  1979. if(isset($value['printtime']))
  1980. {
  1981. if($value['printtime'] > 0)
  1982. {
  1983. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1984. }
  1985. }
  1986. if(isset($value['sku']))
  1987. {
  1988. if($sku9610 == '1')
  1989. {
  1990. $aesku = explode(';',$value['sku']);
  1991. $aesku = $aesku[0];
  1992. $aesku = explode(':',$aesku);
  1993. if(count($aesku) > 1)
  1994. {
  1995. $aesku = $aesku[1];
  1996. $aesku = str_replace('--','~',$aesku);
  1997. $aesku = explode('-',$aesku);
  1998. $aesku = $aesku[0];
  1999. $aesku = str_replace('~','--',$aesku);
  2000. $info_list[$key]['sku'] = $aesku;
  2001. }
  2002. else
  2003. {
  2004. $info_list[$key]['sku'] = '';
  2005. }
  2006. }
  2007. else
  2008. {
  2009. $info_list[$key]['sku'] = $value['sku'];
  2010. }
  2011. }
  2012. if(isset($value['issku']))
  2013. {
  2014. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  2015. if($sku9610 == '1')
  2016. {
  2017. $aesku = explode(';',$value['issku']);
  2018. $aesku = $aesku[0];
  2019. $aesku = str_replace('--','~',$aesku);
  2020. $aesku = explode('-',$aesku);
  2021. $aesku = $aesku[0];
  2022. $aesku = str_replace('~','--',$aesku);
  2023. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  2024. $info_list[$key]['issku'] = $aesku;
  2025. }
  2026. else
  2027. {
  2028. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  2029. $info_list[$key]['issku'] = $value['issku'];
  2030. }
  2031. }
  2032. if(isset($value['subtotal'])){
  2033. $tmp_sub_str = "";
  2034. $subtotal_list = json_decode($value['subtotal'],true);
  2035. foreach($subtotal_list as $v){
  2036. if(isset($v['sub_total'])){
  2037. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  2038. }else{
  2039. $tmp_sub_str .= "0<br>";
  2040. }
  2041. }
  2042. $info_list[$key]['subtotal'] = $tmp_sub_str;
  2043. }
  2044. if(isset($value['rowtotal'])){
  2045. $tmp_sub_str = "";
  2046. $subtotal_list = json_decode($value['rowtotal'],true);
  2047. foreach($subtotal_list as $v){
  2048. if(isset($v['row_total'])){
  2049. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  2050. }else{
  2051. $tmp_sub_str .= "0<br>";
  2052. }
  2053. }
  2054. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  2055. }
  2056. if(isset($value['dbapinocc'])){
  2057. $jmlist_nocc = '';
  2058. $classid = $this->classid->sku();
  2059. $dbapi = explode(';',trim($value['dbapinocc'],';'));
  2060. foreach ($dbapi as $va)
  2061. {
  2062. $jm_nocc = $classid;
  2063. unset($jm_nocc[14]);
  2064. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2065. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2066. $ts = explode('|',trim($features,'|'));
  2067. if(stripos($ts[0],',') !== false)
  2068. {
  2069. $ft = explode(',',$ts[0]);
  2070. $features = explode('-',trim($ft[1],'-'));
  2071. $features[] = $ft[0];
  2072. }
  2073. else
  2074. {
  2075. $features = explode('-',trim($ts[0],'-'));
  2076. }
  2077. foreach($features as $k=>$v)
  2078. {
  2079. if($v != 0 && isset($typeclass[$v]))
  2080. {
  2081. if(isset($jm_nocc[$typeclass[$v]['classid']]))
  2082. {
  2083. if($typeclass[$v]['jm'])
  2084. {
  2085. $jm_nocc[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2086. }
  2087. }
  2088. }
  2089. }
  2090. $jm_nocc = array_filter($jm_nocc);//去除空值
  2091. $jm_nocc = implode("-",$jm_nocc);
  2092. $jmlist_nocc .= $jm_nocc.'<br>';
  2093. }
  2094. $info_list[$key]['dbapinocc'] = $jmlist_nocc ;
  2095. }
  2096. if(isset($value['lpdl'])){
  2097. $tmp_lpdl_str ="";
  2098. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2099. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2100. foreach($tmp_fpdata_arr as $v){
  2101. if(empty($v)){
  2102. continue;
  2103. }
  2104. $tmp_arr = explode('-',$v);
  2105. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  2106. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  2107. }else{
  2108. $tmp_lpdl_str .= " ";
  2109. }
  2110. }
  2111. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  2112. }
  2113. if(isset($value['lhdycc'])){
  2114. $tmp_lhdycc_str ="";
  2115. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  2116. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  2117. foreach($tmp_fpdata_arr as $v){
  2118. if(empty($v)){
  2119. continue;
  2120. }
  2121. if(stripos($v,',') !== false){
  2122. $tmp_arr = explode(',',$v);
  2123. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  2124. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  2125. }else{
  2126. $tmp_lhdycc_str .= "异常 <br>";
  2127. }
  2128. }else{
  2129. $tmp_lhdycc_str .= "无 <br>";
  2130. }
  2131. }
  2132. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  2133. }
  2134. if(isset($value['shopqz'])){
  2135. $info_list[$key]['shopqz'] = isset($shopqz_list[$value['shopqz']])?$shopqz_list[$value['shopqz']]:'';
  2136. }
  2137. if(isset($value['product_id'])){
  2138. $tmp_product_id = "";
  2139. $product_ids = json_decode($value['product_id'],true);
  2140. foreach($product_ids as $v){
  2141. if(isset($v['product_id'])){
  2142. $tmp_product_id .= $v['product_id']."<br>";
  2143. }else{
  2144. $tmp_product_id .= "<br>";
  2145. }
  2146. }
  2147. $info_list[$key]['product_id'] = $tmp_product_id;
  2148. }
  2149. if(isset($value['librarytime']))
  2150. {
  2151. if($value['librarytime'] > 0)
  2152. {
  2153. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2154. }
  2155. }
  2156. if(isset($value['buytime']))
  2157. {
  2158. if($value['buytime'] > 0)
  2159. {
  2160. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2161. }
  2162. }
  2163. if(isset($value['country']))
  2164. {
  2165. $country = $this->country->read($value['country']);
  2166. $info_list[$key]['country'] = $country['name'];
  2167. }
  2168. if(isset($value['street']))//暂时用街道导出州二字码
  2169. {
  2170. if($data['country'] == 192)//如果是美国
  2171. {
  2172. $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');
  2173. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  2174. $data['province'] = trim($data['province'],' ');
  2175. if(isset($ToState[strtolower($data['province'])]))
  2176. {
  2177. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  2178. }
  2179. else
  2180. {
  2181. $dataprovince = '';
  2182. }
  2183. $info_list[$key]['street'] = $dataprovince;
  2184. }
  2185. else
  2186. {
  2187. $info_list[$key]['street'] = '';
  2188. }
  2189. }
  2190. if(isset($value['pay']))
  2191. {
  2192. if(empty($value['pay'])){
  2193. $info_list[$key]['pay'] = "";
  2194. }else{
  2195. if($sj =='fullorder'){
  2196. $pay = $this->typeclass->read($value['pay']);
  2197. $info_list[$key]['pay'] = $pay['title'];
  2198. }
  2199. }
  2200. }
  2201. if(isset($value['type']))
  2202. {
  2203. $type = $this->warehouse->read($value['type']);
  2204. $info_list[$key]['type'] = $type['title'];
  2205. }
  2206. if(isset($value['express']))
  2207. {
  2208. $express = $this->express->read($value['express']);
  2209. if($express)
  2210. {
  2211. $info_list[$key]['express'] = $express['servicename'];
  2212. }
  2213. else
  2214. {
  2215. $info_list[$key]['express'] = '未选择';
  2216. }
  2217. }
  2218. if(isset($value['ccfpdata']))
  2219. {
  2220. $ccfpdata = explode(';',$value['fpdata']);
  2221. $inc = 0;
  2222. foreach ($ccfpdata as $v)
  2223. {
  2224. if(stripos($v,',') !== false)
  2225. {
  2226. $cc = explode(',',$v);
  2227. $inctype = $this->typeclass->read($cc[0]);
  2228. if(is_numeric($inctype['spare']))
  2229. {
  2230. if($inctype['spare'] > $inc)
  2231. {
  2232. $inc = $inctype['spare'];
  2233. }
  2234. }
  2235. }
  2236. }
  2237. $info_list[$key]['ccfpdata'] = $inc.'inch';
  2238. }
  2239. if(isset($value['printtype']))
  2240. {
  2241. if($value['printtype'] == 1)
  2242. {
  2243. $info_list[$key]['printtype'] = '运单';
  2244. }
  2245. else if($value['printtype'] == 2)
  2246. {
  2247. $info_list[$key]['printtype'] = '发货单';
  2248. }
  2249. else if($value['printtype'] == 3)
  2250. {
  2251. $info_list[$key]['printtype'] = '不打印单据';
  2252. }
  2253. else
  2254. {
  2255. $info_list[$key]['printtype'] = '未选择';
  2256. }
  2257. }
  2258. if(isset($value['exstate']))
  2259. {
  2260. if($value['exstate'] == '99')
  2261. {
  2262. $info_list[$key]['exstate'] = '未获取到物流信息';
  2263. }
  2264. else if($value['exstate'] == '1')
  2265. {
  2266. $info_list[$key]['exstate'] = '已揽收';
  2267. }
  2268. else if($value['exstate'] == '2')
  2269. {
  2270. $info_list[$key]['exstate'] = '在途中';
  2271. }
  2272. else if($value['exstate'] == '3')
  2273. {
  2274. $info_list[$key]['exstate'] = '派送中';
  2275. }
  2276. else if($value['exstate'] == '4')
  2277. {
  2278. $info_list[$key]['exstate'] = '已签收';
  2279. }
  2280. else if($value['exstate'] == '5')
  2281. {
  2282. $info_list[$key]['exstate'] = '派送异常';
  2283. }
  2284. else
  2285. {
  2286. $info_list[$key]['exstate'] = '';
  2287. }
  2288. }
  2289. if(isset($value['link']))
  2290. {
  2291. if($value['link'] != '')
  2292. {
  2293. $link = explode(',',$value['link']);
  2294. $info_list[$key]['link'] = $link[0];
  2295. }
  2296. else
  2297. {
  2298. $info_list[$key]['link'] = '';
  2299. }
  2300. }
  2301. if(isset($value['klarnabill']))
  2302. {
  2303. $klarnadata = explode('|',$value['klarnadata']);
  2304. if(isset($klarnadata[2]))
  2305. {
  2306. $info_list[$key]['klarnabill'] = $klarnadata[2];
  2307. }
  2308. else
  2309. {
  2310. $info_list[$key]['klarnabill'] = '';
  2311. }
  2312. }
  2313. if(isset($value['klarnaship']))
  2314. {
  2315. $klarnadata = explode('|',$value['klarnadata']);
  2316. if(isset($klarnadata[3]))
  2317. {
  2318. $info_list[$key]['klarnaship'] = $klarnadata[3];
  2319. }
  2320. else
  2321. {
  2322. $info_list[$key]['klarnaship'] = '';
  2323. }
  2324. }
  2325. if(isset($value['afterpaybill']))
  2326. {
  2327. $klarnadata = explode('|',$value['klarnadata']);
  2328. if(isset($klarnadata[1]))
  2329. {
  2330. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  2331. }
  2332. else
  2333. {
  2334. $info_list[$key]['afterpaybill'] = '';
  2335. }
  2336. }
  2337. if(isset($value['afterpayship']))
  2338. {
  2339. $klarnadata = explode('|',$value['klarnadata']);
  2340. if(isset($klarnadata[2]))
  2341. {
  2342. $info_list[$key]['afterpayship'] = $klarnadata[2];
  2343. }
  2344. else
  2345. {
  2346. $info_list[$key]['afterpayship'] = '';
  2347. }
  2348. }
  2349. if(isset($value['PPname']))
  2350. {
  2351. $info_list[$key]['PPname'] = '';
  2352. $klarnadata = explode('|',$value['klarnadata']);
  2353. if(isset($klarnadata[1]))
  2354. {
  2355. $klarnadata = json_decode($klarnadata[1],true);
  2356. if(isset($klarnadata['name']))
  2357. {
  2358. $info_list[$key]['PPname'] = $klarnadata['name'];
  2359. }
  2360. }
  2361. }
  2362. if(isset($value['PPemail']))
  2363. {
  2364. $info_list[$key]['PPemail'] = '';
  2365. $klarnadata = explode('|',$value['klarnadata']);
  2366. if(isset($klarnadata[1]))
  2367. {
  2368. $klarnadata = json_decode($klarnadata[1],true);
  2369. if(isset($klarnadata['email']))
  2370. {
  2371. if($usp['excelpass'] == '1')
  2372. {
  2373. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  2374. }
  2375. else
  2376. {
  2377. $ppemailpass = $klarnadata['email'];
  2378. }
  2379. $info_list[$key]['PPemail'] = $ppemailpass;
  2380. }
  2381. }
  2382. }
  2383. if(isset($value['PPaddress']))
  2384. {
  2385. $info_list[$key]['PPaddress'] = '';
  2386. $klarnadata = explode('|',$value['klarnadata']);
  2387. if(isset($klarnadata[1]))
  2388. {
  2389. $klarnadata = json_decode($klarnadata[1],true);
  2390. if(isset($klarnadata['address']))
  2391. {
  2392. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  2393. }
  2394. }
  2395. }
  2396. if(isset($value['klarnadata']))
  2397. {
  2398. unset($info_list[$key]['klarnadata']);
  2399. }
  2400. if(isset($value['shippingmethod']))
  2401. {
  2402. $tax = explode('Tax:',$value['shippingmethod']);
  2403. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  2404. }
  2405. if(isset($value['systemwigsout']))
  2406. {
  2407. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  2408. $outread = '';
  2409. if($out)
  2410. {
  2411. foreach ($out as $val)
  2412. {
  2413. $list = '';
  2414. $rk = explode('|',trim($val['rk'],'|'));
  2415. $rktime = explode('|',trim($val['rktime'],'|'));
  2416. $zw = array();
  2417. $t = $this->transfer->find_all("1=1");
  2418. foreach ($t as $v)
  2419. {
  2420. $zw[$v['id']] = $v['title'];
  2421. }
  2422. if($val['rk'] != '' && count($rk) > 0)
  2423. {
  2424. for($i=0;$i<count($rk);$i++)
  2425. {
  2426. if(!isset($rktime[$i]))
  2427. {
  2428. $list .= $zw[$cz[$i]];
  2429. }
  2430. else
  2431. {
  2432. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2433. }
  2434. }
  2435. }
  2436. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2437. }
  2438. }
  2439. else
  2440. {
  2441. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  2442. if($systemwigsout)
  2443. {
  2444. foreach ($systemwigsout as $v)
  2445. {
  2446. $outread = '';
  2447. if($v['czwarehouse'] == 37)
  2448. {
  2449. $outread .= '华荣厂';
  2450. }
  2451. else if($v['czwarehouse'] == 0)
  2452. {
  2453. $outread .= '龙盈厂';
  2454. }
  2455. $cz = explode('|',trim($v['cz'],'|'));
  2456. $cztime = explode('|',trim($v['cztime'],'|'));
  2457. $zw = $this->transfer->get_list();
  2458. if($v['cz'] != '' && count($cz) > 0)
  2459. {
  2460. for($i=0;$i<count($cz);$i++)
  2461. {
  2462. if(!isset($cztime[$i]))
  2463. {
  2464. $outread .= $zw[$cz[$i]].' -&gt; ';
  2465. }
  2466. else
  2467. {
  2468. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2469. }
  2470. }
  2471. $outread .= '<br>';
  2472. }
  2473. }
  2474. }
  2475. }
  2476. $info_list[$key]['systemwigsout'] = $outread;
  2477. }
  2478. if(isset($value['sourcetype']))
  2479. {
  2480. if($value['sourcetype'] == '1')
  2481. {
  2482. $info_list[$key]['sourcetype'] = '网红单';
  2483. }
  2484. else if($value['sourcetype'] == '2')
  2485. {
  2486. $info_list[$key]['sourcetype'] = '批发单';
  2487. }
  2488. else if($value['sourcetype'] == '3')
  2489. {
  2490. $info_list[$key]['sourcetype'] = '线下单';
  2491. }
  2492. else if($value['sourcetype'] == '4')
  2493. {
  2494. $info_list[$key]['sourcetype'] = '售后单';
  2495. }
  2496. else if($value['sourcetype'] == '5')
  2497. {
  2498. $info_list[$key]['sourcetype'] = '其它';
  2499. }
  2500. else
  2501. {
  2502. $info_list[$key]['sourcetype'] = '';
  2503. }
  2504. }
  2505. if(isset($value['js']))
  2506. {
  2507. if($value['js'] == '0')
  2508. {
  2509. $info_list[$key]['js'] = 'Ground Advantage';
  2510. }
  2511. else if($value['js'] == '1')
  2512. {
  2513. $info_list[$key]['js'] = 'PRIORITY';
  2514. }
  2515. else if($value['js'] == '2')
  2516. {
  2517. $info_list[$key]['js'] = 'EXPRESS';
  2518. }
  2519. else if($value['js'] == '3')
  2520. {
  2521. $info_list[$key]['js'] = 'IP';
  2522. }
  2523. else if($value['js'] == '4')
  2524. {
  2525. $info_list[$key]['js'] = 'FICP';
  2526. }
  2527. }
  2528. if(isset($value['type']))
  2529. {
  2530. $type = $this->warehouse->read($value['type']);
  2531. $info_list[$key]['type'] = $type['title'];
  2532. }
  2533. if(isset($value['xdcs']))
  2534. {
  2535. if($sj == 'fullorder')
  2536. {
  2537. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  2538. }
  2539. else
  2540. {
  2541. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  2542. }
  2543. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  2544. }
  2545. if(isset($value['dbapi']) || isset($value['scapi']))
  2546. {
  2547. $jmlist = '';$shuliang = '';
  2548. $classid = $this->classid->sku();
  2549. $dbapi = explode(';',trim($value['fpdata'],';'));
  2550. foreach ($dbapi as $va)
  2551. {
  2552. $pm = $classid;
  2553. $jm = $classid;
  2554. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2555. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2556. $ts = explode('|',trim($features,'|'));
  2557. if(stripos($ts[0],',') !== false)
  2558. {
  2559. $ft = explode(',',$ts[0]);
  2560. $features = explode('-',trim($ft[1],'-'));
  2561. $features[] = $ft[0];
  2562. }
  2563. else
  2564. {
  2565. $features = explode('-',trim($ts[0],'-'));
  2566. }
  2567. foreach($features as $k=>$v)
  2568. {
  2569. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2570. {
  2571. if($typeclass[$v]['bm'] != '')
  2572. {
  2573. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2574. }
  2575. }
  2576. if($v != 0 && isset($typeclass[$v]))
  2577. {
  2578. if($typeclass[$v]['classid'] == 13)
  2579. {
  2580. $dj = $typeclass[$v]['title'];
  2581. }
  2582. if($typeclass[$v]['classid'] == 8)
  2583. {
  2584. $ys = $typeclass[$v]['title'];
  2585. }
  2586. if($typeclass[$v]['classid'] == 15)
  2587. {
  2588. $hx = $typeclass[$v]['title'];
  2589. }
  2590. if(isset($pm[$typeclass[$v]['classid']]))
  2591. {
  2592. if($typeclass[$v]['title'] == '9A')
  2593. {
  2594. $pm[$typeclass[$v]['classid']] = '9A';
  2595. }
  2596. else if($typeclass[$v]['title'] == '10A')
  2597. {
  2598. $pm[$typeclass[$v]['classid']] = '10A';
  2599. }
  2600. else
  2601. {
  2602. $clzh = $typeclass[$v]['zh'];
  2603. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2604. {
  2605. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2606. $clzh = $clzh[0];
  2607. }
  2608. $pm[$typeclass[$v]['classid']] = $clzh;
  2609. }
  2610. }
  2611. if(isset($jm[$typeclass[$v]['classid']]))
  2612. {
  2613. if($typeclass[$v]['jm'])
  2614. {
  2615. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2616. }
  2617. }
  2618. }
  2619. }
  2620. $jm = array_filter($jm);//去除空值
  2621. $jm = implode("-",$jm);
  2622. $jmlist .= $jm.'<br>';
  2623. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2624. $pm = array_filter($pm);//去除空值
  2625. $zh = implode(" ",$pm);
  2626. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2627. }
  2628. if(isset($value['dbapi']))
  2629. {
  2630. $info_list[$key]['dbapi'] = $jmlist;
  2631. }
  2632. else
  2633. {
  2634. $info_list[$key]['scapi'] = $shuliang;
  2635. }
  2636. }
  2637. if(isset($value['dbapi']) && isset($value['scapi']))
  2638. {
  2639. $jmlist = '';$shuliang = '';
  2640. $classid = $this->classid->sku();
  2641. $dbapi = explode(';',trim($value['fpdata'],';'));
  2642. foreach ($dbapi as $va)
  2643. {
  2644. $pm = $classid;
  2645. $jm = $classid;
  2646. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2647. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2648. $ts = explode('|',trim($features,'|'));
  2649. if(stripos($ts[0],',') !== false)
  2650. {
  2651. $ft = explode(',',$ts[0]);
  2652. $features = explode('-',trim($ft[1],'-'));
  2653. $features[] = $ft[0];
  2654. }
  2655. else
  2656. {
  2657. $features = explode('-',trim($ts[0],'-'));
  2658. }
  2659. foreach($features as $k=>$v)
  2660. {
  2661. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2662. {
  2663. if($typeclass[$v]['bm'] != '')
  2664. {
  2665. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2666. }
  2667. }
  2668. if($v != 0 && isset($typeclass[$v]))
  2669. {
  2670. if($typeclass[$v]['classid'] == 13)
  2671. {
  2672. $dj = $typeclass[$v]['title'];
  2673. }
  2674. if($typeclass[$v]['classid'] == 8)
  2675. {
  2676. $ys = $typeclass[$v]['title'];
  2677. }
  2678. if($typeclass[$v]['classid'] == 15)
  2679. {
  2680. $hx = $typeclass[$v]['title'];
  2681. }
  2682. if(isset($pm[$typeclass[$v]['classid']]))
  2683. {
  2684. if($typeclass[$v]['title'] == '9A')
  2685. {
  2686. $pm[$typeclass[$v]['classid']] = '9A';
  2687. }
  2688. else if($typeclass[$v]['title'] == '10A')
  2689. {
  2690. $pm[$typeclass[$v]['classid']] = '10A';
  2691. }
  2692. else
  2693. {
  2694. $clzh = $typeclass[$v]['zh'];
  2695. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2696. {
  2697. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2698. $clzh = $clzh[0];
  2699. }
  2700. $pm[$typeclass[$v]['classid']] = $clzh;
  2701. }
  2702. }
  2703. if(isset($jm[$typeclass[$v]['classid']]))
  2704. {
  2705. if($typeclass[$v]['jm'])
  2706. {
  2707. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2708. }
  2709. }
  2710. }
  2711. }
  2712. $jm = array_filter($jm);//去除空值
  2713. $jm = implode("-",$jm);
  2714. $jmlist .= $jm.'<br>';
  2715. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2716. $pm = array_filter($pm);//去除空值
  2717. $zh = implode(" ",$pm);
  2718. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2719. }
  2720. $info_list[$key]['dbapi'] = $jmlist;
  2721. $info_list[$key]['scapi'] = $shuliang;
  2722. }
  2723. if(isset($value['cpfpdata']))
  2724. {
  2725. $fpread = '';
  2726. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  2727. foreach ($cpfpdata as $v)
  2728. {
  2729. $va = explode('|',trim($v,'|'));
  2730. if(isset($va[1])){
  2731. $fpread .= $va[1].'; ';
  2732. }else{
  2733. $fpread .="合并单没有产品异常标记";
  2734. }
  2735. }
  2736. $info_list[$key]['cpfpdata'] = $fpread;
  2737. }
  2738. if(count($goods_sku_list) > 0){
  2739. $ret_goods_sku = $this->_getGoodsInfo($value,$goods_sku_list,$typeclass);
  2740. if(in_array("gradefpdata",$goods_sku_list)){
  2741. $info_list[$key]['gradefpdata'] = trim($ret_goods_sku['gradefpdata'],"<br>");
  2742. }
  2743. if(in_array("colorfpdata",$goods_sku_list)){
  2744. $info_list[$key]['colorfpdata'] = trim($ret_goods_sku['colorfpdata'],"<br>");
  2745. }
  2746. if(in_array("densityfpdata",$goods_sku_list)){
  2747. $info_list[$key]['densityfpdata'] = trim($ret_goods_sku['densityfpdata'],"<br>");
  2748. }
  2749. if(in_array("hairnumberfpdata",$goods_sku_list)){
  2750. $info_list[$key]['hairnumberfpdata'] = trim($ret_goods_sku['hairnumberfpdata'],"<br>");
  2751. }
  2752. if(in_array("lacetypefpdata",$goods_sku_list)){
  2753. $info_list[$key]['lacetypefpdata'] = trim($ret_goods_sku['lacetypefpdata'],"<br>");
  2754. }
  2755. //lowefpdata
  2756. if(in_array("lowefpdata",$goods_sku_list)){
  2757. $info_list[$key]['lowefpdata'] = trim($ret_goods_sku['lowefpdata'],"<br>");
  2758. }
  2759. }
  2760. unset($info_list[$key]['id']);
  2761. unset($info_list[$key]['fpdata']);
  2762. }
  2763. return [
  2764. 'info_list'=>$info_list,
  2765. 'shouldmoney'=>$shouldmoney
  2766. ];
  2767. }
  2768. //上传运单
  2769. public function _waybill($arg_array)
  2770. {
  2771. $readid = $arg_array[0];
  2772. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2773. /* 订单加入键值-k */
  2774. $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
  2775. foreach ($fdata as $v)
  2776. {
  2777. $dataorder[$v['orderinfo']] = $v;
  2778. }
  2779. $sdata = $this->fullordersmt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2780. foreach ($sdata as $v)
  2781. {
  2782. $dataorder[$v['orderinfo']] = $v;
  2783. }
  2784. $tdata = $this->fullordertt->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2785. foreach ($tdata as $v)
  2786. {
  2787. $dataorder[$v['orderinfo']] = $v;
  2788. }
  2789. $xdata = $this->fullorderxw->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and state = 207 and (dlz < 1 or dlz = 3)');
  2790. foreach ($xdata as $v)
  2791. {
  2792. $dataorder[$v['orderinfo']] = $v;
  2793. }
  2794. /* 订单加入键值-j */
  2795. /* 店铺加入键值-j */
  2796. $fshop = $this->shop->find_all('1=1');
  2797. foreach ($fshop as $v)
  2798. {
  2799. $datashop[$v['id']] = $v;
  2800. }
  2801. /* 店铺加入键值-k */
  2802. /* 快递加入键值-j */
  2803. $fex = $this->express->find_all('1=1');
  2804. foreach ($fex as $v)
  2805. {
  2806. $dataex[$v['id']] = $v;
  2807. }
  2808. /* 快递加入键值-k */
  2809. /* 仓库加入键值-k */
  2810. $fwh = $this->warehouse->find_all('1=1');
  2811. foreach ($fwh as $v)
  2812. {
  2813. $datack[$v['id']] = $v;
  2814. }
  2815. /* 仓库加入键值-j */
  2816. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2817. if(is_numeric($readid) == false || $readid < 1)
  2818. {
  2819. echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
  2820. }
  2821. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2822. $config['upload_path'] = '.'.$dir ;
  2823. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2824. $config['allowed_types'] = 'xls|xlsx|csv';
  2825. $config['max_size'] = 10240;
  2826. $this->load->library('upload', $config);
  2827. $this->upload->initialize($config);
  2828. if ($this->upload->do_upload('userfile'))
  2829. {
  2830. $full_path = $dir.$this->upload->data('file_name');
  2831. $fileName = '.' . $full_path;
  2832. if (!file_exists($fileName))
  2833. {
  2834. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2835. }
  2836. else
  2837. {
  2838. require_once "./data/excel/PHPExcel/IOFactory.php";
  2839. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2840. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2841. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2842. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2843. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2844. ++$column;//如果列数大于26行
  2845. $list = array();
  2846. for ($i = 2; $i <= $row; $i++) // 行数循环
  2847. {
  2848. $data = array();
  2849. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2850. {
  2851. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2852. }
  2853. $list[] = $data;
  2854. }
  2855. }
  2856. $i = 0;$j = 0;$ed = array();$cscs = array();
  2857. $this->db->trans_begin();
  2858. foreach ($list as $key=>$value)
  2859. {
  2860. $ddh = preg_replace('/\D/s','',$value['0']);
  2861. $ydh = preg_replace('/\W/s','',$value['1']);
  2862. $shop = $datashop[$readid];
  2863. if($shop['type'] == '269')
  2864. {
  2865. $orid = $readid.$ddh;
  2866. }
  2867. else
  2868. {
  2869. $orid = $ddh;
  2870. }
  2871. if(isset($dataorder[$orid]))
  2872. {
  2873. if($shop['type'] == 269)//独立站前缀需要添加ID
  2874. {
  2875. $time = time();
  2876. $xg = $dataorder[$orid];
  2877. $oldw = $xg['waybill'];
  2878. $ex = $dataex[$xg['express']];
  2879. $warehouse = $datack[$xg['type']];
  2880. $msg = $ydh;
  2881. $xg['waybill'] = $ydh;
  2882. $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  2883. if(isset($fs[0]))
  2884. {
  2885. $fs = $fs[0];
  2886. $fs['email'] = $this->emaildata->read($fs['email']);
  2887. if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
  2888. {
  2889. $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
  2890. if($ck == 1)
  2891. {
  2892. $ckemail = '邮件发送成功,';
  2893. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
  2894. }
  2895. }
  2896. }
  2897. if($msg != $oldw)
  2898. {
  2899. if($xg['source'] != 1)
  2900. {
  2901. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  2902. if(!isset($ms[0]))
  2903. {
  2904. $ms = $this->message->read(2);
  2905. }
  2906. else
  2907. {
  2908. $ms = $ms[0];
  2909. }
  2910. $ddh = substr($xg['orderinfo'],1);
  2911. $shopifyid = $xg['shopify'];
  2912. //独立站地址更新订单状态、物流信息
  2913. $shopname = $shop['brandname']; //店铺名
  2914. $buyername = $xg['bname']; //Bill Name
  2915. $email_call = $shop['shopid']; //发货人邮箱;
  2916. $phone = $shop['shopphone']; //发货人电话
  2917. $track_type = $ex['title']; //快递名称
  2918. $service = $ex['title']; //快递追踪名称
  2919. $track_link = $ex['url']; //快递查询网址
  2920. $logistics_number = $ydh; //运单号
  2921. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  2922. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  2923. $remark = str_replace($t,$h,$ms['content']);
  2924. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  2925. }
  2926. else if($xg['source'] == 1)
  2927. {
  2928. $gx['res'] = 3;
  2929. $gx['state'] = 216;
  2930. }
  2931. }
  2932. else
  2933. {
  2934. $gx['res'] = $xg['dlz'];
  2935. $gx['state'] = $xg['state'];
  2936. }
  2937. $xg['iscode'] = $ex['title'];
  2938. $xg['url'] = $shop['shopname'];
  2939. @$chuanshu = $this->api->get_paypal($xg);
  2940. //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  2941. $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['id']);
  2942. /**
  2943. $xg = $dataorder[$arg_array[0].$ddh];
  2944. $ex = $dataex[$xg['express']];
  2945. $warehouse = $datack[$xg['type']];
  2946. if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
  2947. {
  2948. //独立站地址更新订单状态、物流信息
  2949. $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
  2950. if(!isset($gx['res']))
  2951. {
  2952. $ed[] = array($ddh.'-更新失败');
  2953. $j++;
  2954. continue;
  2955. }
  2956. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  2957. if($gx['res'] == 1 && $fs)
  2958. {
  2959. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2960. }
  2961. }
  2962. else if($xg['source'] == 1 && $xg['state'] == '207')
  2963. {
  2964. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2965. if($fs)
  2966. {
  2967. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2968. }
  2969. }
  2970. else
  2971. {
  2972. $ed[] = array($ddh.'-状态错误');
  2973. $j++;
  2974. continue;
  2975. }
  2976. **/
  2977. }
  2978. else if($shop['type'] == 270)//速卖通对接发货声明
  2979. {
  2980. $xg = $dataorder[$ddh];
  2981. $ex = $dataex[$xg['express']];
  2982. $warehouse = $datack[$xg['type']];
  2983. if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
  2984. {
  2985. $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
  2986. if(isset($result['result_success']) && $result['result_success'] == "true")
  2987. {
  2988. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
  2989. /** 合并信息处理开始-发货声明 **/
  2990. if($xg['merge'] != '0')
  2991. {
  2992. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
  2993. foreach ($hdata as $v)
  2994. {
  2995. $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
  2996. if(isset($result['result_success']) && $result['result_success'] == "true")
  2997. {
  2998. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
  2999. }
  3000. else
  3001. {
  3002. $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
  3003. $j++;
  3004. continue;
  3005. }
  3006. $l++;
  3007. if($l > 10)
  3008. {
  3009. break;
  3010. }
  3011. }
  3012. }
  3013. /** 合并信息处理结束开始 **/
  3014. }
  3015. else
  3016. {
  3017. $ed[] = array($ddh.'-发货声明失败');
  3018. $j++;
  3019. continue;
  3020. }
  3021. }
  3022. else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
  3023. {
  3024. $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  3025. if(isset($obtain['logistics_no']))
  3026. {
  3027. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  3028. }
  3029. if(isset($result['result_success']) && $result['result_success'] == "true")
  3030. {
  3031. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3032. /** 合并信息处理开始-修改声明 **/
  3033. if($xg['merge'] != '0')
  3034. {
  3035. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
  3036. foreach ($hdata as $v)
  3037. {
  3038. $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  3039. if(isset($obtain['logistics_no']))
  3040. {
  3041. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  3042. }
  3043. if(isset($result['result_success']) && $result['result_success'] == "true")
  3044. {
  3045. $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
  3046. }
  3047. else
  3048. {
  3049. $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
  3050. $j++;
  3051. continue;
  3052. }
  3053. $l++;
  3054. if($l > 10)
  3055. {
  3056. break;
  3057. }
  3058. }
  3059. }
  3060. /** 合并信息处理结束开始 **/
  3061. }
  3062. else
  3063. {
  3064. $ed[] = array($ddh.'-修改发货声明失败');
  3065. $j++;
  3066. continue;
  3067. }
  3068. }
  3069. else if($xg['source'] == 1 && $xg['state'] == '207')
  3070. {
  3071. $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  3072. }
  3073. else
  3074. {
  3075. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  3076. }
  3077. }
  3078. }
  3079. else
  3080. {
  3081. $ed[] = array($ddh.'-单号错误或重复操作');
  3082. $i++;
  3083. continue;
  3084. }
  3085. sleep(1);//停留1秒
  3086. }
  3087. if ($this->db->trans_status() === FALSE)
  3088. {
  3089. $this->db->trans_rollback();
  3090. }
  3091. else
  3092. {
  3093. $this->db->trans_commit();
  3094. }
  3095. if($i+$j > 0)
  3096. {
  3097. $time = date('Ymd',time());
  3098. $title = '错误信息-'.$time;
  3099. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3100. $tail = "\n";
  3101. $filename = $title.".xls";
  3102. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3103. $dir = '/data/excel/'.$time.'/';
  3104. $file_name = 'error_'.$time.rand(1000,9999);
  3105. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3106. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3107. fwrite($myfile,$ecl);
  3108. fclose($myfile);
  3109. $error = $dir.$file_name.'.xls';
  3110. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3111. }
  3112. else
  3113. {
  3114. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3115. }
  3116. }
  3117. else
  3118. {
  3119. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3120. }
  3121. }
  3122. //上传速卖通订单
  3123. public function _order($arg_array)
  3124. {
  3125. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3126. /* 订单加入键值-k */
  3127. $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
  3128. foreach ($fdata as $v)
  3129. {
  3130. $dataorder[$v['orderinfo']] = $v;
  3131. }
  3132. /* 订单加入键值-j */
  3133. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3134. $config['upload_path'] = '.'.$dir ;
  3135. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3136. $config['allowed_types'] = 'xls|xlsx|csv';
  3137. $config['max_size'] = 10240;
  3138. $this->load->library('upload', $config);
  3139. $this->upload->initialize($config);
  3140. if ($this->upload->do_upload('userfile'))
  3141. {
  3142. $full_path = $dir.$this->upload->data('file_name');
  3143. $fileName = '.' . $full_path;
  3144. if (!file_exists($fileName))
  3145. {
  3146. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3147. }
  3148. else
  3149. {
  3150. require_once "./data/excel/PHPExcel/IOFactory.php";
  3151. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3152. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3153. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3154. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3155. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3156. ++$column;//如果列数大于26行
  3157. $list = array();
  3158. for ($i = 2; $i <= $row; $i++) // 行数循环
  3159. {
  3160. $data = array();
  3161. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3162. {
  3163. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3164. }
  3165. $list[] = $data;
  3166. }
  3167. }
  3168. $i = 0;$j = 0;$ed = array();$tytime = time();
  3169. foreach ($list as $key=>$value)
  3170. {
  3171. $value['2'] = preg_replace('/\D/s','',$value['2']);
  3172. if($value['2'] && !isset($dataorder[$value['2']]))
  3173. {
  3174. $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
  3175. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3176. $post['state'] = 207;//订单状态:207等待发货
  3177. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3178. $post['reviewtime'] = $tytime;//审核时间
  3179. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3180. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3181. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3182. if($post['print'] != 3)
  3183. {
  3184. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  3185. }
  3186. $value['1'] = trim($value['1'],' ');
  3187. $shortname = explode('-',$value['1']);
  3188. $shortname = $this->shop->get_shortname($shortname[0]);
  3189. if(!$shortname)
  3190. {
  3191. $ed[] = array($value['1'].'-编码有问题');
  3192. $i++;
  3193. continue;
  3194. }
  3195. $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
  3196. $post['user'] = '无';
  3197. $post['number'] = $value['1'];//编号
  3198. $post['orderinfo'] = $value['2'];//订单号
  3199. $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
  3200. $post['buytime'] = $tytime;//时间转UX
  3201. $post['dtime'] = $tytime;//订单时间
  3202. $post['gtime'] = date('Ymd',$tytime);//格式化时间
  3203. //$post['pay'] = $this->input->post('pay',true);//支付方式
  3204. $post['capital'] = 3;//资金状态
  3205. $post['type'] = 5;//发货仓库
  3206. $post['currency'] = 219;//币种
  3207. $post['currencytitle'] = 'USD';//币种名称
  3208. $post['freight'] = 0;//运费
  3209. $post['expressmoney'] = 0;//物流金额
  3210. $post['shouldmoney'] = 0;//应收金额
  3211. $post['budget'] = 0;//应到金额*店铺到帐金额比
  3212. $orderremarks = '';//订单备注
  3213. $post['shipremarks'] = $value['12'];//仓库品名
  3214. $post['email'] = '';//邮箱
  3215. $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
  3216. $post['phone'] = $value['10'];//电话
  3217. $post['country'] = 192;//国家
  3218. $ct = $this->country->get_ename($value['9']);//国家
  3219. $post['al'] = $ct['lb'];//国家二字码
  3220. $post['province'] = $value['8'];//省、州
  3221. $post['city'] = $value['6'];//城市
  3222. $post['zipcode'] = $value['7'];//邮编
  3223. $post['address'] = $value['4'];//地址1
  3224. $post['address2'] = $value['5']?$value['5']:'';//地址2
  3225. $post['express'] = 2;//快递
  3226. $post['printtype'] = 1;//打印类型
  3227. $post['fpdata'] = '';//购买产品内容
  3228. $post['sbpm'] = 'Hair Sample';//申报品名
  3229. $post['zwpm'] = '假发';//中文品名
  3230. $post['ts'] = $value['17'];//条数
  3231. $post['dtsbjz'] = 15;//单条申报价
  3232. $post['zsbjz'] = 15;//总申报价
  3233. $post['zzl'] = 0.5;//总重量
  3234. $post['zjs'] = 1;//总件数
  3235. $post['quantity'] = 1;//数量
  3236. $post['paypal'] = '';//支付号
  3237. $post['guarantee'] = '';//卖家保障
  3238. $post['zzl'] = $value['13'];//总重量
  3239. $post['bx'] = $value['14'];//总重量
  3240. $post['qm'] = $value['15'];//总重量
  3241. $post['js'] = $value['16'];//总重量
  3242. $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
  3243. if(isset($barcode['Address']['Error']['Description']))
  3244. {
  3245. $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
  3246. $i++;
  3247. }
  3248. else
  3249. {
  3250. $this->fullorder_smt->insert($post);
  3251. }
  3252. }
  3253. else
  3254. {
  3255. $ed[] = array($value['1'].'-单号错误或重复操作');
  3256. $i++;
  3257. }
  3258. sleep(2);//停留2秒
  3259. }
  3260. if($i+$j > 0)
  3261. {
  3262. $time = date('Ymd',time());
  3263. $title = '错误信息-'.$time;
  3264. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3265. $tail = "\n";
  3266. $filename = $title.".xls";
  3267. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3268. $dir = '/data/excel/'.$time.'/';
  3269. $file_name = 'error_'.$time.rand(1000,9999);
  3270. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3271. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3272. fwrite($myfile,$ecl);
  3273. fclose($myfile);
  3274. $error = $dir.$file_name.'.xls';
  3275. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3276. }
  3277. else
  3278. {
  3279. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3280. }
  3281. }
  3282. else
  3283. {
  3284. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3285. }
  3286. }
  3287. public function _email($content,$data,$shopname)
  3288. {
  3289. $express = $this->express->read($data['express']);
  3290. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3291. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3292. $content = str_replace($t,$h,$content);
  3293. $this->load->library('email');
  3294. $config['protocol'] = 'smtp';
  3295. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3296. $config['smtp_port'] = 465;
  3297. $config['smtp_user'] = 'service@email.supernovahair.com';
  3298. $config['smtp_pass'] = 'LONGyihair374';
  3299. $config['smtp_crypto'] = 'ssl';
  3300. $config['crlf'] = "\r\n";
  3301. $config['newline'] = "\r\n";
  3302. $this->email->initialize($config);
  3303. $this->email->from('service@email.supernovahair.com',$shopname);
  3304. $this->email->to($data['email']);//收件
  3305. $this->email->subject('The product you purchased has a new progress');//标题
  3306. $this->email->message($content);//内容
  3307. if ( ! $this->email->send())
  3308. {
  3309. return 2;
  3310. }
  3311. else
  3312. {
  3313. return 1;
  3314. }
  3315. }
  3316. //导出订单excel
  3317. public function _cs()
  3318. {
  3319. if(isset($_GET['fexcel']))
  3320. {
  3321. if(isset($_SESSION['api']))
  3322. {
  3323. $user = $this->user->get_api($_SESSION['api']);
  3324. $usp = $user;
  3325. $fgshop = "";$sid = "";
  3326. $user = explode('|',trim($user['shop'],'|'));
  3327. foreach ($user as $value)
  3328. {
  3329. $fgshop .= " shop = ".$value." or";
  3330. $sid .= " id = ".$value." or";
  3331. }
  3332. }
  3333. $dowid = $this->input->get('a');
  3334. $wid = "";
  3335. if($dowid != "")
  3336. {
  3337. $id_arr = explode(',',rtrim($dowid,','));
  3338. foreach ($id_arr as $v)
  3339. {
  3340. $wid .= " id = 0 or";
  3341. $wid .= " id = '$v' or";
  3342. }
  3343. $wid = " and".rtrim($wid,'or');
  3344. }
  3345. $fexcel = $this->input->get('fexcel',true);
  3346. $page = $this->input->get('page',true);
  3347. $perpage = $this->input->get('perpage',true);
  3348. $warehouse = $this->input->get('warehouse',true);
  3349. $timetk = $this->input->get('timetk',true);
  3350. $timetj = $this->input->get('timetj',true);
  3351. $shop = $this->input->get('shop',true);
  3352. $source = $this->input->get('source',true);
  3353. $state = $this->input->get('state',true);
  3354. $review = $this->input->get('review',true);
  3355. $type = $this->input->get('type',true);
  3356. $express = $this->input->get('express',true);
  3357. $orderinfo = $this->input->get('orderinfo',true);
  3358. $user = $this->input->get('user',true);
  3359. $client = $this->input->get('name',true);
  3360. $waybill = $this->input->get('waybill',true);
  3361. $number = $this->input->get('number',true);
  3362. $email = $this->input->get('email',true);
  3363. $dlz = $this->input->get('dlz',true);
  3364. $library = $this->input->get('library',true);
  3365. $libraryconfirm = $this->input->get('libraryconfirm',true);
  3366. $print = $this->input->get('print',true);
  3367. $timetkk = $this->input->get('timetkk',true);
  3368. $timetjj = $this->input->get('timetjj',true);
  3369. $timetk = strtotime($timetk);
  3370. $timetj = strtotime($timetj);
  3371. $timetkk = strtotime($timetkk);
  3372. $timetjj = strtotime($timetjj);
  3373. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  3374. if($warehouse)
  3375. {
  3376. $where .= " and type = '$warehouse'";
  3377. }
  3378. if($timetk && $timetj)
  3379. {
  3380. $timetj = $timetj+24*3600;
  3381. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3382. }
  3383. if($timetkk && $timetjj)
  3384. {
  3385. $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
  3386. }
  3387. if($library)
  3388. {
  3389. $where .= " and library = '$library'";
  3390. }
  3391. if($print)
  3392. {
  3393. $where .= " and print = '$print'";
  3394. }
  3395. if($shop)
  3396. {
  3397. $where .= " and shop = '$shop'";
  3398. }
  3399. if($source)
  3400. {
  3401. $where .= " and source = '$source'";
  3402. }
  3403. if($state)
  3404. {
  3405. $where .= " and state = '$state'";
  3406. }
  3407. if($review)
  3408. {
  3409. $where .= " and review = '$review'";
  3410. }
  3411. if($type)
  3412. {
  3413. $where .= " and type = '$type'";
  3414. }
  3415. if($express)
  3416. {
  3417. $where .= " and express = '$express'";
  3418. }
  3419. if($orderinfo)
  3420. {
  3421. $where .= " and orderinfo = '$orderinfo'";
  3422. }
  3423. if($user)
  3424. {
  3425. $where .= " and user = '$user'";
  3426. }
  3427. if($client)
  3428. {
  3429. $where .= " and client like '%$client%'";
  3430. }
  3431. if($waybill)
  3432. {
  3433. $where .= " and waybill = '$waybill'";
  3434. }
  3435. if($number)
  3436. {
  3437. $where .= " and number = '$number'";
  3438. }
  3439. if($email)
  3440. {
  3441. $where .= " and email = '$email'";
  3442. }
  3443. if($dlz)
  3444. {
  3445. $where .= " and waybill != '' and dlz = 0";
  3446. }
  3447. if($dlz)
  3448. {
  3449. $where .= " and libraryconfirm = '$libraryconfirm'";
  3450. }
  3451. $fexcel = $this->fullorderexcel->read($fexcel);
  3452. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  3453. foreach ($fexceleq as $k=>$v)
  3454. {
  3455. $fexceleq[$k] = explode('-',$v);
  3456. $num[$k] = $fexceleq[$k][0];
  3457. }
  3458. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  3459. $feq = "";
  3460. foreach ($fexceleq as $k=>$v)
  3461. {
  3462. $feq .= $v[1].',';
  3463. }
  3464. $feq = rtrim($feq,',');
  3465. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  3466. foreach ($fexcelzhw as $k=>$v)
  3467. {
  3468. $fexcelzhw[$k] = explode('-',$v);
  3469. $numb[$k] = $fexcelzhw[$k][0];
  3470. }
  3471. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  3472. $fexcelzh = array();
  3473. foreach ($fexcelzhw as $k=>$v)
  3474. {
  3475. $fexcelzh[] = $v[1];
  3476. }
  3477. //取得信息列表
  3478. $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
  3479. //格式化数据
  3480. $i = 1;$shouldmoney = 0;$hl=1;
  3481. foreach ($info_list as $key=>$value)
  3482. {
  3483. if(isset($value['currencytitle']))
  3484. {
  3485. if($value['currencytitle'] != "CNY")
  3486. {
  3487. $hl=$value['hl'];
  3488. }
  3489. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3490. $budget=$budget+($value['budget']*$hl);
  3491. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3492. $refund=$refund+($value['refund']*$hl);
  3493. }
  3494. if(isset($value['shop']))
  3495. {
  3496. $shop = $this->shop->read($value['shop']);
  3497. $info_list[$key]['shop'] = $shop['shopname'];
  3498. }
  3499. if(isset($value['dtime']))
  3500. {
  3501. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3502. }
  3503. if(isset($value['country']))
  3504. {
  3505. $country = $this->country->read($value['country']);
  3506. $info_list[$key]['country'] = $country['name'];
  3507. }
  3508. if(isset($value['type']))
  3509. {
  3510. $type = $this->warehouse->read($value['type']);
  3511. $info_list[$key]['type'] = $type['title'];
  3512. }
  3513. if(isset($value['express']))
  3514. {
  3515. $express = $this->express->read($value['express']);
  3516. if($express)
  3517. {
  3518. $info_list[$key]['express'] = $express['servicename'];
  3519. }
  3520. else
  3521. {
  3522. $info_list[$key]['express'] = '未选择';
  3523. }
  3524. }
  3525. }
  3526. echo $timetkk;
  3527. }
  3528. }
  3529. public function _gggs($sku,$s,$j,$k)
  3530. {
  3531. $companytitle = array(9=>3,10=>2,11=>1,12=>4);
  3532. $this->load->database();
  3533. $this->db->select('id');
  3534. $this->db->from('crowd_whlabel');
  3535. $this->db->where('warehouse', '5');
  3536. $this->db->where('sku', $sku);
  3537. $this->db->where('state', '0');
  3538. $this->db->limit($s,$k);
  3539. $query = $this->db->get();
  3540. $ids = array_column($query->result_array(), 'id');
  3541. if (!empty($ids))
  3542. {
  3543. // 更新
  3544. $this->db->where_in('id', $ids);
  3545. $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
  3546. return $this->db->affected_rows();
  3547. }
  3548. }
  3549. public function _xxpl()
  3550. {
  3551. $this->load->database();
  3552. $data = ['type' => ''];
  3553. $this->db->update('crowd_whlabel', $data);
  3554. $wt = array();
  3555. $whlabel_type = $this->whlabel_type->find_all();
  3556. foreach ($whlabel_type as $v)
  3557. {
  3558. $wt[$v['title']] = $v['id'];
  3559. }
  3560. /* 订单加入键值-j */
  3561. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3562. $config['upload_path'] = '.'.$dir ;
  3563. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3564. $config['allowed_types'] = 'xls|xlsx|csv';
  3565. $config['max_size'] = 10240;
  3566. $this->load->library('upload', $config);
  3567. $this->upload->initialize($config);
  3568. if ($this->upload->do_upload('userfile'))
  3569. {
  3570. $full_path = $dir.$this->upload->data('file_name');
  3571. $fileName = '.' . $full_path;
  3572. if (!file_exists($fileName))
  3573. {
  3574. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3575. }
  3576. else
  3577. {
  3578. require_once "./data/excel/PHPExcel/IOFactory.php";
  3579. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3580. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3581. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3582. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3583. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3584. ++$column;//如果列数大于26行
  3585. $list = array();
  3586. for ($i = 2; $i <= $row; $i++) // 行数循环
  3587. {
  3588. $data = array();
  3589. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3590. {
  3591. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3592. }
  3593. $list[] = $data;
  3594. }
  3595. }
  3596. $wt = array();
  3597. $whlabel_type = $this->whlabel_type->find_all();
  3598. foreach ($whlabel_type as $v)
  3599. {
  3600. $wt[$v['title']] = $v['id'];
  3601. }
  3602. $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
  3603. foreach ($list as $v)
  3604. {
  3605. $this->load->database();
  3606. // 设置更新数据
  3607. $data = ['type' => $wt[$v[1]]];
  3608. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3609. $this->db->where('SKU', $v[0]);
  3610. $this->db->where('warehouse', '5');
  3611. // 批量更新
  3612. $this->db->update('crowd_whlabel', $data);
  3613. }
  3614. /** 导入缺货
  3615. $time = time();
  3616. $whlabel = $this->whlabel->get_sku($v[0]);
  3617. if($whlabel)
  3618. {
  3619. $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
  3620. }
  3621. else
  3622. {
  3623. $ed[] = $v['0'];
  3624. $j++;
  3625. }
  3626. }
  3627. **/
  3628. /**
  3629. 更换等级
  3630. $this->load->database();
  3631. // 设置更新数据
  3632. $data = ['type' => $wt[$v[1]]];
  3633. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3634. $this->db->where('SKU', $v[0]);
  3635. $this->db->where('warehouse', '5');
  3636. // 批量更新
  3637. $this->db->update('crowd_whlabel', $data);
  3638. **/
  3639. /**
  3640. $whlabel_type = $this->whlabel_type->find_all();
  3641. foreach ($whlabel_type as $v)
  3642. {
  3643. $wt[$v['title']] = $v['id'];
  3644. }
  3645. foreach ($list as $v)
  3646. {
  3647. $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
  3648. if($w && isset($wt[$v[1]]))
  3649. {
  3650. foreach ($w as $val)
  3651. {
  3652. $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
  3653. }
  3654. }
  3655. else
  3656. {
  3657. $ed[] = array($v[0],$v[1]);
  3658. $j++;
  3659. }
  3660. }
  3661. **/
  3662. if($e > 0)
  3663. {
  3664. $time = date('Ymd',time());
  3665. $title = '错误信息-'.$time;
  3666. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3667. $tail = "\n";
  3668. $filename = $title.".xls";
  3669. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3670. $dir = '/data/excel/'.$time.'/';
  3671. $file_name = 'error_'.$time.rand(1000,9999);
  3672. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3673. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3674. fwrite($myfile,$ecl);
  3675. fclose($myfile);
  3676. $error = $dir.$file_name.'.xls';
  3677. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  3678. }
  3679. else
  3680. {
  3681. echo json_encode(array('msg'=>'添加成功!'.$c,'success'=>true));exit;
  3682. }
  3683. }
  3684. else
  3685. {
  3686. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3687. }
  3688. }
  3689. public function _skuzh()
  3690. {
  3691. /* 订单加入键值-j */
  3692. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3693. $config['upload_path'] = '.'.$dir ;
  3694. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3695. $config['allowed_types'] = 'xls|xlsx|csv';
  3696. $config['max_size'] = 10240;
  3697. $this->load->library('upload', $config);
  3698. $this->upload->initialize($config);
  3699. if ($this->upload->do_upload('userfile'))
  3700. {
  3701. $full_path = $dir.$this->upload->data('file_name');
  3702. $fileName = '.' . $full_path;
  3703. if (!file_exists($fileName))
  3704. {
  3705. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3706. }
  3707. else
  3708. {
  3709. require_once "./data/excel/PHPExcel/IOFactory.php";
  3710. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3711. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3712. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3713. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3714. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3715. ++$column;//如果列数大于26行
  3716. $list = array();
  3717. for ($i = 2; $i <= $row; $i++) // 行数循环
  3718. {
  3719. $data = array();
  3720. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3721. {
  3722. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3723. }
  3724. $list[] = $data;
  3725. }
  3726. }
  3727. $dictionaries = $this->typeclass->find_all('spare!= "" and classid != 1 and classid != 2 and classid != 3 and classid != 4 and classid != 5 and classid != 11 and classid != 16 and classid != 17 and classid != 20 and classid != 21 and classid != 23 and classid != 24 and classid != 29 and classid != 30 and classid != 31 and classid != 32');
  3728. $dtc = array();
  3729. foreach ($dictionaries as $v)
  3730. {
  3731. if(stripos($v['spare'],'|') !== false)//如果有多个值
  3732. {
  3733. $v['spare'] = explode('|',$v['spare']);
  3734. foreach ($v['spare'] as $k=>$vs)
  3735. {
  3736. if(stripos($v['zh'],'|') !== false)
  3737. {
  3738. $vzh = explode('|',$v['zh']);
  3739. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3740. }
  3741. else
  3742. {
  3743. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3744. }
  3745. }
  3746. }
  3747. else
  3748. {
  3749. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  3750. }
  3751. }
  3752. $dictionaries2 = $this->typeclass->find_all();
  3753. foreach ($dictionaries2 as $v)
  3754. {
  3755. $dtctitle[$v['id']] = $v['title'];
  3756. }
  3757. /* 匹配结束 */
  3758. /* 价格加入 */
  3759. $money = array();
  3760. $productdescribe = $this->productdescribe->find_all('1=1');
  3761. foreach ($productdescribe as $v)
  3762. {
  3763. $money[$v['number']] = array();
  3764. }
  3765. /* 价格加入 */
  3766. /* 匹配ID加入 */
  3767. $int = array();
  3768. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  3769. foreach ($intdata as $v)
  3770. {
  3771. $v['spare'] = explode('|',$v['spare']);
  3772. $int[$v['id']] = $v['spare'][0];
  3773. }
  3774. /* 匹配ID加入 */
  3775. $zjsku = array();
  3776. $shopsku = $this->shopsku->find_all();
  3777. foreach ($shopsku as $val)
  3778. {
  3779. $ss = explode(',',trim($val['shop'],','));
  3780. foreach ($ss as $v)
  3781. {
  3782. if(isset($zjsku[$v]))
  3783. {
  3784. $zjsku[$v] .= ','.trim($val['sku'],',');
  3785. }
  3786. else
  3787. {
  3788. $zjsku[$v] = trim($val['sku'],',');
  3789. }
  3790. }
  3791. }
  3792. /* 匹配ID结束 */
  3793. $q = '1;';
  3794. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  3795. $shop = $this->shop->read(19);
  3796. if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
  3797. {
  3798. $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
  3799. }
  3800. $ed = array();
  3801. foreach ($list as $v)
  3802. {
  3803. $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
  3804. $p = '';
  3805. $product = explode(';',trim($r['product'],';'));
  3806. if($r['title'] != '' && $product)
  3807. {
  3808. foreach ($product as $val)
  3809. {
  3810. $vc = explode('|',$val);
  3811. if(isset($vc[1]))
  3812. {
  3813. $p .= $vc[1].'<br>';
  3814. }
  3815. }
  3816. $r['title'] = str_replace(array('<','>'),array('&lt;','&gt;'),$r['title']);
  3817. $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
  3818. }
  3819. else
  3820. {
  3821. $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
  3822. }
  3823. }
  3824. $time = date('Ymd',time());
  3825. $title = 'sku转换'.$time;
  3826. $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
  3827. $tail = "\n";
  3828. $filename = $title.".xls";
  3829. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3830. $dir = '/data/excel/'.$time.'/';
  3831. $file_name = 'sku转换 '.$time.rand(1000,9999);
  3832. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3833. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3834. fwrite($myfile,$ecl);
  3835. fclose($myfile);
  3836. $error = $dir.$file_name.'.xls';
  3837. echo json_encode(array('msg'=>'转换成功!','error'=>$error,'success'=>true));exit;
  3838. }
  3839. else
  3840. {
  3841. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3842. }
  3843. }
  3844. public function _xxpl_b()
  3845. {
  3846. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3847. /* 订单加入键值-k */
  3848. $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
  3849. foreach ($fdata as $v)
  3850. {
  3851. $dataorder[$v['orderinfo']] = $v;
  3852. }
  3853. /* 订单加入键值-j */
  3854. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3855. $config['upload_path'] = '.'.$dir ;
  3856. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3857. $config['allowed_types'] = 'xls|xlsx|csv';
  3858. $config['max_size'] = 10240;
  3859. $this->load->library('upload', $config);
  3860. $this->upload->initialize($config);
  3861. if ($this->upload->do_upload('userfile'))
  3862. {
  3863. $full_path = $dir.$this->upload->data('file_name');
  3864. $fileName = '.' . $full_path;
  3865. if (!file_exists($fileName))
  3866. {
  3867. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3868. }
  3869. else
  3870. {
  3871. require_once "./data/excel/PHPExcel/IOFactory.php";
  3872. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3873. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3874. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3875. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3876. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3877. ++$column;//如果列数大于26行
  3878. $list = array();
  3879. for ($i = 2; $i <= $row; $i++) // 行数循环
  3880. {
  3881. $data = array();
  3882. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3883. {
  3884. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3885. }
  3886. $list[] = $data;
  3887. }
  3888. }
  3889. $i = 0;$j = 0;$ed = array();$time = time();
  3890. foreach ($list as $key=>$value)
  3891. {
  3892. $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
  3893. if(!$shop)
  3894. {
  3895. $ed[] = array($value['0'].'-无此店铺');
  3896. $i++;continue;
  3897. }
  3898. $post['buytime'] = strtotime($value['6']);//付款时间
  3899. $value['0'] = preg_replace('/\D/s','',$value['0']);
  3900. if($value['0'] && !isset($dataorder[$value['0']]))
  3901. {
  3902. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3903. $post['state'] = 207;//订单状态:207等待发货
  3904. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3905. $post['reviewtime'] = $time;//审核时间
  3906. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3907. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3908. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3909. $post['dtime'] = $time;//订单时间
  3910. $post['capital'] = 3;//资金状态
  3911. $post['currency'] = 219;//币种
  3912. $post['currencytitle'] = 'USD';//币种名称
  3913. $post['freight'] = 0;//运费
  3914. $post['expressmoney'] = 0;//物流金额
  3915. $post['shouldmoney'] = 0;//应收金额
  3916. if($post['print'] != 3)
  3917. {
  3918. $post['librarynot'] = "订单未打印";//不能出库原因
  3919. }
  3920. $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
  3921. $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
  3922. $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  3923. $post['user'] = $shop['shopuser'];//店铺负责人
  3924. $post['orderinfo'] = $value['0'];//订单号
  3925. $post['type'] = $value['7'];//发货仓库
  3926. $post['shop'] = $shop['id'];//店铺
  3927. $post['shouldmoney'] = $value['3'];//订单金额
  3928. $post['product'] = $value['4']?$value['4']:'';//商品名称
  3929. $post['pay'] = $value['5'];//付款方式
  3930. $post['paypal'] = $value['1']?$value['1']:'';//交易号
  3931. $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
  3932. $post['shipremarks'] = $value['9'];//仓库品名
  3933. $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
  3934. $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
  3935. $post['phone'] = $value['12'];//电话
  3936. $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
  3937. if(!$ct)
  3938. {
  3939. $ed[] = array($value['0'].'-无此国家');
  3940. $i++;continue;
  3941. }
  3942. $post['country'] = $ct['id'];//国家
  3943. $post['al'] = $ct['lb'];//国家二字码
  3944. $post['province'] = $value['14'];//省、州
  3945. $post['city'] = $value['15'];//城市
  3946. $post['zipcode'] = $value['16'];//邮编
  3947. $post['address'] = $value['17'];//地址1
  3948. $post['address2'] = $value['18']?$value['18']:'';//地址2
  3949. $yga = $value['3'];$ygb = $shop['estimaterate'];
  3950. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  3951. $post['sbpm'] = $value['19'];//申报品名
  3952. $post['zwpm'] = $value['20'];//中文品名
  3953. $post['ts'] = $value['21'];//条数
  3954. $post['dtsbjz'] = $value['22'];//单条申报价
  3955. $post['zsbjz'] = $value['23'];//总申报价
  3956. $post['zzl'] = $value['24'];//总重量
  3957. $post['zjs'] = $value['25'];//总件数
  3958. $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
  3959. if(!$express)
  3960. {
  3961. $ed[] = array($value['0'].'-无此快递方式');
  3962. $i++;continue;
  3963. }
  3964. $post['express'] = $express['id'];//快递
  3965. $post['printtype'] = 1;//打印类型 1.运单.2.发货单
  3966. $post['fpdata'] = '';//购买产品内容
  3967. $this->fullordersmt->insert($post);
  3968. }
  3969. else
  3970. {
  3971. $ed[] = array($value['0'].'-单号错误或重复操作');
  3972. $i++;
  3973. }
  3974. sleep(2);//停留2秒
  3975. }
  3976. if($i+$j > 0)
  3977. {
  3978. $time = date('Ymd',time());
  3979. $title = '错误信息-'.$time;
  3980. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3981. $tail = "\n";
  3982. $filename = $title.".xls";
  3983. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3984. $dir = '/data/excel/'.$time.'/';
  3985. $file_name = 'error_'.$time.rand(1000,9999);
  3986. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3987. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3988. fwrite($myfile,$ecl);
  3989. fclose($myfile);
  3990. $error = $dir.$file_name.'.xls';
  3991. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3992. }
  3993. else
  3994. {
  3995. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3996. }
  3997. }
  3998. else
  3999. {
  4000. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  4001. }
  4002. }
  4003. public function _scwd()
  4004. {
  4005. $dir = '/data/excel/'.date('Ymd',time()).'/';
  4006. $config['upload_path'] = '.'.$dir ;
  4007. $config['allowed_types'] = '*';
  4008. $config['max_size'] = 102400;
  4009. $this->load->library('upload', $config);
  4010. $this->upload->initialize($config);
  4011. if ($this->upload->do_upload('userfile'))
  4012. {
  4013. $full_path = $dir.$this->upload->data('file_name');
  4014. echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
  4015. }
  4016. else
  4017. {
  4018. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  4019. }
  4020. }
  4021. public function _jmexcel()
  4022. {
  4023. $setting = $this->setting->get_settings();
  4024. $excelpass = $setting['excelpass'];
  4025. $excelusernum = $setting['excelusernum'];
  4026. $exceljmnum = $setting['exceljmnum'];
  4027. $user = $this->user->get_api($_SESSION['api']);
  4028. if(!isset($user['exceltime']))
  4029. {
  4030. $this->session->sess_destroy();
  4031. header("Location:/");
  4032. }
  4033. $post = $this->input->post(NULL, TRUE);
  4034. if(isset($post['data']))
  4035. {
  4036. $data = $this->input->post('data',true);
  4037. $data = str_replace("\n",",",$data);;
  4038. $data = explode(',',trim($data,','));
  4039. $d = '';$i = 0;
  4040. foreach ($data as $v)
  4041. {
  4042. if($v == '')
  4043. {
  4044. continue;
  4045. }
  4046. $j = $this->setting->get_jmexcelpass($v);
  4047. if($j == '')
  4048. {
  4049. $j = $v.' 信息不正确';
  4050. }
  4051. $d .= $j."<br />";
  4052. $i++;
  4053. }
  4054. if($i > $exceljmnum)
  4055. {
  4056. echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
  4057. }
  4058. if($user['exceltime'] != date('Ymd',time()))
  4059. {
  4060. $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
  4061. }
  4062. else
  4063. {
  4064. if($user['excelnum'] > $excelusernum)
  4065. {
  4066. echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
  4067. }
  4068. else
  4069. {
  4070. $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
  4071. }
  4072. }
  4073. echo json_encode(array('msg'=>$d,'success'=>true));exit;
  4074. }
  4075. $this->data['excelpass'] = $excelpass;
  4076. $this->data['excelusernum'] = $excelusernum;
  4077. $this->data['exceljmnum'] = $exceljmnum;
  4078. $this->_Template('fullorderexcel_jmexcel',$this->data);
  4079. }
  4080. //管理
  4081. public function _classid()
  4082. {
  4083. $post = $this->input->post(NULL, TRUE);
  4084. if(isset($post['page']))
  4085. {
  4086. $page = $this->input->post('page',true);
  4087. $perpage = $this->input->post('perpage',true);
  4088. $type = $this->input->post('type',true);
  4089. $where = "1=1 ";
  4090. //数据排序
  4091. $order_str = "id asc";
  4092. if(empty($page))
  4093. {
  4094. $start = 0;
  4095. $perpage = 1;
  4096. }
  4097. else
  4098. {
  4099. $start = ($page - 1)*$perpage;
  4100. }
  4101. if($type)
  4102. {
  4103. $where .= " and type = '$type'";
  4104. }
  4105. //取得信息列表
  4106. $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
  4107. $total = $this->fullorderexcelclassid->find_count($where);
  4108. $pagenum = ceil($total/$perpage);
  4109. $over = $total-($start+$perpage);
  4110. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  4111. echo json_encode($rows);exit;
  4112. }
  4113. $this->_Template('fullorderexcel_classid',$this->data);
  4114. }
  4115. //添加
  4116. public function _classidadd()
  4117. {
  4118. $post = $this->input->post(NULL, TRUE);
  4119. if(isset($post['title']))
  4120. {
  4121. if($this->fullorderexcelclassid->insert($post))
  4122. {
  4123. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  4124. }
  4125. else
  4126. {
  4127. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  4128. }
  4129. }
  4130. $this->_Template('fullorderexcel_classidadd',$this->data);
  4131. }
  4132. //修改
  4133. public function _classidedit($arg_array)
  4134. {
  4135. $post = $this->input->post(NULL, TRUE);
  4136. if(isset($post['id']))
  4137. {
  4138. $id = $this->input->post('id',true);
  4139. if($this->fullorderexcelclassid->save($post,$id))
  4140. {
  4141. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  4142. }
  4143. else
  4144. {
  4145. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  4146. }
  4147. }
  4148. $arg_array = $arg_array[0];
  4149. $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
  4150. $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
  4151. $this->_Template('fullorderexcel_classidedit',$this->data);
  4152. }
  4153. }