Fullorderexcel.php 125 KB

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