Fullorderexcel.php 132 KB

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