Notice.php 21 KB

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