Fullorderexcel.php 124 KB

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