Apiyy.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Apiyy extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_api','api');
  7. $this->load->_model('Model_shop','shop');
  8. $this->load->_model('Model_fullorder','fullorder');
  9. $this->load->_model('Model_fullordertt','fullordertt');
  10. $this->load->_model('Model_fullordersmt','fullordersmt');
  11. $this->load->_model('Model_country','country');
  12. $this->load->_model('Model_hl','hl');
  13. $this->load->_model('Model_is','is');
  14. $this->load->_model('Model_kdniao','kdniao');
  15. $this->load->_model('Model_typeclass','typeclass');
  16. $this->load->_model('Model_warehouse','warehouse');
  17. $this->load->_model('Model_fullorderexcel','fullorderexcel');
  18. $this->load->_model('Model_dhl','dhl');
  19. $this->load->_model('Model_usps','usps');
  20. $this->load->_model('Model_ups','ups');
  21. $this->load->_model('Model_dhltest','dhltest');
  22. $this->load->_model('Model_customer','customer');
  23. $this->load->_model('Model_express','express');
  24. $this->load->_model('Model_notice','notice');
  25. $this->load->_model('Model_emaildata','emaildata');
  26. $this->load->_model('Model_whlabel','whlabel');
  27. $this->load->_model('Model_productdescribe','productdescribe');
  28. $this->load->_model('Model_ljg','ljg');
  29. $this->load->_model('Model_commodityread','commodityread');
  30. $this->load->_model('Model_service','service');
  31. $this->load->_model('Model_fedex','fedex');
  32. $this->load->_model('Model_apismt','apismt');
  33. $this->load->_model('Model_cne','cne');
  34. $this->load->_model('Model_specialstock','specialstock');
  35. $this->load->_model('Model_whlabellabel','whlabellabel');
  36. $this->load->_model('Model_allocation','allocation');
  37. $this->load->_model('Model_yswaybill','yswaybill');
  38. $this->load->_model('Model_paypal','paypal');
  39. $this->load->_model('Model_17track','17track');
  40. $this->load->_model('Model_ck','ck');
  41. $this->load->_model('Model_weight','weight');
  42. $this->load->_model('Model_pay','pay');
  43. $this->load->_model('Model_setting','setting');
  44. $this->load->_model('Model_classid','classid');
  45. $this->load->_model('Model_apitt','apitt');
  46. $this->load->_model('Model_customertt','customertt');
  47. $this->load->_model('Model_als','als');
  48. $this->load->_model('Model_apiyy','apiyy');
  49. $this->load->_model('Model_whlabel_fc','whlabel_fc');
  50. $this->load->_model('Model_excel','excel');
  51. }
  52. //定义方法的调用规则 获取URI第二段值
  53. public function _remap($arg,$arg_array)
  54. {
  55. if($arg == 'c')
  56. {
  57. $this->_c();
  58. }
  59. else if($arg == 'cs')
  60. {
  61. $this->_cs($arg_array);
  62. }
  63. else if($arg == 'excel')
  64. {
  65. $this->_excel($arg_array);
  66. }
  67. else if($arg == 'xxpl')
  68. {
  69. $this->_xxpl();
  70. }
  71. else if($arg == 'rz')
  72. {
  73. $this->_rz($arg_array);
  74. }
  75. }
  76. public function _excel($arg_array)
  77. {
  78. $filePath = './data/yyexcel/'.$arg_array[0].'/excel.txt';
  79. $fileContent = file_get_contents($filePath);
  80. if ($fileContent !== false)
  81. {
  82. header( 'Content-Type: application/vnd.ms-excel; name=excel' );
  83. header( 'Content-type: application/octet-stream' );
  84. header( 'Content-Disposition: attachment; filename='.$arg_array[0].'.xls');
  85. header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
  86. header( 'Pragma: no-cache' );
  87. header( 'Expires: 0' );
  88. echo $fileContent;
  89. }
  90. else
  91. {
  92. echo "文件无法读取";
  93. }
  94. }
  95. public function _rz($arg_array)
  96. {
  97. $a = './data/yylog/RK-'.$arg_array[0].'.txt';
  98. if(is_file($a))
  99. {
  100. $myfile = fopen($a, "r") or die("Unable to open file!");
  101. $bc = fread($myfile,filesize($a));
  102. fclose($myfile);
  103. $zt = explode('\n',trim($bc,'\n'));
  104. //$bc = json_decode($bc,true);
  105. $nr = array();
  106. foreach($zt as $k=>$val)
  107. {
  108. $xx = explode(' = ',trim($val,' = '));
  109. if(stripos($xx[0],'RK-F') !== false)
  110. {
  111. $nr[$k][][0] = '入库发送';
  112. }
  113. else if(stripos($xx[0],'RK-J') !== false)
  114. {
  115. $nr[$k][][0] = '入库接收';
  116. }
  117. else if(stripos($xx[0],'SH-F') !== false)
  118. {
  119. $nr[$k][][0] = '审核发送';
  120. }
  121. else if(stripos($xx[0],'SH-J') !== false)
  122. {
  123. $nr[$k][][0] = '审核接收';
  124. }
  125. else if(stripos($xx[0],'DC-F') !== false)
  126. {
  127. $nr[$k][][0] = '调出发送';
  128. }
  129. else if(stripos($xx[0],'DC-J') !== false)
  130. {
  131. $nr[$k][][0] = '调出接收';
  132. }
  133. $nr[$k][][1] = $xx[1];
  134. }
  135. echo "<pre>";
  136. print_r($nr);
  137. }
  138. else
  139. {
  140. echo '无';
  141. }
  142. }
  143. public function _c()
  144. {
  145. $asd = array();
  146. $f = array('fullordersmt','fullordertt','fullorder');
  147. foreach($f as $v)
  148. {
  149. $d = $this->$v->find_all("librarytime > '".(time()-(12*24*3600))."' and (type = '13' or type = '16') and dbapi < 99");
  150. if($d)
  151. {
  152. $h = $this->_list($d,$v);
  153. foreach($h as $vv)
  154. {
  155. $x = 0;$c = 0;
  156. if(!isset($vv[0]))
  157. {
  158. continue;
  159. }
  160. $xs = $this->apiyy->_cxxsdd($vv['0']);
  161. $chd = $this->apiyy->_cxchd($vv['0']);
  162. if(isset($xs['Data'][0]))
  163. {
  164. $vv[] = '成功';
  165. $x = 1;
  166. }
  167. else
  168. {
  169. $vv[] = '无';
  170. }
  171. if(isset($chd['Data'][0]))
  172. {
  173. $vv[] = '成功';
  174. $c = 1;
  175. }
  176. else
  177. {
  178. $vv[] = '无';
  179. }
  180. if($x==1 && $c==1)
  181. {
  182. $this->$v->save(array('dbapi'=>99),$vv[4]);
  183. }
  184. $asd[] = $vv;
  185. }
  186. }
  187. }
  188. $title = "表 ".date("Y-m-d");
  189. $titlename = "<table border=1>
  190. <tr><th colspan='6' align='left'><h3>".$title."<h3></th></tr>
  191. <tr>
  192. <td>编号</td>
  193. <td>销售订单发送</td>
  194. <td>销售订单接收</td>
  195. <td>出货单发送</td>
  196. <td>出货单接收</td>
  197. <td>销售订单验证</td>
  198. <td>出货单验证</td>
  199. </tr>
  200. </table>";
  201. $filename = $title.".xls";
  202. $tail = "\n";
  203. $data = $this->excel->get_fz2_bc($asd,$titlename,$filename,$tail);
  204. $orderinfo = time();
  205. $pdtime = date('Y-m-d',time());
  206. $folderPath = './data/yyexcel/'.$pdtime; // 文件夹路径
  207. $permissions = 0777; // 权限设置
  208. if (!file_exists($folderPath)) { mkdir($folderPath, $permissions); }//创建文件夹
  209. file_exists($folderPath);
  210. if(!is_file($folderPath."/".$orderinfo.".txt"))
  211. {
  212. $myfile = fopen($folderPath."/excel.txt", "w") or die("Unable to open file!");
  213. fwrite($myfile, $data);
  214. fclose($myfile);
  215. }
  216. else
  217. {
  218. $myfile = fopen($folderPath."/exce.txt", "a+") or die("Unable to open file!");
  219. fwrite($myfile, $data);
  220. fclose($myfile);
  221. }
  222. }
  223. public function _list($d,$fullorder)//获取订单列表
  224. {
  225. $xx = array();
  226. foreach($d as $k=>$data)
  227. {
  228. $xx[$k] = array(0=>$data['number'],'xsf'=>'','xss'=>'','fhf'=>'','fhs'=>'',4=>$data['id']);
  229. $kh = $this->shop->read($data['shop']);
  230. $classid = $this->classid->sku();
  231. $tcall = $this->typeclass->find_all();
  232. $typeclass = array();
  233. foreach ($tcall as $v)
  234. {
  235. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  236. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  237. }
  238. $bm = '03';
  239. $xysc = array();
  240. $data['lh'] = array();
  241. $scid = '';$cw = '';$lc = 0;
  242. $sku = explode(';',trim($data['fpdata'],';'));
  243. $whlabelsc = explode('|',trim($data['whlabel'],'|'));
  244. foreach($sku as $key=>$val)
  245. {
  246. if(stripos($val,'-131-') !== false)
  247. {
  248. continue;
  249. }
  250. $pm = $classid;
  251. $jm = $classid;
  252. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  253. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  254. $ts = explode('|',trim($features,'|'));
  255. if(stripos($ts[0],',') !== false)
  256. {
  257. $ft = explode(',',$ts[0]);
  258. $features = explode('-',trim($ft[1],'-'));
  259. $features[] = $ft[0];
  260. }
  261. else
  262. {
  263. $features = explode('-',trim($ts[0],'-'));
  264. }
  265. foreach($features as $k=>$v)
  266. {
  267. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  268. {
  269. if($typeclass[$v]['bm'] != '')
  270. {
  271. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  272. }
  273. }
  274. if($v != 0)
  275. {
  276. if(isset($pm[$typeclass[$v]['classid']]))
  277. {
  278. if($typeclass[$v]['title'] == '9A')
  279. {
  280. $pm[$typeclass[$v]['classid']] = '9A';
  281. }
  282. else if($typeclass[$v]['title'] == '10A')
  283. {
  284. $pm[$typeclass[$v]['classid']] = '10A';
  285. }
  286. else
  287. {
  288. $clzh = $typeclass[$v]['zh'];
  289. if(stripos($typeclass[$v]['zh'],'|') !== false)
  290. {
  291. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  292. $clzh = $clzh[0];
  293. }
  294. $pm[$typeclass[$v]['classid']] = $clzh;
  295. }
  296. }
  297. if(isset($jm[$typeclass[$v]['classid']]))
  298. {
  299. if($typeclass[$v]['jm'])
  300. {
  301. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  302. }
  303. }
  304. }
  305. }
  306. $jm = array_filter($jm);//去除空值
  307. $jm = implode("-",$jm);
  308. $pm = array_filter($pm);//去除空值
  309. $zh = implode(" ",$pm);
  310. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  311. if(!isset($ts[1]))
  312. {
  313. $ts[1] = '无';
  314. }
  315. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
  316. if(isset($lh['Data'][0]))
  317. {
  318. if($lh['Data'][0]['m_isSucess'] != 1)
  319. {
  320. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  321. {
  322. $xx[$k][1] = $lh;
  323. $this->apiyy->insert(array('number'=>$data['number'],'error'=>$lh['Data'][0]['m_errorMsg'],'type'=>'料号','cs'=>$fullorder));
  324. continue;
  325. }
  326. }
  327. }
  328. else
  329. {
  330. $this->apiyy->insert(array('number'=>$data['number'],'error'=>json_encode($lh),'type'=>'料号','cs'=>$fullorder));
  331. continue;
  332. }
  333. $data['lh'][] = array('sku'=>$jm,'ts'=>$ts[2]);
  334. if(stripos($val,'-131-') !== false)
  335. {
  336. continue;
  337. }
  338. if(stripos($val,'-126-') !== false)
  339. {
  340. $drck = '12003';//进入发条库
  341. }
  342. else if(stripos($val,'-127-') !== false)
  343. {
  344. $drck = '12004';//进入发块库
  345. }
  346. else
  347. {
  348. $drck = '12006';//其它进入完成库
  349. }
  350. }
  351. $data['yyid'] = $kh['yyid'];
  352. @$ay = $this->apiyy->_neworder($data,$classid,$tcall);
  353. $xx[$k]['xsf'] = $ay['fs'];
  354. $xx[$k]['xss'] = $ay['fh'];
  355. if($ay['c'] != 0)
  356. {
  357. $this->$fullorder->save(array('dbapi'=>0),$data['id']);
  358. $this->apiyy->insert(array('number'=>$data['number'],'type'=>'销售订单','error'=>$ay['error'],'cs'=>$fullorder));
  359. }
  360. else
  361. {
  362. $this->$fullorder->save(array('dbapi'=>99),$data['id']);
  363. $chdfs = '';$chdjs = '';$chdcg = 0;
  364. foreach($data['lh'] as $k=>$v)
  365. {
  366. $chd = array('number'=>$data['number'],'i'=>$k+1,'ts'=>$v['ts']);
  367. $c = $this->apiyy->get_chd($chd);
  368. $chdfs = $c['1'];
  369. $chdjs = json_encode($c['0']);
  370. if(isset($c['Data']))
  371. {
  372. if($c['Data'][0]['m_isSucess'] == 1)
  373. {
  374. $chdcg += 1;
  375. }
  376. }
  377. }
  378. $xx[$k]['fhf'] = $chdfs;
  379. $xx[$k]['fhs'] = $chdjs;
  380. if($chdcg == count($data['lh']))
  381. {
  382. $cs = $this->$fullorder->save(array('dbapi'=>100),$data['id']);
  383. }
  384. }
  385. }
  386. return $xx;
  387. }
  388. public function _cs($arg_array)
  389. {
  390. $asd = array();
  391. $data = $this->fullorder->get_number($arg_array[0]);
  392. $fullorder = 'fullorder';
  393. $xx = array();
  394. $xx[$k] = array(0=>$data['number'],'xsf'=>'','xss'=>'','fhf'=>'','fhs'=>'',4=>$data['id']);
  395. $kh = $this->shop->read($data['shop']);
  396. $classid = $this->classid->sku();
  397. $tcall = $this->typeclass->find_all();
  398. $typeclass = array();
  399. foreach ($tcall as $v)
  400. {
  401. $tcjm[$v['id']] = array($v['jm'],$v['classid']);
  402. $typeclass[$v['id']] = array('zh'=>$v['zh'],'classid'=>$v['classid'],'bm'=>$v['bm'],'title'=>$v['title'],'jm'=>$v['jm']);
  403. }
  404. $bm = '03';
  405. $xysc = array();
  406. $data['lh'] = array();
  407. $scid = '';$cw = '';$lc = 0;
  408. $sku = explode(';',trim($data['fpdata'],';'));
  409. $whlabelsc = explode('|',trim($data['whlabel'],'|'));
  410. foreach($sku as $key=>$val)
  411. {
  412. if(stripos($val,'-131-') !== false)
  413. {
  414. continue;
  415. }
  416. $pm = $classid;
  417. $jm = $classid;
  418. $bmpx = array(13=>'',16=>'',18=>'',25=>'',26=>'',41=>'');
  419. $features = str_replace(array('-163-','-164-','-165-','-166-'),'-',$val);
  420. $ts = explode('|',trim($features,'|'));
  421. if(stripos($ts[0],',') !== false)
  422. {
  423. $ft = explode(',',$ts[0]);
  424. $features = explode('-',trim($ft[1],'-'));
  425. $features[] = $ft[0];
  426. }
  427. else
  428. {
  429. $features = explode('-',trim($ts[0],'-'));
  430. }
  431. foreach($features as $k=>$v)
  432. {
  433. if(isset($typeclass[$v]) && isset($bmpx[$typeclass[$v]['classid']]))
  434. {
  435. if($typeclass[$v]['bm'] != '')
  436. {
  437. $bmpx[$typeclass[$v]['classid']] = $typeclass[$v]['bm'];
  438. }
  439. }
  440. if($v != 0)
  441. {
  442. if(isset($pm[$typeclass[$v]['classid']]))
  443. {
  444. if($typeclass[$v]['title'] == '9A')
  445. {
  446. $pm[$typeclass[$v]['classid']] = '9A';
  447. }
  448. else if($typeclass[$v]['title'] == '10A')
  449. {
  450. $pm[$typeclass[$v]['classid']] = '10A';
  451. }
  452. else
  453. {
  454. $clzh = $typeclass[$v]['zh'];
  455. if(stripos($typeclass[$v]['zh'],'|') !== false)
  456. {
  457. $clzh = explode('|',rtrim($typeclass[$v]['zh'],'|'));
  458. $clzh = $clzh[0];
  459. }
  460. $pm[$typeclass[$v]['classid']] = $clzh;
  461. }
  462. }
  463. if(isset($jm[$typeclass[$v]['classid']]))
  464. {
  465. if($typeclass[$v]['jm'])
  466. {
  467. $jm[$typeclass[$v]['classid']] = $typeclass[$v]['jm'];
  468. }
  469. }
  470. }
  471. }
  472. $jm = array_filter($jm);//去除空值
  473. $jm = implode("-",$jm);
  474. $pm = array_filter($pm);//去除空值
  475. $zh = implode(" ",$pm);
  476. $zh = preg_replace("/\r\n|\r|\n/",'',trim($zh,' '));
  477. if(!isset($ts[1]))
  478. {
  479. $ts[1] = '无';
  480. }
  481. $lh = $this->apiyy->get_cjlp(array('jm'=>$jm,'title'=>$ts[1],'zh'=>$zh,'bm'=>$bm.implode("",$bmpx)));
  482. if(isset($lh['Data'][0]))
  483. {
  484. if($lh['Data'][0]['m_isSucess'] != 1)
  485. {
  486. if($lh['Data'][0]['m_errorMsg'] != '料号 已存在,请重新输入!')
  487. {
  488. $xx[$k][1] = $lh;
  489. $this->apiyy->insert(array('number'=>$data['number'],'error'=>$lh['Data'][0]['m_errorMsg'],'type'=>'料号','cs'=>$fullorder));
  490. continue;
  491. }
  492. }
  493. }
  494. else
  495. {
  496. $this->apiyy->insert(array('number'=>$data['number'],'error'=>json_encode($lh),'type'=>'料号','cs'=>$fullorder));
  497. continue;
  498. }
  499. $data['lh'][] = array('sku'=>$jm,'ts'=>$ts[2]);
  500. if(stripos($val,'-131-') !== false)
  501. {
  502. continue;
  503. }
  504. if(stripos($val,'-126-') !== false)
  505. {
  506. $drck = '12003';//进入发条库
  507. }
  508. else if(stripos($val,'-127-') !== false)
  509. {
  510. $drck = '12004';//进入发块库
  511. }
  512. else
  513. {
  514. $drck = '12006';//其它进入完成库
  515. }
  516. }
  517. $data['yyid'] = $kh['yyid'];
  518. @$ay = $this->apiyy->_neworder($data,$classid,$tcall);
  519. echo "<pre>";
  520. print_r(array($data,$classid,$tcall));
  521. echo "<pre>";
  522. print_r($ay);
  523. exit;
  524. $xx[$k]['xsf'] = $ay['fs'];
  525. $xx[$k]['xss'] = $ay['fh'];
  526. if($ay['c'] != 0)
  527. {
  528. $this->$fullorder->save(array('dbapi'=>0),$data['id']);
  529. $this->apiyy->insert(array('number'=>$data['number'],'type'=>'销售订单','error'=>$ay['error'],'cs'=>$fullorder));
  530. }
  531. else
  532. {
  533. $this->$fullorder->save(array('dbapi'=>99),$data['id']);
  534. $chdfs = '';$chdjs = '';$chdcg = 0;
  535. foreach($data['lh'] as $k=>$v)
  536. {
  537. $chd = array('number'=>$data['number'],'i'=>$k+1,'ts'=>$v['ts']);
  538. $c = $this->apiyy->get_chd($chd);
  539. $chdfs = $c['1'];
  540. $chdjs = json_encode($c['0']);
  541. if(isset($c['Data']))
  542. {
  543. if($c['Data'][0]['m_isSucess'] == 1)
  544. {
  545. $chdcg += 1;
  546. }
  547. }
  548. }
  549. $xx[$k]['fhf'] = $chdfs;
  550. $xx[$k]['fhs'] = $chdjs;
  551. if($chdcg == count($data['lh']))
  552. {
  553. $cs = $this->$fullorder->save(array('dbapi'=>100),$data['id']);
  554. }
  555. }
  556. }
  557. public function _xxpl()
  558. {
  559. $dir = '/data/excel/'.date('Ymd',time()).'/';
  560. $config['upload_path'] = '.'.$dir ;
  561. $config['file_name'] = date('Ymd_His_',time()).rand(1000,9999);
  562. $config['allowed_types'] = 'xls|xlsx|csv';
  563. $config['max_size'] = 10240;
  564. $this->load->library('upload', $config);
  565. $this->upload->initialize($config);
  566. if ($this->upload->do_upload('userfile'))
  567. {
  568. $full_path = $dir.$this->upload->data('file_name');
  569. $fileName = '.' . $full_path;
  570. if (!file_exists($fileName))
  571. {
  572. echo json_encode(array('msg'=>"上传失败,请重试",'success'=>false));exit;
  573. }
  574. else
  575. {
  576. require_once "./data/excel/PHPExcel/IOFactory.php";
  577. @$phpExcel = PHPExcel_IOFactory::load($fileName);// 载入当前文件
  578. @$phpExcel->setActiveSheetIndex(0);// 设置为默认表
  579. $sheetCount = $phpExcel->getSheetCount();// 获取表格数量
  580. $row = $phpExcel->getActiveSheet()->getHighestRow();// 获取行数
  581. $column = $phpExcel->getActiveSheet()->getHighestColumn();// 获取列数
  582. ++$column;//如果列数大于26行
  583. $list = array();
  584. for ($i = 2; $i <= $row; $i++) // 行数循环
  585. {
  586. $data = array();
  587. for ($c = 'A'; $c != $column; $c++) // 列数循环
  588. {
  589. $data[] = $phpExcel->getActiveSheet()->getCell($c . $i)->getValue();
  590. }
  591. $list[] = $data;
  592. }
  593. }
  594. $cw = [];$d = [];
  595. foreach ($list as $v)
  596. {
  597. $v = $v[0];
  598. $fullorder_name = 'fullorder';
  599. $y = $this->fullorder->get_number($v);
  600. if(!$y)
  601. {
  602. $fullorder_name = 'fullordersmt';
  603. $y = $this->fullordersmt->get_number($v);
  604. if(!$y)
  605. {
  606. $fullorder_name = 'fullordertt';
  607. $y = $this->fullordertt->get_number($v);
  608. if(!$y)
  609. {
  610. $cw[] = [$v,'无数据'];
  611. }
  612. }
  613. }
  614. $d[$fullorder_name][] = $y;
  615. }
  616. foreach($d as $key=>$val)
  617. {
  618. $h = $this->_list($val,$key);
  619. foreach($h as $vv)
  620. {
  621. $x = 0;$c = 0;
  622. if(!isset($vv[0]))
  623. {
  624. continue;
  625. }
  626. $xs = $this->apiyy->_cxxsdd($vv['0']);
  627. $chd = $this->apiyy->_cxchd($vv['0']);
  628. if(isset($xs['Data'][0]))
  629. {
  630. $vv[] = '成功';
  631. $x = 1;
  632. }
  633. else
  634. {
  635. $vv[] = '无';
  636. }
  637. if(isset($chd['Data'][0]))
  638. {
  639. $vv[] = '成功';
  640. $c = 1;
  641. }
  642. else
  643. {
  644. $vv[] = '无';
  645. }
  646. if($x==1 && $c==1)
  647. {
  648. $this->$v->save(array('dbapi'=>99),$vv[4]);
  649. }
  650. $asd[] = $vv;
  651. }
  652. }
  653. echo "<pre>";
  654. print_r($cw);
  655. echo "<pre>";
  656. print_r($asd);
  657. }
  658. else
  659. {
  660. echo json_encode(array('msg'=>'上传失败!','t'=>$this->upload->display_errors(),'success'=>false));exit;
  661. }
  662. }
  663. }