Notice.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Notice extends Start_Controller {
  3. public function __construct(){
  4. parent::__construct();
  5. $this->load->library('session');
  6. $this->load->_model('Model_user','user');
  7. $this->load->_model('Model_notice','notice');
  8. $this->load->_model('Model_noticeemail','noticeemail');
  9. $this->load->_model('Model_shop','shop');
  10. $this->load->_model('Model_typeclass','typeclass');
  11. $this->load->_model('Model_fullorder','fullorder');
  12. $this->load->_model('Model_fullordertt','fullordertt');
  13. $this->load->_model('Model_fullordersmt','fullordersmt');
  14. $this->load->_model('Model_express','express');
  15. $this->load->_model('Model_emaildata','emaildata');
  16. $this->load->_model('Model_als','als');
  17. $this->load->_model('Model_apitt','apitt');
  18. $this->load->_model('Model_producttitle','producttitle');
  19. }
  20. //定义方法的调用规则 获取URI第二段值
  21. public function _remap($arg,$arg_array)
  22. {
  23. if($arg == 'add')//添加
  24. {
  25. $this->_add($arg_array);
  26. }
  27. else if($arg == 'edit')//修改
  28. {
  29. $this->_edit($arg_array);
  30. }
  31. else if($arg == 'del')//修改
  32. {
  33. $this->_del();
  34. }
  35. else if($arg == 'rows')//数据
  36. {
  37. $this->_rows();
  38. }
  39. else if($arg == 'email')
  40. {
  41. $this->_email();
  42. }
  43. else if($arg == 'addemail')
  44. {
  45. $this->_addemail();
  46. }
  47. else if($arg == 'emailfs')
  48. {
  49. $this->_emailfs();
  50. }
  51. else if($arg == 'testfs')
  52. {
  53. $this->_testfs();
  54. }
  55. else
  56. {
  57. $this->_index($arg_array);
  58. }
  59. }
  60. //管理
  61. public function _index($arg_array)
  62. {
  63. if(isset($_SESSION['api']))
  64. {
  65. $user = $this->user->get_api($_SESSION['api']);
  66. $fgshop = "";$sid = "";
  67. $user = explode('|',trim($user['shop'],'|'));
  68. foreach ($user as $value)
  69. {
  70. $fgshop .= " shop = ".$value." or";
  71. $sid .= " id = ".$value." or";
  72. }
  73. }
  74. $post = $this->input->post(NULL, TRUE);
  75. if(isset($post['page']))
  76. {
  77. $page = $this->input->post('page',true);
  78. $perpage = $this->input->post('perpage',true);
  79. $shop = $this->input->post('shop',true);
  80. $type = $this->input->post('type',true);
  81. $ordertatus = $this->input->post('ordertatus',true);
  82. $arg = $this->input->post('arg',true);
  83. $logisticstatus = $this->input->post('logisticstatus',true);
  84. $state = $this->input->post('state',true);
  85. $where = "1=1 and (".rtrim($fgshop,'or').")";
  86. if($shop)
  87. {
  88. $where .= " and shop = '$shop'";
  89. }
  90. if($state){
  91. $where .= " and state = '$state'";
  92. }
  93. if($type)
  94. {
  95. $where .= " and type = '$type'";
  96. }
  97. if($ordertatus)
  98. {
  99. $where .= " and ordertatus = '$ordertatus'";
  100. }
  101. if($logisticstatus)
  102. {
  103. $where .= " and logisticstatus = '$logisticstatus'";
  104. }
  105. //数据排序
  106. $order_str = "id asc";
  107. if(empty($page))
  108. {
  109. $start = 0;
  110. $perpage = 1;
  111. }
  112. else
  113. {
  114. $start = ($page - 1)*$perpage;
  115. }
  116. //取得信息列表
  117. $info_list = $this->notice->find_all($where,'id,shop,title,type,message,email,ordertatus,logisticstatus,ktime,jtime,state',$order_str,$start,$perpage);
  118. //格式化数据
  119. foreach ($info_list as $key=>$value)
  120. {
  121. $shop = $this->shop->read($value['shop']);
  122. $info_list[$key]['shop'] = $shop['shopname'];
  123. $email = $this->emaildata->read($value['email']);
  124. $info_list[$key]['email'] = $email['smtp_user'];
  125. $info_list[$key]['ktime'] = date('Y-m-d',$value['ktime']);
  126. $info_list[$key]['jtime'] = date('Y-m-d',$value['jtime']);
  127. if($value['type'] == 1)
  128. {
  129. $info_list[$key]['type'] = '自动发送';
  130. }
  131. else if($value['type'] == 2)
  132. {
  133. $info_list[$key]['type'] = '物流追踪';
  134. }
  135. else if($value['type'] == 3)
  136. {
  137. $info_list[$key]['type'] = '营销';
  138. }
  139. else if($value['type'] == 4)
  140. {
  141. $info_list[$key]['type'] = '运单号通知';
  142. }
  143. if($value['message'] == 1)
  144. {
  145. $info_list[$key]['message'] = '发送邮件';
  146. }
  147. //订单状态开始
  148. $typeclass = $this->typeclass->read($value['ordertatus']);
  149. $info_list[$key]['ordertatus'] = $typeclass?(($arg==1)?$typeclass['title']:$typeclass['spare']):'';
  150. //订单状态结束
  151. if($value['logisticstatus'] == 0)
  152. {
  153. $info_list[$key]['logisticstatus'] = "无信息";
  154. }
  155. else if($value['logisticstatus'] == 2)
  156. {
  157. $info_list[$key]['logisticstatus'] = "已取件";
  158. }
  159. else if($value['logisticstatus'] == 3)
  160. {
  161. $info_list[$key]['logisticstatus'] = "在途中";
  162. }
  163. /**
  164. else if($value['logisticstatus'] == 4)
  165. {
  166. $info_list[$key]['logisticstatus'] = "到达目的地国";
  167. }
  168. **/
  169. else if($value['logisticstatus'] == 4 || $value['logisticstatus'] == 5)
  170. {
  171. $info_list[$key]['logisticstatus'] = "即将派送";
  172. }
  173. else if($value['logisticstatus'] == 6)
  174. {
  175. $info_list[$key]['logisticstatus'] = "已签收";
  176. }
  177. else if($value['logisticstatus'] == 1)
  178. {
  179. $info_list[$key]['logisticstatus'] = "派送异常";
  180. }
  181. if($value['message'] == 1)
  182. {
  183. $info_list[$key]['message'] = '发送邮件';
  184. }
  185. else if($value['message'] == 2)
  186. {
  187. $info_list[$key]['message'] = 'AE站内信';
  188. }
  189. else if($value['message'] == 3)
  190. {
  191. $info_list[$key]['message'] = 'TT会话';
  192. }
  193. if($value['state'] == 1)
  194. {
  195. $info_list[$key]['state'] = '启用中';
  196. }
  197. else if($value['state'] == 2)
  198. {
  199. $info_list[$key]['state'] = '未启用';
  200. }
  201. }
  202. $total = $this->notice->find_count($where);
  203. $pagenum = ceil($total/$perpage);
  204. $over = $total-($start+$perpage);
  205. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  206. echo json_encode($rows);exit;
  207. }
  208. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  209. $this->data['wlshop'] = $wlshop;
  210. $mb = 2;
  211. if(isset($arg_array[0]))
  212. {
  213. if($arg_array[0]=='smt')
  214. {
  215. $mb = 1;
  216. }
  217. else if($arg_array[0]=='dlz')
  218. {
  219. $mb = 2;
  220. }
  221. else if($arg_array[0]=='tt')
  222. {
  223. $mb = 3;
  224. }
  225. }
  226. $this->data['arg'] = $mb;
  227. $this->_Template('notice',$this->data);
  228. }
  229. //添加
  230. public function _add($arg_array)
  231. {
  232. if(isset($_SESSION['api']))
  233. {
  234. $user = $this->user->get_api($_SESSION['api']);
  235. $fgshop = "";$sid = "";
  236. $user = explode('|',trim($user['shop'],'|'));
  237. foreach ($user as $value)
  238. {
  239. $fgshop .= " shop = ".$value." or";
  240. $sid .= " id = ".$value." or";
  241. }
  242. }
  243. $post = $this->input->post(NULL, TRUE);
  244. if(isset($post['title']))
  245. {
  246. $post['title'] = $this->input->post('title',true);
  247. $post['shop'] = $this->input->post('shop',true);
  248. $post['message'] = $this->input->post('message',true);
  249. $post['type'] = $this->input->post('type',true);
  250. $post['repeat'] = $this->input->post('repeat',true);
  251. $ktime = $this->input->post('ktime',true);
  252. $post['ktime'] = strtotime($ktime);
  253. $jtime = $this->input->post('jtime',true);
  254. $post['jtime'] = strtotime($jtime);
  255. $post['content'] = $this->input->post('content');
  256. $emailtitle = $this->input->post('emailtitle');
  257. $post['js'] = '';
  258. if($emailtitle)
  259. {
  260. $post['emailtitle'] = $emailtitle;
  261. }
  262. if($post['type'] == 1)
  263. {
  264. $post['ordertatus'] = $this->input->post('ordertatus',true);
  265. if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
  266. {
  267. $post['sending'] = $this->input->post('sending',true);
  268. $post['timeinterval'] = $this->input->post('timeinterval',true);
  269. }
  270. }
  271. else if($post['type'] == 2)
  272. {
  273. $post['logisticstatus'] = $this->input->post('logisticstatus',true);
  274. }
  275. else if($post['type'] == 3)
  276. {
  277. $marketing = $this->input->post('marketing',true);
  278. $post['marketing'] = strtotime($marketing);
  279. }
  280. else if($post['type'] == 4)
  281. {
  282. $post['js'] = $this->input->post('js',true);
  283. if($post['js'] != '')
  284. {
  285. $post['js'] = ','.$post['js'];
  286. }
  287. $post['express'] = $this->input->post('express',true);
  288. if($post['express'] != '')
  289. {
  290. $post['express'] = ','.$post['express'];
  291. }
  292. }
  293. $post['state'] = $this->input->post('state',true);
  294. if($post['state'] == 1)
  295. {
  296. $post['statetime'] = time();
  297. }
  298. if($this->notice->insert($post))
  299. {
  300. echo json_encode(array('msg'=>'添加成功','success'=>true));exit;
  301. }
  302. else
  303. {
  304. echo json_encode(array('msg'=>'添加失败,请重试','success'=>false));exit;
  305. }
  306. }
  307. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  308. $this->data['wlshop'] = $wlshop;
  309. $email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
  310. $this->data['email'] = $email;
  311. $mb = 2;
  312. if(isset($arg_array[0]))
  313. {
  314. if($arg_array[0]=='smt')
  315. {
  316. $mb = 1;
  317. }
  318. else if($arg_array[0]=='dlz')
  319. {
  320. $mb = 2;
  321. }
  322. else if($arg_array[0]=='tt')
  323. {
  324. $mb = 3;
  325. }
  326. }
  327. $this->data['arg'] = $mb;
  328. $this->_Template('notice_add',$this->data);
  329. }
  330. //修改
  331. public function _edit($arg_array)
  332. {
  333. if(isset($_SESSION['api']))
  334. {
  335. $user = $this->user->get_api($_SESSION['api']);
  336. $fgshop = "";$sid = "";
  337. $user = explode('|',trim($user['shop'],'|'));
  338. foreach ($user as $value)
  339. {
  340. $fgshop .= " shop = ".$value." or";
  341. $sid .= " id = ".$value." or";
  342. }
  343. }
  344. $post = $this->input->post(NULL, TRUE);
  345. if(isset($post['id']))
  346. {
  347. $id = $this->input->post('id',true);
  348. $post['title'] = $this->input->post('title',true);
  349. $post['shop'] = $this->input->post('shop',true);
  350. $post['message'] = $this->input->post('message',true);
  351. $post['type'] = $this->input->post('type',true);
  352. $post['repeat'] = $this->input->post('repeat',true);
  353. $ktime = $this->input->post('ktime',true);
  354. $post['ktime'] = strtotime($ktime);
  355. $jtime = $this->input->post('jtime',true);
  356. $post['jtime'] = strtotime($jtime);
  357. $post['content'] = $this->input->post('content');
  358. $post['emailtitle'] = $this->input->post('emailtitle');
  359. $post['js'] = '';
  360. if($post['type'] == 1)
  361. {
  362. $post['ordertatus'] = $this->input->post('ordertatus',true);
  363. if($post['ordertatus'] == 2 || $post['ordertatus'] == 3)
  364. {
  365. $post['sending'] = $this->input->post('sending',true);
  366. $post['timeinterval'] = $this->input->post('timeinterval',true);
  367. }
  368. $post['logisticstatus'] = 0;
  369. }
  370. else if($post['type'] == 2)
  371. {
  372. $post['ordertatus'] = 0;//非订单状态写入:未获取
  373. $post['logisticstatus'] = $this->input->post('logisticstatus',true);
  374. }
  375. else if($post['type'] == 3)
  376. {
  377. $post['ordertatus'] = 0;//非订单状态写入:未获取
  378. $marketing = $this->input->post('marketing',true);
  379. $post['marketing'] = strtotime($marketing);
  380. }
  381. else if($post['type'] == 4)
  382. {
  383. $post['js'] = $this->input->post('js',true);
  384. if($post['js'] != '')
  385. {
  386. $post['js'] = ','.$post['js'];
  387. }
  388. $post['express'] = $this->input->post('express',true);
  389. if($post['express'] != '')
  390. {
  391. $post['express'] = ','.$post['express'];
  392. }
  393. }
  394. $post['state'] = $this->input->post('state',true);
  395. if($post['state'] == 1)
  396. {
  397. $post['statetime'] = time();
  398. }
  399. if($this->notice->save($post,$id))
  400. {
  401. echo json_encode(array('msg'=>'修改成功','success'=>true));exit;
  402. }
  403. else
  404. {
  405. echo json_encode(array('msg'=>'修改失败,请重试','success'=>false));exit;
  406. }
  407. }
  408. $notice = $this->notice->read($arg_array[0]);
  409. $this->data['notice'] = $notice;
  410. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  411. $this->data['wlshop'] = $wlshop;
  412. $email = $this->emaildata->find_all('1=1 and '.rtrim($fgshop,'or'));
  413. $this->data['email'] = $email;
  414. $mb = 2;
  415. if(isset($arg_array[0]))
  416. {
  417. if($arg_array[0]=='smt')
  418. {
  419. $mb = 1;
  420. }
  421. else if($arg_array[0]=='dlz')
  422. {
  423. $mb = 2;
  424. }
  425. else if($arg_array[0]=='tt')
  426. {
  427. $mb = 3;
  428. }
  429. }
  430. $this->data['arg'] = $mb;
  431. $this->_Template('notice_edit',$this->data);
  432. }
  433. //删除
  434. public function _del()
  435. {
  436. $post = $this->input->post(NULL, TRUE);
  437. if(isset($post['s']))
  438. {
  439. $id_arr = $this->input->post('s');
  440. $id_arr = explode(',',$id_arr);
  441. if(!$id_arr)
  442. {
  443. echo json_encode(array('msg'=>'参数错误!','success'=>false));exit;
  444. }
  445. //循环删除记录
  446. foreach ($id_arr as $v)
  447. {
  448. $this->notice->remove($v);
  449. }
  450. echo json_encode(array('del'=>$id_arr,'msg'=>'删除记录成功!','success'=>true));
  451. }
  452. }
  453. public function _email()
  454. {
  455. if(isset($_SESSION['api']))
  456. {
  457. $user = $this->user->get_api($_SESSION['api']);
  458. $fgshop = "";$sid = "";
  459. $user = explode('|',trim($user['shop'],'|'));
  460. foreach ($user as $value)
  461. {
  462. $fgshop .= " shop = ".$value." or";
  463. $sid .= " id = ".$value." or";
  464. }
  465. }
  466. $post = $this->input->post(NULL, TRUE);
  467. if(isset($post['page']))
  468. {
  469. $page = $this->input->post('page',true);
  470. $perpage = $this->input->post('perpage',true);
  471. $shop = $this->input->post('shop',true);
  472. $email = $this->input->post('email',true);
  473. $notice = $this->input->post('notice',true);
  474. $xztime = $this->input->post('xztime',true);
  475. $timetk = $this->input->post('timetk',true);
  476. $timetj = $this->input->post('timetj',true);
  477. $timetk = strtotime($timetk);
  478. $timetj = strtotime($timetj);
  479. $where = "1=1 and (".rtrim($fgshop,'or').")";
  480. if($shop)
  481. {
  482. $where .= " and shop = '$shop'";
  483. }
  484. if($email)
  485. {
  486. $where .= " and email like '%$email%'";
  487. }
  488. if($notice)
  489. {
  490. $where .= " and notice = '$notice'";
  491. }
  492. if($timetk && $timetj)
  493. {
  494. $where .= " and ".$xztime." > '$timetk' and ".$xztime." < '$timetj'";
  495. }
  496. //数据排序
  497. $order_str = "id desc";
  498. if(empty($page))
  499. {
  500. $start = 0;
  501. $perpage = 1;
  502. }
  503. else
  504. {
  505. $start = ($page - 1)*$perpage;
  506. }
  507. //取得信息列表
  508. $info_list = $this->noticeemail->find_all($where,'id,shop,email,notice,addtime,time',$order_str,$start,$perpage);
  509. //格式化数据
  510. foreach ($info_list as $key=>$value)
  511. {
  512. $data = $this->noticeemail->read($value['id']);
  513. $shop = $this->shop->read($value['shop']);
  514. $info_list[$key]['shop'] = $shop['shopname'];
  515. $info_list[$key]['addtime'] = date('Y-m-d H:i:s',$value['addtime']);
  516. if(is_numeric($value['time']) && $value['time'] > 0)
  517. {
  518. $info_list[$key]['time'] = date('Y-m-d H:i:s',$value['time']);
  519. }
  520. else
  521. {
  522. $info_list[$key]['time'] = '';
  523. if($data['error'] != '')
  524. {
  525. $info_list[$key]['time'] = $data['error'];
  526. }
  527. }
  528. $notice = $this->notice->read($value['notice']);
  529. $info_list[$key]['notice'] = $notice['title'];
  530. }
  531. $total = $this->noticeemail->find_count($where);
  532. $pagenum = ceil($total/$perpage);
  533. $over = $total-($start+$perpage);
  534. $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($info_list));
  535. echo json_encode($rows);exit;
  536. }
  537. $wlshop = $this->shop->find_all('1=1 and '.rtrim($sid,'or'));
  538. $this->data['wlshop'] = $wlshop;
  539. $notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
  540. $this->data['notice'] = $notice;
  541. $this->_Template('notice_email',$this->data);
  542. }
  543. public function _addemail()
  544. {
  545. if(isset($_SESSION['api']))
  546. {
  547. $user = $this->user->get_api($_SESSION['api']);
  548. $fgshop = "";$sid = "";
  549. $user = explode('|',trim($user['shop'],'|'));
  550. foreach ($user as $value)
  551. {
  552. $fgshop .= " shop = ".$value." or";
  553. $sid .= " id = ".$value." or";
  554. }
  555. }
  556. $post = $this->input->post(NULL, TRUE);
  557. if(isset($post['email']))
  558. {
  559. $time = time();$cw = '';$i = 0;$fs = '';
  560. $notice = $this->input->post('notice',true);
  561. $n = $this->notice->read($notice);
  562. $email = $this->input->post('email',true);
  563. $email = str_replace(PHP_EOL, ',', $email);
  564. $email = explode(',',trim($email,','));
  565. $this->db->trans_begin();
  566. foreach ($email as $v)
  567. {
  568. $f = $this->fullorder->find_all("email = '$v' and shop = '".$n['shop']."'",'*','id desc');
  569. if(isset($f[0]['email']))
  570. {
  571. $tid = $this->noticeemail->insert(array('shop'=>$f[0]['shop'],'email'=>$v,'notice'=>$notice,'addtime'=>$time));
  572. $fs .= $f[0]['id'].'-'.$tid.',';
  573. }
  574. else
  575. {
  576. $i++;
  577. $cw .= $v.',';
  578. }
  579. }
  580. if(count($email) == $i)
  581. {
  582. echo json_encode(array('msg'=>'Email地址全部错误,请排查!','success'=>false));exit;
  583. }
  584. if($this->db->trans_status() === TRUE)
  585. {
  586. $this->db->trans_commit();
  587. $ch = curl_init();
  588. $url = 'http://a'.rand(10,50).'.wepolicy.cn/notice/emailfs';
  589. curl_setopt($ch,CURLOPT_URL,$url);
  590. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  591. curl_setopt($ch,CURLOPT_HEADER,0);
  592. curl_setopt($ch,CURLOPT_POST, 1);
  593. curl_setopt($ch,CURLOPT_TIMEOUT,1);
  594. //设置post数据
  595. $post = array();
  596. $post['notice'] = $notice;
  597. $post['fs'] = trim($fs,',');
  598. curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($post));
  599. $res = curl_exec($ch);
  600. curl_close($ch);
  601. if($i > 0)
  602. {
  603. echo json_encode(array('msg'=>'有错误Email地址,请排查!其它正常发送中。<br>错误Email:<br>'.trim($cw,',').'<br>','success'=>true));exit;
  604. }
  605. else
  606. {
  607. echo json_encode(array('n'=>0,'msg'=>'添加成功,邮件逐条发送中','success'=>true));exit;
  608. }
  609. }
  610. else
  611. {
  612. $this->db->trans_rollback();
  613. echo json_encode(array('msg'=>'系统错误,请重试!!','success'=>false));exit;
  614. }
  615. }
  616. $notice = $this->notice->find_all("message = 1 and type = '3' and (".rtrim($fgshop,'or').")");
  617. $this->data['notice'] = $notice;
  618. $this->_Template('notice_addemail',$this->data);
  619. }
  620. public function _emailfs()
  621. {
  622. $time = time();
  623. $post = $this->input->post(NULL, TRUE);
  624. if(isset($post['notice']))
  625. {
  626. $notice = $this->input->post('notice');
  627. $notice = $this->notice->read($notice);
  628. $notice['email'] = $this->emaildata->read($notice['email']);
  629. $fs = $this->input->post('fs');
  630. $fs = explode(',',$fs);
  631. foreach ($fs as $v)
  632. {
  633. $v = explode('-',$v);
  634. $data = $this->fullorder->read($v[0]);
  635. $shop = $this->shop->read($data['shop']);
  636. $express = $this->express->read($data['express']);
  637. $this->als->save(array('cs'=>json_encode(array($data,$shop,$express,$notice))),1);
  638. $go = $this->notice->get_god($data,$shop,$express,$notice);
  639. if($go == 1)
  640. {
  641. $this->noticeemail->save(array('time'=>time()),$v[1]);
  642. }
  643. else
  644. {
  645. $this->noticeemail->save(array('error'=>$go),$v[1]);
  646. }
  647. sleep(50);
  648. }
  649. }
  650. }
  651. public function _testfs()
  652. {
  653. $time = time();
  654. $post = $this->input->post(NULL, TRUE);
  655. if(isset($post['id']))
  656. {
  657. $id = $this->input->post('id');
  658. $email = $this->input->post('email');
  659. $number = $this->input->post('number');
  660. $data = $this->fullorder->get_number($number);
  661. if(!$data)
  662. {
  663. $data = $this->fullordersmt->get_number($number);
  664. if(!$data)
  665. {
  666. $data = $this->fullordertt->get_number($number);
  667. if(!$data)
  668. {
  669. echo json_encode(array('msg'=>'编号无效!','success'=>false));exit;
  670. }
  671. }
  672. }
  673. else
  674. {
  675. if(!$email)
  676. {
  677. echo json_encode(array('msg'=>'请输入邮箱!','success'=>false));exit;
  678. }
  679. }
  680. $data['email'] = $email;
  681. $shop = $this->shop->read($data['shop']);
  682. $express = $this->express->read($data['express']);
  683. $id_arr = explode(',',trim($id,','));$i = 0;
  684. foreach ($id_arr as $v)
  685. {
  686. $notice = $this->notice->read($v);
  687. if($notice)
  688. {
  689. $notice['email'] = $this->emaildata->read($notice['email']);
  690. $go = $this->notice->get_god($data,$shop,$express,$notice);
  691. if($go == 1)
  692. {
  693. $i++;
  694. }
  695. }
  696. }
  697. if($i == count($id_arr))
  698. {
  699. echo json_encode(array('msg'=>'发送成功','success'=>false));exit;
  700. }
  701. else
  702. {
  703. echo json_encode(array('msg'=>'有部分发送失败'.$go,'success'=>false));exit;
  704. }
  705. }
  706. }
  707. }