Fullorderexcel.php 126 KB

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