mass.inc.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * [WeEngine System] Copyright (c) 2014 WE7.CC
  4. * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
  5. */
  6. defined('IN_IA') or exit('Access Denied');
  7. global $_W, $_GPC;
  8. $id = intval($_W['cron']['extra']);
  9. $data = table('mc_mass_record')->where(array('uniacid' => $_W['uniacid'], 'id' => $id))->get();
  10. if (empty($data)) {
  11. $this->addCronLog($id, -1100, '未找到群发的设置信息');
  12. }
  13. $acc = WeAccount::createByUniacid();
  14. if (is_error($acc)) {
  15. $this->addCronLog($id, -1101, '创建公众号操作对象失败');
  16. }
  17. if ($data['msgtype'] == 'basic') {
  18. $data['media_id'] = urlencode(emoji_unicode_decode($data['content']));
  19. }
  20. $status = $acc->fansSendAll($data['group'], $data['msgtype'], $data['media_id']);
  21. if (is_error($status)) {
  22. table('mc_mass_record')
  23. ->where(array(
  24. 'uniacid' => $_W['uniacid'],
  25. 'id' => $id
  26. ))
  27. ->fill(array(
  28. 'status' => 2,
  29. 'finalsendtime' => TIMESTAMP
  30. ))
  31. ->save();
  32. $this->addCronLog($id, -1102, $status['message']);
  33. }
  34. table('mc_mass_record')
  35. ->where(array(
  36. 'uniacid' => $_W['uniacid'],
  37. 'id' => $id
  38. ))
  39. ->fill(array(
  40. 'status' => 0,
  41. 'finalsendtime' => TIMESTAMP
  42. ))
  43. ->save();
  44. table('core_cron')->where(array('uniacid' => $_W['uniacid'], 'id' => $_W['cron']['id']))->delete();
  45. $this->addCronLog($id, 0, 'success');