Fullorderexcel.php 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108
  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. }else{
  1488. $sku_gradefpdata_str .= " --<br/>";
  1489. $sku_colorfpdata_str .= " --<br/>";
  1490. $sku_densityfpdata_str .= " --<br/>";
  1491. $sku_hairnumberfpdata_str .= " --<br/>";
  1492. $sku_lacetypefpdata_str .= " --<br/>";
  1493. }
  1494. }
  1495. }
  1496. return [
  1497. 'gradefpdata' => trim($sku_gradefpdata_str,"<br/>"),
  1498. 'colorfpdata' => trim($sku_colorfpdata_str,"<br/>"),
  1499. 'densityfpdata' => trim($sku_densityfpdata_str,"<br/>"),
  1500. 'hairnumberfpdata' => trim($sku_hairnumberfpdata_str,"<br/>"),
  1501. 'lacetypefpdata' => trim($sku_lacetypefpdata_str,"<br/>"),
  1502. ];
  1503. }
  1504. //导出订单excel
  1505. public function _excelhz()
  1506. {
  1507. $fgshop = "";$sid = "";$excelshop="";
  1508. if(isset($_SESSION['api']))
  1509. {
  1510. $user = $this->user->get_api($_SESSION['api']);
  1511. $usp = $user;
  1512. $usersp = explode('|',trim($user['shop'],'|'));
  1513. foreach ($usersp as $value)
  1514. {
  1515. $fgshop .= " shop = ".$value." or";
  1516. $sid .= " id = ".$value." or";
  1517. }
  1518. $userexcel = explode('|',trim($user['excelshop'],'|'));
  1519. if($user['excelshop'] == '')
  1520. {
  1521. echo "没有下载权限";exit;
  1522. }
  1523. foreach ($userexcel as $value)
  1524. {
  1525. $excelshop .= " shop = ".$value." or";
  1526. }
  1527. if($excelshop != "")
  1528. {
  1529. $excelshop = "(".rtrim($excelshop,'or').")";
  1530. }
  1531. }
  1532. if(isset($_GET['fexcel']))
  1533. {
  1534. $typeclass = array();
  1535. $tclass = $this->typeclass->find_all();
  1536. foreach ($tclass as $v)
  1537. {
  1538. $typeclass[$v['id']] = $v;
  1539. }
  1540. $dowid = $this->input->get('a');
  1541. $wid = "";
  1542. if($dowid != "")
  1543. {
  1544. $id_arr = explode(',',rtrim($dowid,','));
  1545. $wid .= " id = 0 or";
  1546. foreach ($id_arr as $v)
  1547. {
  1548. $wid .= " id = '$v' or";
  1549. }
  1550. $wid = " and".rtrim($wid,'or');
  1551. }
  1552. $fexcel = $this->input->get('fexcel',true);
  1553. $page = $this->input->get('page',true);
  1554. $perpage = $this->input->get('perpage',true);
  1555. $warehouse = $this->input->get('warehouse',true);
  1556. $timetk = $this->input->get('timetk',true);
  1557. $timetj = $this->input->get('timetj',true);
  1558. $shop = $this->input->get('shop',true);
  1559. $source = $this->input->get('source',true);
  1560. $state = $this->input->get('state',true);
  1561. $review = $this->input->get('review',true);
  1562. $type = $this->input->get('type',true);
  1563. $express = $this->input->get('express',true);
  1564. $orderinfo = $this->input->get('orderinfo',true);
  1565. $user = $this->input->get('user',true);
  1566. $client = $this->input->get('name',true);
  1567. $waybill = $this->input->get('waybill',true);
  1568. $number = $this->input->get('number',true);
  1569. $email = $this->input->get('email',true);
  1570. $dlz = $this->input->get('dlz',true);
  1571. $library = $this->input->get('library',true);
  1572. $libraryconfirm = $this->input->get('libraryconfirm',true);
  1573. $print = $this->input->get('print',true);
  1574. $timetkk = $this->input->get('timetkk',true);
  1575. $timetjj = $this->input->get('timetjj',true);
  1576. $xztime = $this->input->get('xztime',true);
  1577. $country = $this->input->get('country',true);
  1578. $zf = $this->input->get('zf',true);
  1579. $pay = $this->input->get('pay',true);
  1580. $phone = $this->input->get('phone',true);
  1581. $so = $this->input->get('so',true);
  1582. $sfxh = $this->input->get('sfxh',true);
  1583. $xdcs = $this->input->get('xdcs',true);
  1584. $xdcs = $this->input->get('xdcs',true);
  1585. $dbapi = $this->input->get('dbapi',true);
  1586. $orderurl = $this->input->get('orderurl',true);
  1587. $timetk = strtotime($timetk);
  1588. $timetj = strtotime($timetj);
  1589. $timetkk = strtotime($timetkk);
  1590. $timetjj = strtotime($timetjj);
  1591. $px = $this->input->get('px',true);
  1592. $fexcel = $this->fullorderexcel->read($fexcel);
  1593. $classid = $this->fullorderexcelclassid->read($fexcel['type']);
  1594. $where = "1 = 1 and (".rtrim($fgshop,'or').")";
  1595. if($warehouse)
  1596. {
  1597. $where .= " and type = '$warehouse'";
  1598. }
  1599. if($xztime)
  1600. {
  1601. if($timetk && $timetj)
  1602. {
  1603. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  1604. }
  1605. if($timetkk && $timetjj)
  1606. {
  1607. $where .= " and ".$xztime." > '$timetkk' and ".$xztime." < '$timetjj'";
  1608. }
  1609. }
  1610. else
  1611. {
  1612. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  1613. }
  1614. if($library)
  1615. {
  1616. $where .= " and library = '$library'";
  1617. }
  1618. if($print)
  1619. {
  1620. $where .= " and print = '$print'";
  1621. }
  1622. if($shop)
  1623. {
  1624. $where .= " and shop = '$shop'";
  1625. }
  1626. if($source)
  1627. {
  1628. if($source == '2d')
  1629. {
  1630. $where .= " and source >= '2'";
  1631. }
  1632. else
  1633. {
  1634. $where .= " and source = '$source'";
  1635. }
  1636. }
  1637. if($state)
  1638. {
  1639. $where .= " and state = '$state'";
  1640. }
  1641. if($review)
  1642. {
  1643. $where .= " and review = '$review'";
  1644. }
  1645. if($type)
  1646. {
  1647. $where .= " and type = '$type'";
  1648. }
  1649. if($express)
  1650. {
  1651. $where .= " and express = '$express'";
  1652. }
  1653. if($orderinfo)
  1654. {
  1655. $where .= " and orderinfo = '$orderinfo'";
  1656. }
  1657. if($user)
  1658. {
  1659. $where .= " and user = '$user'";
  1660. }
  1661. if($client)
  1662. {
  1663. $where .= " and client like '%$client%'";
  1664. }
  1665. if($waybill)
  1666. {
  1667. $where .= " and waybill = '$waybill'";
  1668. }
  1669. if($number)
  1670. {
  1671. $where .= " and number = '$number'";
  1672. }
  1673. if($email)
  1674. {
  1675. $where .= " and email = '$email'";
  1676. }
  1677. if($country)
  1678. {
  1679. $where .= " and country = '$country'";
  1680. }
  1681. if($dlz)
  1682. {
  1683. $where .= " and waybill != '' and dlz = 0";
  1684. }
  1685. if($libraryconfirm)
  1686. {
  1687. $where .= " and libraryconfirm = '$libraryconfirm'";
  1688. }
  1689. if($so)
  1690. {
  1691. $where .= " and shipremarks like '%$so%'";
  1692. }
  1693. if($pay)
  1694. {
  1695. $where .= " and pay = '$pay'";
  1696. }
  1697. if($phone)
  1698. {
  1699. $where .= " and phone = '$phone'";
  1700. }
  1701. if($sfxh != '')
  1702. {
  1703. $where .= " and sfxh = '$sfxh'";
  1704. }
  1705. if($orderurl)
  1706. {
  1707. $url = $this->orderurl->read($orderurl);
  1708. $where .= " and link like '%".$url['url']."%'";
  1709. }
  1710. if($zf)
  1711. {
  1712. if($zf == 1)
  1713. {
  1714. $where .= " and paypal not like '%-%-%-%'";
  1715. }
  1716. else
  1717. {
  1718. $where .= " and paypal like '%-%-%-%'";
  1719. }
  1720. }
  1721. $sj = $this->input->get('sj',true);
  1722. if($sj)
  1723. {
  1724. $sj = $this->input->get('sj',true);
  1725. }
  1726. else
  1727. {
  1728. $sj = $classid['type'];
  1729. }
  1730. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  1731. foreach ($fexceleq as $k=>$v)
  1732. {
  1733. $fexceleq[$k] = explode('-',$v);
  1734. $num[$k] = $fexceleq[$k][0];
  1735. }
  1736. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  1737. $feq = "";$kong = array();$sku9610 = '';
  1738. foreach ($fexceleq as $k=>$v)
  1739. {
  1740. if(isset($v[1]))
  1741. {
  1742. if($v[1] == 'klarnabill' || $v[1] == 'klarnaship' || $v[1] == 'PPname' || $v[1] == 'PPaddress' || $v[1] == 'PPemail' || $v[1] == 'afterpayship' || $v[1] == 'afterpaybill')
  1743. {
  1744. $feq .= 'klarnadata,';
  1745. }
  1746. if($v[1] == 'ccfpdata' || $v[1] == 'cpfpdata' || $v[1] == 'dbapi' || $v[1] == 'scapi')
  1747. {
  1748. $feq .= 'fpdata,';
  1749. }
  1750. if($v[1] != 'kong')//空值去除
  1751. {
  1752. if($v[1] == '9610sku' || $v[1] == 'issku' || $v[1] == 'sku')
  1753. {
  1754. if($v[1] == '9610sku')
  1755. {
  1756. $sku9610 = 1;
  1757. }
  1758. if($sj == 'fullordersmt')
  1759. {
  1760. $v[1] = 'sku';
  1761. }
  1762. else
  1763. {
  1764. $v[1] = 'issku';
  1765. }
  1766. }
  1767. $feq .= $v[1].',';
  1768. }
  1769. else
  1770. {
  1771. $kong[$v[0]] = 1;
  1772. }
  1773. }
  1774. }
  1775. //处理额外加上的subtotal和rowtoal 但是不想在表中加太多字段 想着以后有关金额的都给怼到extra_price字段中
  1776. if((strpos($feq,'subtotal')!= false)||(strpos($feq,'rowtotal')!= false) ||(strpos($feq,'product_id')!= false)){
  1777. if(strpos($feq,'subtotal')!= false){
  1778. $feq = str_replace('subtotal,',"extra_price as subtotal,",$feq);
  1779. }
  1780. if(strpos($feq,'rowtotal')!= false){
  1781. $feq = str_replace('rowtotal,',"extra_price as rowtotal,",$feq);
  1782. }
  1783. if(strpos($feq,'product_id')!= false){
  1784. $feq = str_replace('product_id,',"extra_price as product_id,",$feq);
  1785. }
  1786. }
  1787. $typeclass_lpdl = [];
  1788. //料品大类
  1789. if(strpos($feq,'lpdl')!= false){
  1790. $feq = str_replace('lpdl,',"fpdata as lpdl,",$feq);
  1791. $tmp_typeclass_lpdl = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',16)->get()->result_array();
  1792. $typeclass_lpdl = array_column($tmp_typeclass_lpdl,'zh','id');
  1793. }
  1794. $typeclass_lhdycc = [];
  1795. //料号对应尺寸
  1796. if(strpos($feq,'lhdycc')!= false){
  1797. $feq = str_replace('lhdycc,',"fpdata as lhdycc,",$feq);
  1798. $tmp_typeclass_lhdycc = $this->db->from('typeclass')->select("id,title,zh,classid")->where('classid',14)->get()->result_array();
  1799. $typeclass_lhdycc = array_column($tmp_typeclass_lhdycc,'zh','id');
  1800. }
  1801. $feq = rtrim($feq,',');
  1802. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  1803. foreach ($fexcelzhw as $k=>$v)
  1804. {
  1805. $fexcelzhw[$k] = explode('-',$v);
  1806. $numb[$k] = $fexcelzhw[$k][0];
  1807. }
  1808. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  1809. $fexcelzh = array();
  1810. foreach ($fexcelzhw as $k=>$v)
  1811. {
  1812. $fexcelzh[] = $v[1];
  1813. }
  1814. if($px)
  1815. {
  1816. $order_str = $px." desc";
  1817. }
  1818. else
  1819. {
  1820. $order_str = "id desc";
  1821. }
  1822. // if($_GET['fexcel'] == '157'){
  1823. // $this->logic_ding->sendToDing("excel导出的【".$where.$wid.' and '.$excelshop);
  1824. // $this->logic_ding->sendToDing("excel导出的【".'id,'.$feq);
  1825. // $this->logic_ding->sendToDing("excel导出的【".$order_str);
  1826. // $this->logic_ding->sendToDing("excel导出的SJ【".$sj);
  1827. // }
  1828. $extra = [
  1829. 'usp'=>$usp,
  1830. 'sku9610'=>$sku9610,
  1831. 'typeclass_lpdl'=>$typeclass_lpdl,
  1832. 'typeclass_lhdycc'=>$typeclass_lhdycc
  1833. ];
  1834. $dlz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorder',$extra);
  1835. $tt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordertt',$extra);
  1836. $smt_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullordersmt',$extra);
  1837. $amz_ret = $this->_datahz($where.$wid.' and '.$excelshop,'id,'.$feq,$order_str,'fullorderamz',$extra);
  1838. $info_list = array_merge( $dlz_ret['info_list'],$tt_ret['info_list'],$smt_ret['info_list'],$amz_ret['info_list']);
  1839. $shouldmoney = $dlz_ret['shouldmoney']+$tt_ret['shouldmoney']+$smt_ret['shouldmoney']+$amz_ret['shouldmoney'];
  1840. $fzh = "";
  1841. foreach ($fexcelzh as $v)
  1842. {
  1843. $fzh .= "<td>".$v."</td>";
  1844. }
  1845. $data = array($shouldmoney.' CNY');
  1846. $title = $fexcel['title'].'-'.date('Ymd',time());
  1847. $titlename = "<table border=1>
  1848. <tr>"
  1849. .$fzh.
  1850. "</tr>
  1851. </table>";
  1852. $tail = "\n";
  1853. $filename = $title.".xls";
  1854. $this->excel->get_fz5($info_list,$titlename,$filename,$tail,$kong);
  1855. }
  1856. }
  1857. public function _datahz($where,$field,$order_str,$sj,$extra){
  1858. //取得信息列表
  1859. $info_list = $this->$sj->find_all($where,$field,$order_str);
  1860. //格式化数据
  1861. $i = 1;$shouldmoney = 0;$hl=1;
  1862. $usp = $extra['usp'];
  1863. $sku9610 = $extra['sku9610'];
  1864. $typeclass_lpdl = $extra['typeclass_lpdl'];
  1865. $typeclass_lhdycc = $extra['typeclass_lhdycc'];
  1866. foreach ($info_list as $key=>$value)
  1867. {
  1868. $data = $this->$sj->read($value['id']);
  1869. $data = str_replace(array("'"),array("’"),$data);
  1870. if(isset($value['email']) && $usp['excelpass'] == '1')
  1871. {
  1872. $emailpass = $this->setting->get_excelpass($value['email']);
  1873. $info_list[$key]['email'] = $emailpass;
  1874. }
  1875. if(isset($value['phone']) && $usp['excelpass'] == '1')
  1876. {
  1877. $phonepass = $this->setting->get_excelpass($value['phone']);
  1878. $info_list[$key]['phone'] = $phonepass;
  1879. }
  1880. if(isset($value['currencytitle']))
  1881. {
  1882. if($value['currencytitle'] != "CNY")
  1883. {
  1884. $hl=$value['hl'];
  1885. }
  1886. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  1887. }
  1888. if(isset($value['shop']))
  1889. {
  1890. $shop = $this->shop->read($value['shop']);
  1891. $info_list[$key]['shop'] = $shop['shopname'];
  1892. }
  1893. if(isset($value['dtime']))
  1894. {
  1895. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  1896. }
  1897. if(isset($value['printtime']))
  1898. {
  1899. if($value['printtime'] > 0)
  1900. {
  1901. $info_list[$key]['printtime'] = date('Y-m-d H:i:s',$value['printtime']);
  1902. }
  1903. }
  1904. if(isset($value['sku']))
  1905. {
  1906. if($sku9610 == '1')
  1907. {
  1908. $aesku = explode(';',$value['sku']);
  1909. $aesku = $aesku[0];
  1910. $aesku = explode(':',$aesku);
  1911. if(count($aesku) > 1)
  1912. {
  1913. $aesku = $aesku[1];
  1914. $aesku = str_replace('--','~',$aesku);
  1915. $aesku = explode('-',$aesku);
  1916. $aesku = $aesku[0];
  1917. $aesku = str_replace('~','--',$aesku);
  1918. $info_list[$key]['sku'] = $aesku;
  1919. }
  1920. else
  1921. {
  1922. $info_list[$key]['sku'] = '';
  1923. }
  1924. }
  1925. else
  1926. {
  1927. $info_list[$key]['sku'] = $value['sku'];
  1928. }
  1929. }
  1930. if(isset($value['issku']))
  1931. {
  1932. $value['issku'] = str_replace(array('&lt;','&gt;'),array('<','>'),$value['issku']);
  1933. if($sku9610 == '1')
  1934. {
  1935. $aesku = explode(';',$value['issku']);
  1936. $aesku = $aesku[0];
  1937. $aesku = str_replace('--','~',$aesku);
  1938. $aesku = explode('-',$aesku);
  1939. $aesku = $aesku[0];
  1940. $aesku = str_replace('~','--',$aesku);
  1941. $aesku = str_replace(array('<','>'),array('&lt;','&gt;'),$aesku);
  1942. $info_list[$key]['issku'] = $aesku;
  1943. }
  1944. else
  1945. {
  1946. $value['issku'] = str_replace(array('<','>'),array('&lt;','&gt;'),$value['issku']);
  1947. $info_list[$key]['issku'] = $value['issku'];
  1948. }
  1949. }
  1950. if(isset($value['subtotal'])){
  1951. $tmp_sub_str = "";
  1952. $subtotal_list = json_decode($value['subtotal'],true);
  1953. foreach($subtotal_list as $v){
  1954. if(isset($v['sub_total'])){
  1955. $tmp_sub_str .= sprintf( "%.2f",$v['sub_total'])."<br>";
  1956. }else{
  1957. $tmp_sub_str .= "0<br>";
  1958. }
  1959. }
  1960. $info_list[$key]['subtotal'] = $tmp_sub_str;
  1961. }
  1962. if(isset($value['rowtotal'])){
  1963. $tmp_sub_str = "";
  1964. $subtotal_list = json_decode($value['rowtotal'],true);
  1965. foreach($subtotal_list as $v){
  1966. if(isset($v['row_total'])){
  1967. $tmp_sub_str .= sprintf( "%.2f",$v['row_total'])."<br>";
  1968. }else{
  1969. $tmp_sub_str .= "0<br>";
  1970. }
  1971. }
  1972. $info_list[$key]['rowtotal'] = $tmp_sub_str;
  1973. }
  1974. if(isset($value['lpdl'])){
  1975. $tmp_lpdl_str ="";
  1976. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  1977. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  1978. foreach($tmp_fpdata_arr as $v){
  1979. if(empty($v)){
  1980. continue;
  1981. }
  1982. $tmp_arr = explode('-',$v);
  1983. if(isset($typeclass_lpdl[$tmp_arr[1]])){
  1984. $tmp_lpdl_str .= $typeclass_lpdl[$tmp_arr[1]]."<br>";
  1985. }else{
  1986. $tmp_lpdl_str .= " ";
  1987. }
  1988. }
  1989. $info_list[$key]['lpdl'] = trim($tmp_lpdl_str,"<br>") ;
  1990. }
  1991. if(isset($value['lhdycc'])){
  1992. $tmp_lhdycc_str ="";
  1993. $tmp_fpdata_arr = explode(';',trim($value['fpdata'],';'));
  1994. $tmp_fpdata_arr = array_filter($tmp_fpdata_arr);
  1995. foreach($tmp_fpdata_arr as $v){
  1996. if(empty($v)){
  1997. continue;
  1998. }
  1999. if(stripos($v,',') !== false){
  2000. $tmp_arr = explode(',',$v);
  2001. if(isset($typeclass_lhdycc[$tmp_arr[0]])){
  2002. $tmp_lhdycc_str .= $typeclass_lhdycc[$tmp_arr[0]]."<br>";
  2003. }else{
  2004. $tmp_lhdycc_str .= "异常 <br>";
  2005. }
  2006. }else{
  2007. $tmp_lhdycc_str .= "无 <br>";
  2008. }
  2009. }
  2010. $info_list[$key]['lhdycc'] = trim($tmp_lhdycc_str,"<br>") ;
  2011. }
  2012. if(isset($value['product_id'])){
  2013. $tmp_product_id = "";
  2014. $product_ids = json_decode($value['product_id'],true);
  2015. foreach($product_ids as $v){
  2016. if(isset($v['product_id'])){
  2017. $tmp_product_id .= $v['product_id']."<br>";
  2018. }else{
  2019. $tmp_product_id .= "<br>";
  2020. }
  2021. }
  2022. $info_list[$key]['product_id'] = $tmp_product_id;
  2023. }
  2024. if(isset($value['librarytime']))
  2025. {
  2026. if($value['librarytime'] > 0)
  2027. {
  2028. $info_list[$key]['librarytime'] = date('Y-m-d H:i:s',$value['librarytime']);
  2029. }
  2030. }
  2031. if(isset($value['buytime']))
  2032. {
  2033. if($value['buytime'] > 0)
  2034. {
  2035. $info_list[$key]['buytime'] = date('Y-m-d H:i:s',$value['buytime']);
  2036. }
  2037. }
  2038. if(isset($value['country']))
  2039. {
  2040. $country = $this->country->read($value['country']);
  2041. $info_list[$key]['country'] = $country['name'];
  2042. }
  2043. if(isset($value['street']))//暂时用街道导出州二字码
  2044. {
  2045. if($data['country'] == 192)//如果是美国
  2046. {
  2047. $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');
  2048. $data['province'] = preg_replace('/( | |\s)/',' ',$data['province']);
  2049. $data['province'] = trim($data['province'],' ');
  2050. if(isset($ToState[strtolower($data['province'])]))
  2051. {
  2052. $dataprovince = strlen($data['province'])==2?$data['province']:$ToState[strtolower($data['province'])];
  2053. }
  2054. else
  2055. {
  2056. $dataprovince = '';
  2057. }
  2058. $info_list[$key]['street'] = $dataprovince;
  2059. }
  2060. else
  2061. {
  2062. $info_list[$key]['street'] = '';
  2063. }
  2064. }
  2065. if(isset($value['pay']))
  2066. {
  2067. if(empty($value['pay'])){
  2068. $info_list[$key]['pay'] = "";
  2069. }else{
  2070. if($sj =='fullorder'){
  2071. $pay = $this->typeclass->read($value['pay']);
  2072. $info_list[$key]['pay'] = $pay['title'];
  2073. }
  2074. }
  2075. }
  2076. if(isset($value['type']))
  2077. {
  2078. $type = $this->warehouse->read($value['type']);
  2079. $info_list[$key]['type'] = $type['title'];
  2080. }
  2081. if(isset($value['express']))
  2082. {
  2083. $express = $this->express->read($value['express']);
  2084. if($express)
  2085. {
  2086. $info_list[$key]['express'] = $express['servicename'];
  2087. }
  2088. else
  2089. {
  2090. $info_list[$key]['express'] = '未选择';
  2091. }
  2092. }
  2093. if(isset($value['ccfpdata']))
  2094. {
  2095. $ccfpdata = explode(';',$value['fpdata']);
  2096. $inc = 0;
  2097. foreach ($ccfpdata as $v)
  2098. {
  2099. if(stripos($v,',') !== false)
  2100. {
  2101. $cc = explode(',',$v);
  2102. $inctype = $this->typeclass->read($cc[0]);
  2103. if(is_numeric($inctype['spare']))
  2104. {
  2105. if($inctype['spare'] > $inc)
  2106. {
  2107. $inc = $inctype['spare'];
  2108. }
  2109. }
  2110. }
  2111. }
  2112. $info_list[$key]['ccfpdata'] = $inc.'inch';
  2113. }
  2114. if(isset($value['printtype']))
  2115. {
  2116. if($value['printtype'] == 1)
  2117. {
  2118. $info_list[$key]['printtype'] = '运单';
  2119. }
  2120. else if($value['printtype'] == 2)
  2121. {
  2122. $info_list[$key]['printtype'] = '发货单';
  2123. }
  2124. else if($value['printtype'] == 3)
  2125. {
  2126. $info_list[$key]['printtype'] = '不打印单据';
  2127. }
  2128. else
  2129. {
  2130. $info_list[$key]['printtype'] = '未选择';
  2131. }
  2132. }
  2133. if(isset($value['exstate']))
  2134. {
  2135. if($value['exstate'] == '99')
  2136. {
  2137. $info_list[$key]['exstate'] = '未获取到物流信息';
  2138. }
  2139. else if($value['exstate'] == '1')
  2140. {
  2141. $info_list[$key]['exstate'] = '已揽收';
  2142. }
  2143. else if($value['exstate'] == '2')
  2144. {
  2145. $info_list[$key]['exstate'] = '在途中';
  2146. }
  2147. else if($value['exstate'] == '3')
  2148. {
  2149. $info_list[$key]['exstate'] = '派送中';
  2150. }
  2151. else if($value['exstate'] == '4')
  2152. {
  2153. $info_list[$key]['exstate'] = '已签收';
  2154. }
  2155. else if($value['exstate'] == '5')
  2156. {
  2157. $info_list[$key]['exstate'] = '派送异常';
  2158. }
  2159. else
  2160. {
  2161. $info_list[$key]['exstate'] = '';
  2162. }
  2163. }
  2164. if(isset($value['link']))
  2165. {
  2166. if($value['link'] != '')
  2167. {
  2168. $link = explode(',',$value['link']);
  2169. $info_list[$key]['link'] = $link[0];
  2170. }
  2171. else
  2172. {
  2173. $info_list[$key]['link'] = '';
  2174. }
  2175. }
  2176. if(isset($value['klarnabill']))
  2177. {
  2178. $klarnadata = explode('|',$value['klarnadata']);
  2179. if(isset($klarnadata[2]))
  2180. {
  2181. $info_list[$key]['klarnabill'] = $klarnadata[2];
  2182. }
  2183. else
  2184. {
  2185. $info_list[$key]['klarnabill'] = '';
  2186. }
  2187. }
  2188. if(isset($value['klarnaship']))
  2189. {
  2190. $klarnadata = explode('|',$value['klarnadata']);
  2191. if(isset($klarnadata[3]))
  2192. {
  2193. $info_list[$key]['klarnaship'] = $klarnadata[3];
  2194. }
  2195. else
  2196. {
  2197. $info_list[$key]['klarnaship'] = '';
  2198. }
  2199. }
  2200. if(isset($value['afterpaybill']))
  2201. {
  2202. $klarnadata = explode('|',$value['klarnadata']);
  2203. if(isset($klarnadata[1]))
  2204. {
  2205. $info_list[$key]['afterpaybill'] = $klarnadata[1];
  2206. }
  2207. else
  2208. {
  2209. $info_list[$key]['afterpaybill'] = '';
  2210. }
  2211. }
  2212. if(isset($value['afterpayship']))
  2213. {
  2214. $klarnadata = explode('|',$value['klarnadata']);
  2215. if(isset($klarnadata[2]))
  2216. {
  2217. $info_list[$key]['afterpayship'] = $klarnadata[2];
  2218. }
  2219. else
  2220. {
  2221. $info_list[$key]['afterpayship'] = '';
  2222. }
  2223. }
  2224. if(isset($value['PPname']))
  2225. {
  2226. $info_list[$key]['PPname'] = '';
  2227. $klarnadata = explode('|',$value['klarnadata']);
  2228. if(isset($klarnadata[1]))
  2229. {
  2230. $klarnadata = json_decode($klarnadata[1],true);
  2231. if(isset($klarnadata['name']))
  2232. {
  2233. $info_list[$key]['PPname'] = $klarnadata['name'];
  2234. }
  2235. }
  2236. }
  2237. if(isset($value['PPemail']))
  2238. {
  2239. $info_list[$key]['PPemail'] = '';
  2240. $klarnadata = explode('|',$value['klarnadata']);
  2241. if(isset($klarnadata[1]))
  2242. {
  2243. $klarnadata = json_decode($klarnadata[1],true);
  2244. if(isset($klarnadata['email']))
  2245. {
  2246. if($usp['excelpass'] == '1')
  2247. {
  2248. $ppemailpass = $this->setting->get_excelpass($klarnadata['email']);
  2249. }
  2250. else
  2251. {
  2252. $ppemailpass = $klarnadata['email'];
  2253. }
  2254. $info_list[$key]['PPemail'] = $ppemailpass;
  2255. }
  2256. }
  2257. }
  2258. if(isset($value['PPaddress']))
  2259. {
  2260. $info_list[$key]['PPaddress'] = '';
  2261. $klarnadata = explode('|',$value['klarnadata']);
  2262. if(isset($klarnadata[1]))
  2263. {
  2264. $klarnadata = json_decode($klarnadata[1],true);
  2265. if(isset($klarnadata['address']))
  2266. {
  2267. $info_list[$key]['PPaddress'] = $klarnadata['address'];
  2268. }
  2269. }
  2270. }
  2271. if(isset($value['klarnadata']))
  2272. {
  2273. unset($info_list[$key]['klarnadata']);
  2274. }
  2275. if(isset($value['shippingmethod']))
  2276. {
  2277. $tax = explode('Tax:',$value['shippingmethod']);
  2278. $info_list[$key]['shippingmethod'] = (isset($tax[1]))?trim($tax[1],';'):'';
  2279. }
  2280. if(isset($value['systemwigsout']))
  2281. {
  2282. $out = $this->systemtransfer->find_all("number = '".$data['number']."'");
  2283. $outread = '';
  2284. if($out)
  2285. {
  2286. foreach ($out as $val)
  2287. {
  2288. $list = '';
  2289. $rk = explode('|',trim($val['rk'],'|'));
  2290. $rktime = explode('|',trim($val['rktime'],'|'));
  2291. $zw = array();
  2292. $t = $this->transfer->find_all("1=1");
  2293. foreach ($t as $v)
  2294. {
  2295. $zw[$v['id']] = $v['title'];
  2296. }
  2297. if($val['rk'] != '' && count($rk) > 0)
  2298. {
  2299. for($i=0;$i<count($rk);$i++)
  2300. {
  2301. if(!isset($rktime[$i]))
  2302. {
  2303. $list .= $zw[$cz[$i]];
  2304. }
  2305. else
  2306. {
  2307. $list .= $zw[$rk[$i]].' :'.date('Y-m-d H:i',$rktime[$i]).',';
  2308. }
  2309. }
  2310. }
  2311. $outread .= '<span style="color:#f00">'.$val['pm'].'</span>:'.$list.'<br>';
  2312. }
  2313. }
  2314. else
  2315. {
  2316. $systemwigsout = $this->systemwigsout->find_all("number = '".$data['number']."'");
  2317. if($systemwigsout)
  2318. {
  2319. foreach ($systemwigsout as $v)
  2320. {
  2321. $outread = '';
  2322. if($v['czwarehouse'] == 37)
  2323. {
  2324. $outread .= '华荣厂';
  2325. }
  2326. else if($v['czwarehouse'] == 0)
  2327. {
  2328. $outread .= '龙盈厂';
  2329. }
  2330. $cz = explode('|',trim($v['cz'],'|'));
  2331. $cztime = explode('|',trim($v['cztime'],'|'));
  2332. $zw = $this->transfer->get_list();
  2333. if($v['cz'] != '' && count($cz) > 0)
  2334. {
  2335. for($i=0;$i<count($cz);$i++)
  2336. {
  2337. if(!isset($cztime[$i]))
  2338. {
  2339. $outread .= $zw[$cz[$i]].' -&gt; ';
  2340. }
  2341. else
  2342. {
  2343. $outread .= $zw[$cz[$i]].' :'.date('Y-m-d H:i',$cztime[$i]).' -&gt; ';
  2344. }
  2345. }
  2346. $outread .= '<br>';
  2347. }
  2348. }
  2349. }
  2350. }
  2351. $info_list[$key]['systemwigsout'] = $outread;
  2352. }
  2353. if(isset($value['sourcetype']))
  2354. {
  2355. if($value['sourcetype'] == '1')
  2356. {
  2357. $info_list[$key]['sourcetype'] = '网红单';
  2358. }
  2359. else if($value['sourcetype'] == '2')
  2360. {
  2361. $info_list[$key]['sourcetype'] = '批发单';
  2362. }
  2363. else if($value['sourcetype'] == '3')
  2364. {
  2365. $info_list[$key]['sourcetype'] = '线下单';
  2366. }
  2367. else if($value['sourcetype'] == '4')
  2368. {
  2369. $info_list[$key]['sourcetype'] = '售后单';
  2370. }
  2371. else if($value['sourcetype'] == '5')
  2372. {
  2373. $info_list[$key]['sourcetype'] = '其它';
  2374. }
  2375. else
  2376. {
  2377. $info_list[$key]['sourcetype'] = '';
  2378. }
  2379. }
  2380. if(isset($value['js']))
  2381. {
  2382. if($value['js'] == '0')
  2383. {
  2384. $info_list[$key]['js'] = 'Ground Advantage';
  2385. }
  2386. else if($value['js'] == '1')
  2387. {
  2388. $info_list[$key]['js'] = 'PRIORITY';
  2389. }
  2390. else if($value['js'] == '2')
  2391. {
  2392. $info_list[$key]['js'] = 'EXPRESS';
  2393. }
  2394. else if($value['js'] == '3')
  2395. {
  2396. $info_list[$key]['js'] = 'IP';
  2397. }
  2398. else if($value['js'] == '4')
  2399. {
  2400. $info_list[$key]['js'] = 'FICP';
  2401. }
  2402. }
  2403. if(isset($value['type']))
  2404. {
  2405. $type = $this->warehouse->read($value['type']);
  2406. $info_list[$key]['type'] = $type['title'];
  2407. }
  2408. if(isset($value['xdcs']))
  2409. {
  2410. if($sj == 'fullorder')
  2411. {
  2412. $xdcs = $this->customer->get_email($data['email'],$data['shop']);
  2413. }
  2414. else
  2415. {
  2416. $xdcs = $this->customersmt->get_shopdata($data['shop'],$data['name'],$data['address']);
  2417. }
  2418. $info_list[$key]['xdcs'] = (isset($xdcs['num']))?(($xdcs['num']==0)?1:$xdcs['num']):1;
  2419. }
  2420. if(isset($value['dbapi']) || isset($value['scapi']))
  2421. {
  2422. $jmlist = '';$shuliang = '';
  2423. $classid = $this->classid->sku();
  2424. $dbapi = explode(';',trim($value['fpdata'],';'));
  2425. foreach ($dbapi as $va)
  2426. {
  2427. $pm = $classid;
  2428. $jm = $classid;
  2429. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2430. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2431. $ts = explode('|',trim($features,'|'));
  2432. if(stripos($ts[0],',') !== false)
  2433. {
  2434. $ft = explode(',',$ts[0]);
  2435. $features = explode('-',trim($ft[1],'-'));
  2436. $features[] = $ft[0];
  2437. }
  2438. else
  2439. {
  2440. $features = explode('-',trim($ts[0],'-'));
  2441. }
  2442. foreach($features as $k=>$v)
  2443. {
  2444. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2445. {
  2446. if($typeclass[$v]['bm'] != '')
  2447. {
  2448. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2449. }
  2450. }
  2451. if($v != 0 && isset($typeclass[$v]))
  2452. {
  2453. if($typeclass[$v]['classid'] == 13)
  2454. {
  2455. $dj = $typeclass[$v]['title'];
  2456. }
  2457. if($typeclass[$v]['classid'] == 8)
  2458. {
  2459. $ys = $typeclass[$v]['title'];
  2460. }
  2461. if($typeclass[$v]['classid'] == 15)
  2462. {
  2463. $hx = $typeclass[$v]['title'];
  2464. }
  2465. if(isset($pm[$typeclass[$v]['classid']]))
  2466. {
  2467. if($typeclass[$v]['title'] == '9A')
  2468. {
  2469. $pm[$typeclass[$v]['classid']] = '9A';
  2470. }
  2471. else if($typeclass[$v]['title'] == '10A')
  2472. {
  2473. $pm[$typeclass[$v]['classid']] = '10A';
  2474. }
  2475. else
  2476. {
  2477. $clzh = $typeclass[$v]['zh'];
  2478. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2479. {
  2480. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2481. $clzh = $clzh[0];
  2482. }
  2483. $pm[$typeclass[$v]['classid']] = $clzh;
  2484. }
  2485. }
  2486. if(isset($jm[$typeclass[$v]['classid']]))
  2487. {
  2488. if($typeclass[$v]['jm'])
  2489. {
  2490. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2491. }
  2492. }
  2493. }
  2494. }
  2495. $jm = array_filter($jm);//去除空值
  2496. $jm = implode("-",$jm);
  2497. $jmlist .= $jm.'<br>';
  2498. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2499. $pm = array_filter($pm);//去除空值
  2500. $zh = implode(" ",$pm);
  2501. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2502. }
  2503. if(isset($value['dbapi']))
  2504. {
  2505. $info_list[$key]['dbapi'] = $jmlist;
  2506. }
  2507. else
  2508. {
  2509. $info_list[$key]['scapi'] = $shuliang;
  2510. }
  2511. }
  2512. if(isset($value['dbapi']) && isset($value['scapi']))
  2513. {
  2514. $jmlist = '';$shuliang = '';
  2515. $classid = $this->classid->sku();
  2516. $dbapi = explode(';',trim($value['fpdata'],';'));
  2517. foreach ($dbapi as $va)
  2518. {
  2519. $pm = $classid;
  2520. $jm = $classid;
  2521. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  2522. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$va);
  2523. $ts = explode('|',trim($features,'|'));
  2524. if(stripos($ts[0],',') !== false)
  2525. {
  2526. $ft = explode(',',$ts[0]);
  2527. $features = explode('-',trim($ft[1],'-'));
  2528. $features[] = $ft[0];
  2529. }
  2530. else
  2531. {
  2532. $features = explode('-',trim($ts[0],'-'));
  2533. }
  2534. foreach($features as $k=>$v)
  2535. {
  2536. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  2537. {
  2538. if($typeclass[$v]['bm'] != '')
  2539. {
  2540. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  2541. }
  2542. }
  2543. if($v != 0 && isset($typeclass[$v]))
  2544. {
  2545. if($typeclass[$v]['classid'] == 13)
  2546. {
  2547. $dj = $typeclass[$v]['title'];
  2548. }
  2549. if($typeclass[$v]['classid'] == 8)
  2550. {
  2551. $ys = $typeclass[$v]['title'];
  2552. }
  2553. if($typeclass[$v]['classid'] == 15)
  2554. {
  2555. $hx = $typeclass[$v]['title'];
  2556. }
  2557. if(isset($pm[$typeclass[$v]['classid']]))
  2558. {
  2559. if($typeclass[$v]['title'] == '9A')
  2560. {
  2561. $pm[$typeclass[$v]['classid']] = '9A';
  2562. }
  2563. else if($typeclass[$v]['title'] == '10A')
  2564. {
  2565. $pm[$typeclass[$v]['classid']] = '10A';
  2566. }
  2567. else
  2568. {
  2569. $clzh = $typeclass[$v]['zh'];
  2570. if(stripos($typeclass[$v]['zh'],'|') !== false)
  2571. {
  2572. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  2573. $clzh = $clzh[0];
  2574. }
  2575. $pm[$typeclass[$v]['classid']] = $clzh;
  2576. }
  2577. }
  2578. if(isset($jm[$typeclass[$v]['classid']]))
  2579. {
  2580. if($typeclass[$v]['jm'])
  2581. {
  2582. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  2583. }
  2584. }
  2585. }
  2586. }
  2587. $jm = array_filter($jm);//去除空值
  2588. $jm = implode("-",$jm);
  2589. $jmlist .= $jm.'<br>';
  2590. $shuliang .= (isset($ts[2])?$ts[2]:'未知').'<br>';
  2591. $pm = array_filter($pm);//去除空值
  2592. $zh = implode(" ",$pm);
  2593. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  2594. }
  2595. $info_list[$key]['dbapi'] = $jmlist;
  2596. $info_list[$key]['scapi'] = $shuliang;
  2597. }
  2598. if(isset($value['cpfpdata']))
  2599. {
  2600. $fpread = '';
  2601. $cpfpdata = explode(';',trim($value['fpdata'],';'));
  2602. foreach ($cpfpdata as $v)
  2603. {
  2604. $va = explode('|',trim($v,'|'));
  2605. if(isset($va[1])){
  2606. $fpread .= $va[1].'; ';
  2607. }else{
  2608. $fpread .="合并单没有产品异常标记";
  2609. }
  2610. }
  2611. $info_list[$key]['cpfpdata'] = $fpread;
  2612. }
  2613. unset($info_list[$key]['id']);
  2614. unset($info_list[$key]['fpdata']);
  2615. }
  2616. return [
  2617. 'info_list'=>$info_list,
  2618. 'shouldmoney'=>$shouldmoney
  2619. ];
  2620. }
  2621. //上传运单
  2622. public function _waybill($arg_array)
  2623. {
  2624. $readid = $arg_array[0];
  2625. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2626. /* 订单加入键值-k */
  2627. $fdata = $this->fullorder->find_all('shop = "'.$readid.'" and dtime > "'.(time()-30*24*3600).'" and review > 4 and dlz < 1 and state = 207');
  2628. foreach ($fdata as $v)
  2629. {
  2630. $dataorder[$v['orderinfo']] = $v;
  2631. }
  2632. $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)');
  2633. foreach ($sdata as $v)
  2634. {
  2635. $dataorder[$v['orderinfo']] = $v;
  2636. }
  2637. $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)');
  2638. foreach ($tdata as $v)
  2639. {
  2640. $dataorder[$v['orderinfo']] = $v;
  2641. }
  2642. $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)');
  2643. foreach ($xdata as $v)
  2644. {
  2645. $dataorder[$v['orderinfo']] = $v;
  2646. }
  2647. /* 订单加入键值-j */
  2648. /* 店铺加入键值-j */
  2649. $fshop = $this->shop->find_all('1=1');
  2650. foreach ($fshop as $v)
  2651. {
  2652. $datashop[$v['id']] = $v;
  2653. }
  2654. /* 店铺加入键值-k */
  2655. /* 快递加入键值-j */
  2656. $fex = $this->express->find_all('1=1');
  2657. foreach ($fex as $v)
  2658. {
  2659. $dataex[$v['id']] = $v;
  2660. }
  2661. /* 快递加入键值-k */
  2662. /* 仓库加入键值-k */
  2663. $fwh = $this->warehouse->find_all('1=1');
  2664. foreach ($fwh as $v)
  2665. {
  2666. $datack[$v['id']] = $v;
  2667. }
  2668. /* 仓库加入键值-j */
  2669. $fs = $this->notice->get_ordertatus(216);//216成功状态
  2670. if(is_numeric($readid) == false || $readid < 1)
  2671. {
  2672. echo json_encode(array('msg'=>'店铺信息错误!','success'=>true));exit;
  2673. }
  2674. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2675. $config['upload_path'] = '.'.$dir ;
  2676. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2677. $config['allowed_types'] = 'xls|xlsx|csv';
  2678. $config['max_size'] = 10240;
  2679. $this->load->library('upload', $config);
  2680. $this->upload->initialize($config);
  2681. if ($this->upload->do_upload('userfile'))
  2682. {
  2683. $full_path = $dir.$this->upload->data('file_name');
  2684. $fileName = '.' . $full_path;
  2685. if (!file_exists($fileName))
  2686. {
  2687. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  2688. }
  2689. else
  2690. {
  2691. require_once "./data/excel/PHPExcel/IOFactory.php";
  2692. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  2693. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  2694. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  2695. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  2696. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  2697. ++$column;//如果列数大于26行
  2698. $list = array();
  2699. for ($i = 2; $i <= $row; $i++) // 行数循环
  2700. {
  2701. $data = array();
  2702. for ($c = 'A'; $c != $column; $c++) // 列数循环
  2703. {
  2704. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  2705. }
  2706. $list[] = $data;
  2707. }
  2708. }
  2709. $i = 0;$j = 0;$ed = array();$cscs = array();
  2710. $this->db->trans_begin();
  2711. foreach ($list as $key=>$value)
  2712. {
  2713. $ddh = preg_replace('/\D/s','',$value['0']);
  2714. $ydh = preg_replace('/\W/s','',$value['1']);
  2715. $shop = $datashop[$readid];
  2716. if($shop['type'] == '269')
  2717. {
  2718. $orid = $readid.$ddh;
  2719. }
  2720. else
  2721. {
  2722. $orid = $ddh;
  2723. }
  2724. if(isset($dataorder[$orid]))
  2725. {
  2726. if($shop['type'] == 269)//独立站前缀需要添加ID
  2727. {
  2728. $time = time();
  2729. $xg = $dataorder[$orid];
  2730. $oldw = $xg['waybill'];
  2731. $ex = $dataex[$xg['express']];
  2732. $warehouse = $datack[$xg['type']];
  2733. $msg = $ydh;
  2734. $xg['waybill'] = $ydh;
  2735. $fs = $this->notice->find_all("shop = '".$xg['shop']."' and message = '1' and state = '1' and type = '4' and ktime < '$time' and jtime > '$time'");
  2736. if(isset($fs[0]))
  2737. {
  2738. $fs = $fs[0];
  2739. $fs['email'] = $this->emaildata->read($fs['email']);
  2740. if(($xg['dlzemail'] == 1 && $msg != $oldw) || $xg['dlzemail'] == 0)
  2741. {
  2742. $ck = $this->notice->get_god($xg,$shop,$ex,$fs);
  2743. if($ck == 1)
  2744. {
  2745. $ckemail = '邮件发送成功,';
  2746. $this->fullorder->save(array('dlzemail'=>1,'dlzemailtime'=>time()),$xg['id']);
  2747. }
  2748. }
  2749. }
  2750. if($msg != $oldw)
  2751. {
  2752. if($xg['source'] != 1)
  2753. {
  2754. $ms = $this->message->find_all("express like '%,".$xg['express'].",%'");
  2755. if(!isset($ms[0]))
  2756. {
  2757. $ms = $this->message->read(2);
  2758. }
  2759. else
  2760. {
  2761. $ms = $ms[0];
  2762. }
  2763. $ddh = substr($xg['orderinfo'],1);
  2764. $shopifyid = $xg['shopify'];
  2765. //独立站地址更新订单状态、物流信息
  2766. $shopname = $shop['brandname']; //店铺名
  2767. $buyername = $xg['bname']; //Bill Name
  2768. $email_call = $shop['shopid']; //发货人邮箱;
  2769. $phone = $shop['shopphone']; //发货人电话
  2770. $track_type = $ex['title']; //快递名称
  2771. $service = $ex['title']; //快递追踪名称
  2772. $track_link = $ex['url']; //快递查询网址
  2773. $logistics_number = $ydh; //运单号
  2774. $t= array('%buyername%','%email_call%','%track_type%','%service%','%track_link%','%logistics_number%','%shop%','%phone%','%jtime%');
  2775. $h= array($buyername,$email_call,$track_type,$service,$track_link,$logistics_number,$shopname,$phone,$ex['yjtime']);
  2776. $remark = str_replace($t,$h,$ms['content']);
  2777. @$gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$remark,$shopifyid);
  2778. }
  2779. else if($xg['source'] == 1)
  2780. {
  2781. $gx['res'] = 3;
  2782. $gx['state'] = 216;
  2783. }
  2784. }
  2785. else
  2786. {
  2787. $gx['res'] = $xg['dlz'];
  2788. $gx['state'] = $xg['state'];
  2789. }
  2790. $xg['iscode'] = $ex['title'];
  2791. $xg['url'] = $shop['shopname'];
  2792. @$chuanshu = $this->api->get_paypal($xg);
  2793. //$this->afspaypal->insert(array('number'=>$xg['number'],'cs'=>$chuanshu));
  2794. $this->fullorder->save(array('waybill'=>$msg,'state'=>$gx['state'],'dlz'=>$gx['res']),$xg['id']);
  2795. /**
  2796. $xg = $dataorder[$arg_array[0].$ddh];
  2797. $ex = $dataex[$xg['express']];
  2798. $warehouse = $datack[$xg['type']];
  2799. if($xg['source'] != 1 && $ex['iscode'] != 'Other' && $xg['state'] == '207')
  2800. {
  2801. //独立站地址更新订单状态、物流信息
  2802. $gx = $this->api->get_gx($ddh,$ydh,$xg,$shop,$ex,$xg['msg'],$xg['msg'],$dataorder[$orid]['shopify']);
  2803. if(!isset($gx['res']))
  2804. {
  2805. $ed[] = array($ddh.'-更新失败');
  2806. $j++;
  2807. continue;
  2808. }
  2809. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>$gx['res'],'state'=>$gx['state']),$xg['id']);
  2810. if($gx['res'] == 1 && $fs)
  2811. {
  2812. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2813. }
  2814. }
  2815. else if($xg['source'] == 1 && $xg['state'] == '207')
  2816. {
  2817. $this->fullorder->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2818. if($fs)
  2819. {
  2820. $ck = $this->_email($fs['content'],$xg,$warehouse['company']);
  2821. }
  2822. }
  2823. else
  2824. {
  2825. $ed[] = array($ddh.'-状态错误');
  2826. $j++;
  2827. continue;
  2828. }
  2829. **/
  2830. }
  2831. else if($shop['type'] == 270)//速卖通对接发货声明
  2832. {
  2833. $xg = $dataorder[$ddh];
  2834. $ex = $dataex[$xg['express']];
  2835. $warehouse = $datack[$xg['type']];
  2836. if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['library'] == 2 && ($xg['dlz'] == '0' || $xg['dlz'] == '2'))
  2837. {
  2838. $result = $this->apismt->get_out($ydh,'all',$xg['orderinfo'],$ex['aecode'],$sp['code']);
  2839. if(isset($result['result_success']) && $result['result_success'] == "true")
  2840. {
  2841. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$xg['id']);
  2842. /** 合并信息处理开始-发货声明 **/
  2843. if($xg['merge'] != '0')
  2844. {
  2845. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz = '0' and source != 1");$l=0;
  2846. foreach ($hdata as $v)
  2847. {
  2848. $result = $this->apismt->get_out($ydh,'all',$v['orderinfo'],$ex['aecode'],$sp['code']);
  2849. if(isset($result['result_success']) && $result['result_success'] == "true")
  2850. {
  2851. $this->fullordersmt->save(array('waybill'=>$ydh,'state'=>209,'dlz'=>1),$v['id']);
  2852. }
  2853. else
  2854. {
  2855. $ed[] = array($v['orderinfo'].'-合并单发货声明失败,请在ERP上手动操作此单');
  2856. $j++;
  2857. continue;
  2858. }
  2859. $l++;
  2860. if($l > 10)
  2861. {
  2862. break;
  2863. }
  2864. }
  2865. }
  2866. /** 合并信息处理结束开始 **/
  2867. }
  2868. else
  2869. {
  2870. $ed[] = array($ddh.'-发货声明失败');
  2871. $j++;
  2872. continue;
  2873. }
  2874. }
  2875. else if($xg['source'] != 1 && $ex['aecode'] != 'Other' && $xg['dlz'] == '1' && $xg['library'] == 2)//修改声明
  2876. {
  2877. $obtain = $this->apismt->get_obtain($xg['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  2878. if(isset($obtain['logistics_no']))
  2879. {
  2880. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$xg['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  2881. }
  2882. if(isset($result['result_success']) && $result['result_success'] == "true")
  2883. {
  2884. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  2885. /** 合并信息处理开始-修改声明 **/
  2886. if($xg['merge'] != '0')
  2887. {
  2888. $hdata = $this->fullordersmt->find_all("merge = '".$xg['merge']."' and id != '".$xg['id']."' and dlz != 1 and source != 1");$l=0;
  2889. foreach ($hdata as $v)
  2890. {
  2891. $obtain = $this->apismt->get_obtain($v['orderinfo'],$sp['code']);//修改声明先查询之前物流信息
  2892. if(isset($obtain['logistics_no']))
  2893. {
  2894. $result = $this->apismt->get_editout($obtain['logistics_no'],$ydh,'all',$v['orderinfo'],$obtain['service_name'],$ex['aecode'],$sp['code']);
  2895. }
  2896. if(isset($result['result_success']) && $result['result_success'] == "true")
  2897. {
  2898. $this->fullordersmt->save(array('waybill'=>$ydh),$v['id']);
  2899. }
  2900. else
  2901. {
  2902. $ed[] = array($v['orderinfo'].'-合并单修改发货声明失败,请在ERP上手动操作此单');
  2903. $j++;
  2904. continue;
  2905. }
  2906. $l++;
  2907. if($l > 10)
  2908. {
  2909. break;
  2910. }
  2911. }
  2912. }
  2913. /** 合并信息处理结束开始 **/
  2914. }
  2915. else
  2916. {
  2917. $ed[] = array($ddh.'-修改发货声明失败');
  2918. $j++;
  2919. continue;
  2920. }
  2921. }
  2922. else if($xg['source'] == 1 && $xg['state'] == '207')
  2923. {
  2924. $this->fullordersmt->save(array('waybill'=>$ydh,'dlz'=>3,'state'=>216),$xg['id']);
  2925. }
  2926. else
  2927. {
  2928. $this->fullordersmt->save(array('waybill'=>$ydh),$xg['id']);
  2929. }
  2930. }
  2931. }
  2932. else
  2933. {
  2934. $ed[] = array($ddh.'-单号错误或重复操作');
  2935. $i++;
  2936. continue;
  2937. }
  2938. sleep(1);//停留1秒
  2939. }
  2940. if ($this->db->trans_status() === FALSE)
  2941. {
  2942. $this->db->trans_rollback();
  2943. }
  2944. else
  2945. {
  2946. $this->db->trans_commit();
  2947. }
  2948. if($i+$j > 0)
  2949. {
  2950. $time = date('Ymd',time());
  2951. $title = '错误信息-'.$time;
  2952. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  2953. $tail = "\n";
  2954. $filename = $title.".xls";
  2955. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  2956. $dir = '/data/excel/'.$time.'/';
  2957. $file_name = 'error_'.$time.rand(1000,9999);
  2958. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  2959. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  2960. fwrite($myfile,$ecl);
  2961. fclose($myfile);
  2962. $error = $dir.$file_name.'.xls';
  2963. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  2964. }
  2965. else
  2966. {
  2967. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  2968. }
  2969. }
  2970. else
  2971. {
  2972. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  2973. }
  2974. }
  2975. //上传速卖通订单
  2976. public function _order($arg_array)
  2977. {
  2978. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  2979. /* 订单加入键值-k */
  2980. $fdata = $this->fullorder_smt->find_all('dtime >'.(time()-5*24*3600));
  2981. foreach ($fdata as $v)
  2982. {
  2983. $dataorder[$v['orderinfo']] = $v;
  2984. }
  2985. /* 订单加入键值-j */
  2986. $dir = '/data/excel/'.date('Ymd',time()).'/';
  2987. $config['upload_path'] = '.'.$dir ;
  2988. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  2989. $config['allowed_types'] = 'xls|xlsx|csv';
  2990. $config['max_size'] = 10240;
  2991. $this->load->library('upload', $config);
  2992. $this->upload->initialize($config);
  2993. if ($this->upload->do_upload('userfile'))
  2994. {
  2995. $full_path = $dir.$this->upload->data('file_name');
  2996. $fileName = '.' . $full_path;
  2997. if (!file_exists($fileName))
  2998. {
  2999. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3000. }
  3001. else
  3002. {
  3003. require_once "./data/excel/PHPExcel/IOFactory.php";
  3004. $phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3005. $phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3006. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3007. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3008. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3009. ++$column;//如果列数大于26行
  3010. $list = array();
  3011. for ($i = 2; $i <= $row; $i++) // 行数循环
  3012. {
  3013. $data = array();
  3014. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3015. {
  3016. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3017. }
  3018. $list[] = $data;
  3019. }
  3020. }
  3021. $i = 0;$j = 0;$ed = array();$tytime = time();
  3022. foreach ($list as $key=>$value)
  3023. {
  3024. $value['2'] = preg_replace('/\D/s','',$value['2']);
  3025. if($value['2'] && !isset($dataorder[$value['2']]))
  3026. {
  3027. $num = $this->fullorder_smt->find_count('gtime = "'.date('Ymd',time()).'"');
  3028. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3029. $post['state'] = 207;//订单状态:207等待发货
  3030. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3031. $post['reviewtime'] = $tytime;//审核时间
  3032. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3033. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3034. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3035. if($post['print'] != 3)
  3036. {
  3037. $post['librarynot'] = "订单未打印,未审核或未通过";//不能出库原因
  3038. }
  3039. $value['1'] = trim($value['1'],' ');
  3040. $shortname = explode('-',$value['1']);
  3041. $shortname = $this->shop->get_shortname($shortname[0]);
  3042. if(!$shortname)
  3043. {
  3044. $ed[] = array($value['1'].'-编码有问题');
  3045. $i++;
  3046. continue;
  3047. }
  3048. $post['shop'] = $shortname['id']?$shortname['id']:0;//速卖通
  3049. $post['user'] = '无';
  3050. $post['number'] = $value['1'];//编号
  3051. $post['orderinfo'] = $value['2'];//订单号
  3052. $post['client'] = preg_replace('/( | | |\s)/',' ',$value['3']);//客户名称
  3053. $post['buytime'] = $tytime;//时间转UX
  3054. $post['dtime'] = $tytime;//订单时间
  3055. $post['gtime'] = date('Ymd',$tytime);//格式化时间
  3056. //$post['pay'] = $this->input->post('pay',true);//支付方式
  3057. $post['capital'] = 3;//资金状态
  3058. $post['type'] = 5;//发货仓库
  3059. $post['currency'] = 219;//币种
  3060. $post['currencytitle'] = 'USD';//币种名称
  3061. $post['freight'] = 0;//运费
  3062. $post['expressmoney'] = 0;//物流金额
  3063. $post['shouldmoney'] = 0;//应收金额
  3064. $post['budget'] = 0;//应到金额*店铺到帐金额比
  3065. $orderremarks = '';//订单备注
  3066. $post['shipremarks'] = $value['12'];//仓库品名
  3067. $post['email'] = '';//邮箱
  3068. $post['name'] = preg_replace('/( | | |\s)/',' ',$value['3']);//名字
  3069. $post['phone'] = $value['10'];//电话
  3070. $post['country'] = 192;//国家
  3071. $ct = $this->country->get_ename($value['9']);//国家
  3072. $post['al'] = $ct['lb'];//国家二字码
  3073. $post['province'] = $value['8'];//省、州
  3074. $post['city'] = $value['6'];//城市
  3075. $post['zipcode'] = $value['7'];//邮编
  3076. $post['address'] = $value['4'];//地址1
  3077. $post['address2'] = $value['5']?$value['5']:'';//地址2
  3078. $post['express'] = 2;//快递
  3079. $post['printtype'] = 1;//打印类型
  3080. $post['fpdata'] = '';//购买产品内容
  3081. $post['sbpm'] = 'Hair Sample';//申报品名
  3082. $post['zwpm'] = '假发';//中文品名
  3083. $post['ts'] = $value['17'];//条数
  3084. $post['dtsbjz'] = 15;//单条申报价
  3085. $post['zsbjz'] = 15;//总申报价
  3086. $post['zzl'] = 0.5;//总重量
  3087. $post['zjs'] = 1;//总件数
  3088. $post['quantity'] = 1;//数量
  3089. $post['paypal'] = '';//支付号
  3090. $post['guarantee'] = '';//卖家保障
  3091. $post['zzl'] = $value['13'];//总重量
  3092. $post['bx'] = $value['14'];//总重量
  3093. $post['qm'] = $value['15'];//总重量
  3094. $post['js'] = $value['16'];//总重量
  3095. $barcode = $this->usps->get_address(array('address'=>$value['4'],'address2'=>$value['5'],'city'=>$value['6'],'province'=>$value['8'],'zipcode'=>$value['7']));
  3096. if(isset($barcode['Address']['Error']['Description']))
  3097. {
  3098. $ed[] = array($value['1'].'-'.$barcode['Address']['Error']['Description']);
  3099. $i++;
  3100. }
  3101. else
  3102. {
  3103. $this->fullorder_smt->insert($post);
  3104. }
  3105. }
  3106. else
  3107. {
  3108. $ed[] = array($value['1'].'-单号错误或重复操作');
  3109. $i++;
  3110. }
  3111. sleep(2);//停留2秒
  3112. }
  3113. if($i+$j > 0)
  3114. {
  3115. $time = date('Ymd',time());
  3116. $title = '错误信息-'.$time;
  3117. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3118. $tail = "\n";
  3119. $filename = $title.".xls";
  3120. $ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3121. $dir = '/data/excel/'.$time.'/';
  3122. $file_name = 'error_'.$time.rand(1000,9999);
  3123. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3124. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3125. fwrite($myfile,$ecl);
  3126. fclose($myfile);
  3127. $error = $dir.$file_name.'.xls';
  3128. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3129. }
  3130. else
  3131. {
  3132. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3133. }
  3134. }
  3135. else
  3136. {
  3137. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3138. }
  3139. }
  3140. public function _email($content,$data,$shopname)
  3141. {
  3142. $express = $this->express->read($data['express']);
  3143. $t= array('$userName','$orderid','$trackingNumber','$expressCompany','$contactPerson','$mobileNo','$zip','$recipientAddress');//需要被替换的内容
  3144. $h= array($data['client'],$data['orderinfo'],$data['waybill'],$express['servicename'],$data['name'],$data['phone'],$data['zipcode'],$data['address']);//替换的内容
  3145. $content = str_replace($t,$h,$content);
  3146. $this->load->library('email');
  3147. $config['protocol'] = 'smtp';
  3148. $config['smtp_host'] = 'smtpdm-ap-southeast-1.aliyun.com';
  3149. $config['smtp_port'] = 465;
  3150. $config['smtp_user'] = 'service@email.supernovahair.com';
  3151. $config['smtp_pass'] = 'LONGyihair374';
  3152. $config['smtp_crypto'] = 'ssl';
  3153. $config['crlf'] = "\r\n";
  3154. $config['newline'] = "\r\n";
  3155. $this->email->initialize($config);
  3156. $this->email->from('service@email.supernovahair.com',$shopname);
  3157. $this->email->to($data['email']);//收件
  3158. $this->email->subject('The product you purchased has a new progress');//标题
  3159. $this->email->message($content);//内容
  3160. if ( ! $this->email->send())
  3161. {
  3162. return 2;
  3163. }
  3164. else
  3165. {
  3166. return 1;
  3167. }
  3168. }
  3169. //导出订单excel
  3170. public function _cs()
  3171. {
  3172. if(isset($_GET['fexcel']))
  3173. {
  3174. if(isset($_SESSION['api']))
  3175. {
  3176. $user = $this->user->get_api($_SESSION['api']);
  3177. $usp = $user;
  3178. $fgshop = "";$sid = "";
  3179. $user = explode('|',trim($user['shop'],'|'));
  3180. foreach ($user as $value)
  3181. {
  3182. $fgshop .= " shop = ".$value." or";
  3183. $sid .= " id = ".$value." or";
  3184. }
  3185. }
  3186. $dowid = $this->input->get('a');
  3187. $wid = "";
  3188. if($dowid != "")
  3189. {
  3190. $id_arr = explode(',',rtrim($dowid,','));
  3191. foreach ($id_arr as $v)
  3192. {
  3193. $wid .= " id = 0 or";
  3194. $wid .= " id = '$v' or";
  3195. }
  3196. $wid = " and".rtrim($wid,'or');
  3197. }
  3198. $fexcel = $this->input->get('fexcel',true);
  3199. $page = $this->input->get('page',true);
  3200. $perpage = $this->input->get('perpage',true);
  3201. $warehouse = $this->input->get('warehouse',true);
  3202. $timetk = $this->input->get('timetk',true);
  3203. $timetj = $this->input->get('timetj',true);
  3204. $shop = $this->input->get('shop',true);
  3205. $source = $this->input->get('source',true);
  3206. $state = $this->input->get('state',true);
  3207. $review = $this->input->get('review',true);
  3208. $type = $this->input->get('type',true);
  3209. $express = $this->input->get('express',true);
  3210. $orderinfo = $this->input->get('orderinfo',true);
  3211. $user = $this->input->get('user',true);
  3212. $client = $this->input->get('name',true);
  3213. $waybill = $this->input->get('waybill',true);
  3214. $number = $this->input->get('number',true);
  3215. $email = $this->input->get('email',true);
  3216. $dlz = $this->input->get('dlz',true);
  3217. $library = $this->input->get('library',true);
  3218. $libraryconfirm = $this->input->get('libraryconfirm',true);
  3219. $print = $this->input->get('print',true);
  3220. $timetkk = $this->input->get('timetkk',true);
  3221. $timetjj = $this->input->get('timetjj',true);
  3222. $timetk = strtotime($timetk);
  3223. $timetj = strtotime($timetj);
  3224. $timetkk = strtotime($timetkk);
  3225. $timetjj = strtotime($timetjj);
  3226. $where = "mergeid = 0 and (".rtrim($fgshop,'or').")";
  3227. if($warehouse)
  3228. {
  3229. $where .= " and type = '$warehouse'";
  3230. }
  3231. if($timetk && $timetj)
  3232. {
  3233. $timetj = $timetj+24*3600;
  3234. $where .= " and dtime > '$timetk' and dtime < '$timetj'";
  3235. }
  3236. if($timetkk && $timetjj)
  3237. {
  3238. $where .= " and librarytime > '$timetkk' and librarytime < '$timetjj'";
  3239. }
  3240. if($library)
  3241. {
  3242. $where .= " and library = '$library'";
  3243. }
  3244. if($print)
  3245. {
  3246. $where .= " and print = '$print'";
  3247. }
  3248. if($shop)
  3249. {
  3250. $where .= " and shop = '$shop'";
  3251. }
  3252. if($source)
  3253. {
  3254. $where .= " and source = '$source'";
  3255. }
  3256. if($state)
  3257. {
  3258. $where .= " and state = '$state'";
  3259. }
  3260. if($review)
  3261. {
  3262. $where .= " and review = '$review'";
  3263. }
  3264. if($type)
  3265. {
  3266. $where .= " and type = '$type'";
  3267. }
  3268. if($express)
  3269. {
  3270. $where .= " and express = '$express'";
  3271. }
  3272. if($orderinfo)
  3273. {
  3274. $where .= " and orderinfo = '$orderinfo'";
  3275. }
  3276. if($user)
  3277. {
  3278. $where .= " and user = '$user'";
  3279. }
  3280. if($client)
  3281. {
  3282. $where .= " and client like '%$client%'";
  3283. }
  3284. if($waybill)
  3285. {
  3286. $where .= " and waybill = '$waybill'";
  3287. }
  3288. if($number)
  3289. {
  3290. $where .= " and number = '$number'";
  3291. }
  3292. if($email)
  3293. {
  3294. $where .= " and email = '$email'";
  3295. }
  3296. if($dlz)
  3297. {
  3298. $where .= " and waybill != '' and dlz = 0";
  3299. }
  3300. if($dlz)
  3301. {
  3302. $where .= " and libraryconfirm = '$libraryconfirm'";
  3303. }
  3304. $fexcel = $this->fullorderexcel->read($fexcel);
  3305. $fexceleq = explode("|",rtrim($fexcel['content'],'|'));
  3306. foreach ($fexceleq as $k=>$v)
  3307. {
  3308. $fexceleq[$k] = explode('-',$v);
  3309. $num[$k] = $fexceleq[$k][0];
  3310. }
  3311. //array_multisort($num,SORT_ASC,$fexceleq);//重新排序
  3312. $feq = "";
  3313. foreach ($fexceleq as $k=>$v)
  3314. {
  3315. $feq .= $v[1].',';
  3316. }
  3317. $feq = rtrim($feq,',');
  3318. $fexcelzhw = explode('|',rtrim($fexcel['contentzh'],'|'));
  3319. foreach ($fexcelzhw as $k=>$v)
  3320. {
  3321. $fexcelzhw[$k] = explode('-',$v);
  3322. $numb[$k] = $fexcelzhw[$k][0];
  3323. }
  3324. //array_multisort($numb,SORT_ASC,$fexcelzhw);//重新排序
  3325. $fexcelzh = array();
  3326. foreach ($fexcelzhw as $k=>$v)
  3327. {
  3328. $fexcelzh[] = $v[1];
  3329. }
  3330. //取得信息列表
  3331. $info_list = $this->fullorder->find_all($where.$wid,$feq,'id desc');
  3332. //格式化数据
  3333. $i = 1;$shouldmoney = 0;$hl=1;
  3334. foreach ($info_list as $key=>$value)
  3335. {
  3336. if(isset($value['currencytitle']))
  3337. {
  3338. if($value['currencytitle'] != "CNY")
  3339. {
  3340. $hl=$value['hl'];
  3341. }
  3342. $shouldmoney=$shouldmoney+($value['shouldmoney']*$hl);
  3343. $budget=$budget+($value['budget']*$hl);
  3344. $currency=$currency+(($value['shouldmoney']-$value['budget'])*$hl);
  3345. $refund=$refund+($value['refund']*$hl);
  3346. }
  3347. if(isset($value['shop']))
  3348. {
  3349. $shop = $this->shop->read($value['shop']);
  3350. $info_list[$key]['shop'] = $shop['shopname'];
  3351. }
  3352. if(isset($value['dtime']))
  3353. {
  3354. $info_list[$key]['dtime'] = date('Y-m-d H:i:s',$value['dtime']);
  3355. }
  3356. if(isset($value['country']))
  3357. {
  3358. $country = $this->country->read($value['country']);
  3359. $info_list[$key]['country'] = $country['name'];
  3360. }
  3361. if(isset($value['type']))
  3362. {
  3363. $type = $this->warehouse->read($value['type']);
  3364. $info_list[$key]['type'] = $type['title'];
  3365. }
  3366. if(isset($value['express']))
  3367. {
  3368. $express = $this->express->read($value['express']);
  3369. if($express)
  3370. {
  3371. $info_list[$key]['express'] = $express['servicename'];
  3372. }
  3373. else
  3374. {
  3375. $info_list[$key]['express'] = '未选择';
  3376. }
  3377. }
  3378. }
  3379. echo $timetkk;
  3380. }
  3381. }
  3382. public function _gggs($sku,$s,$j,$k)
  3383. {
  3384. $companytitle = array(9=>3,10=>2,11=>1,12=>4);
  3385. $this->load->database();
  3386. $this->db->select('id');
  3387. $this->db->from('crowd_whlabel');
  3388. $this->db->where('warehouse', '5');
  3389. $this->db->where('sku', $sku);
  3390. $this->db->where('state', '0');
  3391. $this->db->limit($s,$k);
  3392. $query = $this->db->get();
  3393. $ids = array_column($query->result_array(), 'id');
  3394. if (!empty($ids))
  3395. {
  3396. // 更新
  3397. $this->db->where_in('id', $ids);
  3398. $this->db->update('crowd_whlabel', array('companytitle' => $companytitle[$j]));
  3399. return $this->db->affected_rows();
  3400. }
  3401. }
  3402. public function _xxpl()
  3403. {
  3404. $this->load->database();
  3405. $data = ['type' => ''];
  3406. $this->db->update('crowd_whlabel', $data);
  3407. $wt = array();
  3408. $whlabel_type = $this->whlabel_type->find_all();
  3409. foreach ($whlabel_type as $v)
  3410. {
  3411. $wt[$v['title']] = $v['id'];
  3412. }
  3413. /* 订单加入键值-j */
  3414. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3415. $config['upload_path'] = '.'.$dir ;
  3416. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3417. $config['allowed_types'] = 'xls|xlsx|csv';
  3418. $config['max_size'] = 10240;
  3419. $this->load->library('upload', $config);
  3420. $this->upload->initialize($config);
  3421. if ($this->upload->do_upload('userfile'))
  3422. {
  3423. $full_path = $dir.$this->upload->data('file_name');
  3424. $fileName = '.' . $full_path;
  3425. if (!file_exists($fileName))
  3426. {
  3427. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3428. }
  3429. else
  3430. {
  3431. require_once "./data/excel/PHPExcel/IOFactory.php";
  3432. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3433. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3434. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3435. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3436. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3437. ++$column;//如果列数大于26行
  3438. $list = array();
  3439. for ($i = 2; $i <= $row; $i++) // 行数循环
  3440. {
  3441. $data = array();
  3442. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3443. {
  3444. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3445. }
  3446. $list[] = $data;
  3447. }
  3448. }
  3449. $wt = array();
  3450. $whlabel_type = $this->whlabel_type->find_all();
  3451. foreach ($whlabel_type as $v)
  3452. {
  3453. $wt[$v['title']] = $v['id'];
  3454. }
  3455. $j = 0;$ed = array();$e = 0;$c = 0;$cs = array();
  3456. foreach ($list as $v)
  3457. {
  3458. $this->load->database();
  3459. // 设置更新数据
  3460. $data = ['type' => $wt[$v[1]]];
  3461. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3462. $this->db->where('SKU', $v[0]);
  3463. $this->db->where('warehouse', '5');
  3464. // 批量更新
  3465. $this->db->update('crowd_whlabel', $data);
  3466. }
  3467. /** 导入缺货
  3468. $time = time();
  3469. $whlabel = $this->whlabel->get_sku($v[0]);
  3470. if($whlabel)
  3471. {
  3472. $this->whlabel_qh->insert(array('sku'=>$whlabel['sku'],'features'=>$whlabel['features'],'num'=>$v['1'],'gtime'=>date('Ym',$time),'gxtime'=>date('Ymd',$time)));
  3473. }
  3474. else
  3475. {
  3476. $ed[] = $v['0'];
  3477. $j++;
  3478. }
  3479. }
  3480. **/
  3481. /**
  3482. 更换等级
  3483. $this->load->database();
  3484. // 设置更新数据
  3485. $data = ['type' => $wt[$v[1]]];
  3486. // 添加条件:SKU 为 123456 且 warehouse 为 5
  3487. $this->db->where('SKU', $v[0]);
  3488. $this->db->where('warehouse', '5');
  3489. // 批量更新
  3490. $this->db->update('crowd_whlabel', $data);
  3491. **/
  3492. /**
  3493. $whlabel_type = $this->whlabel_type->find_all();
  3494. foreach ($whlabel_type as $v)
  3495. {
  3496. $wt[$v['title']] = $v['id'];
  3497. }
  3498. foreach ($list as $v)
  3499. {
  3500. $w = $this->whlabel->find_all("sku = '".$v[0]."' and warehouse = 5");
  3501. if($w && isset($wt[$v[1]]))
  3502. {
  3503. foreach ($w as $val)
  3504. {
  3505. $this->whlabel->save(array('type'=>$wt[$v[1]]),$val['id']);
  3506. }
  3507. }
  3508. else
  3509. {
  3510. $ed[] = array($v[0],$v[1]);
  3511. $j++;
  3512. }
  3513. }
  3514. **/
  3515. if($e > 0)
  3516. {
  3517. $time = date('Ymd',time());
  3518. $title = '错误信息-'.$time;
  3519. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3520. $tail = "\n";
  3521. $filename = $title.".xls";
  3522. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3523. $dir = '/data/excel/'.$time.'/';
  3524. $file_name = 'error_'.$time.rand(1000,9999);
  3525. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3526. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3527. fwrite($myfile,$ecl);
  3528. fclose($myfile);
  3529. $error = $dir.$file_name.'.xls';
  3530. echo json_encode(array('msg'=>$j.'条异常,','error'=>$error,'success'=>true));exit;
  3531. }
  3532. else
  3533. {
  3534. echo json_encode(array('msg'=>'添加成功!'.$c,'success'=>true));exit;
  3535. }
  3536. }
  3537. else
  3538. {
  3539. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3540. }
  3541. }
  3542. public function _skuzh()
  3543. {
  3544. /* 订单加入键值-j */
  3545. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3546. $config['upload_path'] = '.'.$dir ;
  3547. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3548. $config['allowed_types'] = 'xls|xlsx|csv';
  3549. $config['max_size'] = 10240;
  3550. $this->load->library('upload', $config);
  3551. $this->upload->initialize($config);
  3552. if ($this->upload->do_upload('userfile'))
  3553. {
  3554. $full_path = $dir.$this->upload->data('file_name');
  3555. $fileName = '.' . $full_path;
  3556. if (!file_exists($fileName))
  3557. {
  3558. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3559. }
  3560. else
  3561. {
  3562. require_once "./data/excel/PHPExcel/IOFactory.php";
  3563. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3564. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3565. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3566. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3567. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3568. ++$column;//如果列数大于26行
  3569. $list = array();
  3570. for ($i = 2; $i <= $row; $i++) // 行数循环
  3571. {
  3572. $data = array();
  3573. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3574. {
  3575. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3576. }
  3577. $list[] = $data;
  3578. }
  3579. }
  3580. $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');
  3581. $dtc = array();
  3582. foreach ($dictionaries as $v)
  3583. {
  3584. if(stripos($v['spare'],'|') !== false)//如果有多个值
  3585. {
  3586. $v['spare'] = explode('|',$v['spare']);
  3587. foreach ($v['spare'] as $k=>$vs)
  3588. {
  3589. if(stripos($v['zh'],'|') !== false)
  3590. {
  3591. $vzh = explode('|',$v['zh']);
  3592. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$vzh[$k],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3593. }
  3594. else
  3595. {
  3596. $dtc[strtolower($vs)] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$vs);
  3597. }
  3598. }
  3599. }
  3600. else
  3601. {
  3602. $dtc[strtolower($v['spare'])] = array('classid'=>$v['classid'],'zh'=>$v['zh'],'id'=>$v['id'],'jm'=>$v['jm'],'spare'=>$v['spare']);
  3603. }
  3604. }
  3605. $dictionaries2 = $this->typeclass->find_all();
  3606. foreach ($dictionaries2 as $v)
  3607. {
  3608. $dtctitle[$v['id']] = $v['title'];
  3609. }
  3610. /* 匹配结束 */
  3611. /* 价格加入 */
  3612. $money = array();
  3613. $productdescribe = $this->productdescribe->find_all('1=1');
  3614. foreach ($productdescribe as $v)
  3615. {
  3616. $money[$v['number']] = array();
  3617. }
  3618. /* 价格加入 */
  3619. /* 匹配ID加入 */
  3620. $int = array();
  3621. $intdata = $this->typeclass->find_all('classid=14','id,spare');
  3622. foreach ($intdata as $v)
  3623. {
  3624. $v['spare'] = explode('|',$v['spare']);
  3625. $int[$v['id']] = $v['spare'][0];
  3626. }
  3627. /* 匹配ID加入 */
  3628. $zjsku = array();
  3629. $shopsku = $this->shopsku->find_all();
  3630. foreach ($shopsku as $val)
  3631. {
  3632. $ss = explode(',',trim($val['shop'],','));
  3633. foreach ($ss as $v)
  3634. {
  3635. if(isset($zjsku[$v]))
  3636. {
  3637. $zjsku[$v] .= ','.trim($val['sku'],',');
  3638. }
  3639. else
  3640. {
  3641. $zjsku[$v] = trim($val['sku'],',');
  3642. }
  3643. }
  3644. }
  3645. /* 匹配ID结束 */
  3646. $q = '1;';
  3647. $is = $this->is->find_all('1=1','*','number asc');//获取仓库平匹配表
  3648. $shop = $this->shop->read(19);
  3649. if(isset($zjsku[$shop['id']]))//判断是否找到店铺SKU
  3650. {
  3651. $sku = rtrim($sku,',').','.$zjsku[$shop['id']];
  3652. }
  3653. $ed = array();
  3654. foreach ($list as $v)
  3655. {
  3656. $r = $this->api->matching(trim($q,';'),$v['2'],$dtc,$money,$int,$dtctitle,$shop);
  3657. $p = '';
  3658. $product = explode(';',trim($r['product'],';'));
  3659. if($r['title'] != '' && $product)
  3660. {
  3661. foreach ($product as $val)
  3662. {
  3663. $vc = explode('|',$val);
  3664. if(isset($vc[1]))
  3665. {
  3666. $p .= $vc[1].'<br>';
  3667. }
  3668. }
  3669. $r['title'] = str_replace(array('<','>'),array('&lt;','&gt;'),$r['title']);
  3670. $ed[] = array($v['0'],$v['1'],$r['title'],$v['3'],$v['4'],$v['5']);
  3671. }
  3672. else
  3673. {
  3674. $ed[] = array($v['0'],$v['1'],$v['2'].' SKU错误',$v['3'],$v['4'],$v['5']);
  3675. }
  3676. }
  3677. $time = date('Ymd',time());
  3678. $title = 'sku转换'.$time;
  3679. $titlename = "<table border=1><tr><td>退款日期</td><td>订单号</td><td>SKU</td><td退款金额</td><td退款情况具体描述</td><可用/不可用</td></tr></table>";
  3680. $tail = "\n";
  3681. $filename = $title.".xls";
  3682. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3683. $dir = '/data/excel/'.$time.'/';
  3684. $file_name = 'sku转换 '.$time.rand(1000,9999);
  3685. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3686. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3687. fwrite($myfile,$ecl);
  3688. fclose($myfile);
  3689. $error = $dir.$file_name.'.xls';
  3690. echo json_encode(array('msg'=>'转换成功!','error'=>$error,'success'=>true));exit;
  3691. }
  3692. else
  3693. {
  3694. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3695. }
  3696. }
  3697. public function _xxpl_b()
  3698. {
  3699. $dataorder = array();$datashop = array();$dataex = array();$datack = array();
  3700. /* 订单加入键值-k */
  3701. $fdata = $this->fullordersmt->find_all('dtime >'.(time()-10*24*3600));
  3702. foreach ($fdata as $v)
  3703. {
  3704. $dataorder[$v['orderinfo']] = $v;
  3705. }
  3706. /* 订单加入键值-j */
  3707. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3708. $config['upload_path'] = '.'.$dir ;
  3709. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  3710. $config['allowed_types'] = 'xls|xlsx|csv';
  3711. $config['max_size'] = 10240;
  3712. $this->load->library('upload', $config);
  3713. $this->upload->initialize($config);
  3714. if ($this->upload->do_upload('userfile'))
  3715. {
  3716. $full_path = $dir.$this->upload->data('file_name');
  3717. $fileName = '.' . $full_path;
  3718. if (!file_exists($fileName))
  3719. {
  3720. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  3721. }
  3722. else
  3723. {
  3724. require_once "./data/excel/PHPExcel/IOFactory.php";
  3725. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  3726. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  3727. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  3728. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  3729. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  3730. ++$column;//如果列数大于26行
  3731. $list = array();
  3732. for ($i = 2; $i <= $row; $i++) // 行数循环
  3733. {
  3734. $data = array();
  3735. for ($c = 'A'; $c != $column; $c++) // 列数循环
  3736. {
  3737. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  3738. }
  3739. $list[] = $data;
  3740. }
  3741. }
  3742. $i = 0;$j = 0;$ed = array();$time = time();
  3743. foreach ($list as $key=>$value)
  3744. {
  3745. $shop = $this->shop->get_shopname($value['2']);//通过店铺名称查找店铺
  3746. if(!$shop)
  3747. {
  3748. $ed[] = array($value['0'].'-无此店铺');
  3749. $i++;continue;
  3750. }
  3751. $post['buytime'] = strtotime($value['6']);//付款时间
  3752. $value['0'] = preg_replace('/\D/s','',$value['0']);
  3753. if($value['0'] && !isset($dataorder[$value['0']]))
  3754. {
  3755. $post['source'] = 2;//订单类型:1.线下订单2.PC3.手机
  3756. $post['state'] = 207;//订单状态:207等待发货
  3757. $post['review'] = 6;//审核状态:1.未送审2.待审核3.不通过4取消重审5.审核通过6.自动通过
  3758. $post['reviewtime'] = $time;//审核时间
  3759. $post['print'] = 2;//打印状态:1.不可打印2.未打印3.已打印
  3760. $post['library'] = 1;//出库状态:1.未出库2.已出库3.已退库
  3761. $post['libraryconfirm'] = 1;//出库确认:1.不允许2.允许
  3762. $post['dtime'] = $time;//订单时间
  3763. $post['capital'] = 3;//资金状态
  3764. $post['currency'] = 219;//币种
  3765. $post['currencytitle'] = 'USD';//币种名称
  3766. $post['freight'] = 0;//运费
  3767. $post['expressmoney'] = 0;//物流金额
  3768. $post['shouldmoney'] = 0;//应收金额
  3769. if($post['print'] != 3)
  3770. {
  3771. $post['librarynot'] = "订单未打印";//不能出库原因
  3772. }
  3773. $post['gtime'] = date('Ymd',$post['buytime']);//格式化时间
  3774. $num = $this->fullordersmt->find_count('gtime = "'.date('Ymd',$post['buytime']).'" and shop = "'.$shop['id'].'"','id');
  3775. $post['number'] = $shop['shortname'].'-'.substr(date('ymd',$post['buytime']),1).'-'.(substr(strval($num+1+1000),1,3));//编号
  3776. $post['user'] = $shop['shopuser'];//店铺负责人
  3777. $post['orderinfo'] = $value['0'];//订单号
  3778. $post['type'] = $value['7'];//发货仓库
  3779. $post['shop'] = $shop['id'];//店铺
  3780. $post['shouldmoney'] = $value['3'];//订单金额
  3781. $post['product'] = $value['4']?$value['4']:'';//商品名称
  3782. $post['pay'] = $value['5'];//付款方式
  3783. $post['paypal'] = $value['1']?$value['1']:'';//交易号
  3784. $post['orderremarks'] = $value['8']?$value['8']:'';//订单备注
  3785. $post['shipremarks'] = $value['9'];//仓库品名
  3786. $post['client'] = preg_replace('/( | | | |\s)/',' ',$value['10']);//公司名
  3787. $post['name'] = preg_replace('/( | | | |\s)/',' ',$value['11']);//收货人
  3788. $post['phone'] = $value['12'];//电话
  3789. $ct = $this->country->get_ename(preg_replace('/( | | | |\s)/',' ',$value['13']));//国家
  3790. if(!$ct)
  3791. {
  3792. $ed[] = array($value['0'].'-无此国家');
  3793. $i++;continue;
  3794. }
  3795. $post['country'] = $ct['id'];//国家
  3796. $post['al'] = $ct['lb'];//国家二字码
  3797. $post['province'] = $value['14'];//省、州
  3798. $post['city'] = $value['15'];//城市
  3799. $post['zipcode'] = $value['16'];//邮编
  3800. $post['address'] = $value['17'];//地址1
  3801. $post['address2'] = $value['18']?$value['18']:'';//地址2
  3802. $yga = $value['3'];$ygb = $shop['estimaterate'];
  3803. $post['budget'] = eval("return $yga*1.$ygb;");//预估到帐金额
  3804. $post['sbpm'] = $value['19'];//申报品名
  3805. $post['zwpm'] = $value['20'];//中文品名
  3806. $post['ts'] = $value['21'];//条数
  3807. $post['dtsbjz'] = $value['22'];//单条申报价
  3808. $post['zsbjz'] = $value['23'];//总申报价
  3809. $post['zzl'] = $value['24'];//总重量
  3810. $post['zjs'] = $value['25'];//总件数
  3811. $express = $this->express->get_servicename(preg_replace('/( | | | |\s)/',' ',$value['26']));
  3812. if(!$express)
  3813. {
  3814. $ed[] = array($value['0'].'-无此快递方式');
  3815. $i++;continue;
  3816. }
  3817. $post['express'] = $express['id'];//快递
  3818. $post['printtype'] = 1;//打印类型 1.运单.2.发货单
  3819. $post['fpdata'] = '';//购买产品内容
  3820. $this->fullordersmt->insert($post);
  3821. }
  3822. else
  3823. {
  3824. $ed[] = array($value['0'].'-单号错误或重复操作');
  3825. $i++;
  3826. }
  3827. sleep(2);//停留2秒
  3828. }
  3829. if($i+$j > 0)
  3830. {
  3831. $time = date('Ymd',time());
  3832. $title = '错误信息-'.$time;
  3833. $titlename = "<table border=1><tr><td>错误详情</td></tr></table>";
  3834. $tail = "\n";
  3835. $filename = $title.".xls";
  3836. @$ecl = $this->excel->get_fz3($ed,$titlename,$filename,$tail);
  3837. $dir = '/data/excel/'.$time.'/';
  3838. $file_name = 'error_'.$time.rand(1000,9999);
  3839. if(!is_dir('.'.$dir))mkdir('.'.$dir,0777);
  3840. $myfile = fopen(".".$dir.$file_name.".xls", "w") or die();
  3841. fwrite($myfile,$ecl);
  3842. fclose($myfile);
  3843. $error = $dir.$file_name.'.xls';
  3844. echo json_encode(array('msg'=>'添加成功,'.$i.'条异常,'.$j.'条失败','error'=>$error,'success'=>true));exit;
  3845. }
  3846. else
  3847. {
  3848. echo json_encode(array('msg'=>'添加成功!','error'=>1,'success'=>true));exit;
  3849. }
  3850. }
  3851. else
  3852. {
  3853. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3854. }
  3855. }
  3856. public function _scwd()
  3857. {
  3858. $dir = '/data/excel/'.date('Ymd',time()).'/';
  3859. $config['upload_path'] = '.'.$dir ;
  3860. $config['allowed_types'] = '*';
  3861. $config['max_size'] = 102400;
  3862. $this->load->library('upload', $config);
  3863. $this->upload->initialize($config);
  3864. if ($this->upload->do_upload('userfile'))
  3865. {
  3866. $full_path = $dir.$this->upload->data('file_name');
  3867. echo json_encode(array('msg'=>'成功!','wdurl'=>$full_path,'success'=>true));exit;
  3868. }
  3869. else
  3870. {
  3871. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  3872. }
  3873. }
  3874. public function _jmexcel()
  3875. {
  3876. $setting = $this->setting->get_settings();
  3877. $excelpass = $setting['excelpass'];
  3878. $excelusernum = $setting['excelusernum'];
  3879. $exceljmnum = $setting['exceljmnum'];
  3880. $user = $this->user->get_api($_SESSION['api']);
  3881. if(!isset($user['exceltime']))
  3882. {
  3883. $this->session->sess_destroy();
  3884. header("Location:/");
  3885. }
  3886. $post = $this->input->post(NULL, TRUE);
  3887. if(isset($post['data']))
  3888. {
  3889. $data = $this->input->post('data',true);
  3890. $data = str_replace("\n",",",$data);;
  3891. $data = explode(',',trim($data,','));
  3892. $d = '';$i = 0;
  3893. foreach ($data as $v)
  3894. {
  3895. if($v == '')
  3896. {
  3897. continue;
  3898. }
  3899. $j = $this->setting->get_jmexcelpass($v);
  3900. if($j == '')
  3901. {
  3902. $j = $v.' 信息不正确';
  3903. }
  3904. $d .= $j."<br />";
  3905. $i++;
  3906. }
  3907. if($i > $exceljmnum)
  3908. {
  3909. echo json_encode(array('msg'=>'每次解密数量不可超出'.$exceljmnum.'条','success'=>false));exit;
  3910. }
  3911. if($user['exceltime'] != date('Ymd',time()))
  3912. {
  3913. $this->user->save(array('exceltime'=>date('Ymd',time()),'excelnum'=>1),$user['id']);
  3914. }
  3915. else
  3916. {
  3917. if($user['excelnum'] > $excelusernum)
  3918. {
  3919. echo json_encode(array('msg'=>'今日此账号解密次数已使用完毕','success'=>false));exit;
  3920. }
  3921. else
  3922. {
  3923. $this->user->save(array('excelnum'=>$user['excelnum']+1),$user['id']);
  3924. }
  3925. }
  3926. echo json_encode(array('msg'=>$d,'success'=>true));exit;
  3927. }
  3928. $this->data['excelpass'] = $excelpass;
  3929. $this->data['excelusernum'] = $excelusernum;
  3930. $this->data['exceljmnum'] = $exceljmnum;
  3931. $this->_Template('fullorderexcel_jmexcel',$this->data);
  3932. }
  3933. //管理
  3934. public function _classid()
  3935. {
  3936. $post = $this->input->post(NULL, TRUE);
  3937. if(isset($post['page']))
  3938. {
  3939. $page = $this->input->post('page',true);
  3940. $perpage = $this->input->post('perpage',true);
  3941. $type = $this->input->post('type',true);
  3942. $where = "1=1 ";
  3943. //数据排序
  3944. $order_str = "id asc";
  3945. if(empty($page))
  3946. {
  3947. $start = 0;
  3948. $perpage = 1;
  3949. }
  3950. else
  3951. {
  3952. $start = ($page - 1)*$perpage;
  3953. }
  3954. if($type)
  3955. {
  3956. $where .= " and type = '$type'";
  3957. }
  3958. //取得信息列表
  3959. $info_list = $this->fullorderexcelclassid->find_all($where,'id,title,type',$order_str,$start,$perpage);
  3960. $total = $this->fullorderexcelclassid->find_count($where);
  3961. $pagenum = ceil($total/$perpage);
  3962. $over = $total-($start+$perpage);
  3963. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  3964. echo json_encode($rows);exit;
  3965. }
  3966. $this->_Template('fullorderexcel_classid',$this->data);
  3967. }
  3968. //添加
  3969. public function _classidadd()
  3970. {
  3971. $post = $this->input->post(NULL, TRUE);
  3972. if(isset($post['title']))
  3973. {
  3974. if($this->fullorderexcelclassid->insert($post))
  3975. {
  3976. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  3977. }
  3978. else
  3979. {
  3980. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  3981. }
  3982. }
  3983. $this->_Template('fullorderexcel_classidadd',$this->data);
  3984. }
  3985. //修改
  3986. public function _classidedit($arg_array)
  3987. {
  3988. $post = $this->input->post(NULL, TRUE);
  3989. if(isset($post['id']))
  3990. {
  3991. $id = $this->input->post('id',true);
  3992. if($this->fullorderexcelclassid->save($post,$id))
  3993. {
  3994. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  3995. }
  3996. else
  3997. {
  3998. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  3999. }
  4000. }
  4001. $arg_array = $arg_array[0];
  4002. $fullorderexcelclassid = $this->fullorderexcelclassid->read($arg_array);
  4003. $this->data['fullorderexcelclassid'] = $fullorderexcelclassid;
  4004. $this->_Template('fullorderexcel_classidedit',$this->data);
  4005. }
  4006. }