SendChannelMsgService.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Elton
  5. * Date: 2020/3/17
  6. * Time: 9:28
  7. */
  8. namespace app\common\service;
  9. use think\Db;
  10. class SendChannelMsgService
  11. {
  12. /**
  13. * @var SendChannelMsgService
  14. */
  15. private static $self;
  16. /**
  17. * @return SendChannelMsgService
  18. */
  19. public static function instance()
  20. {
  21. if(self::$self == NULL){
  22. self::$self = new self();
  23. }
  24. return self::$self;
  25. }
  26. /**
  27. * @param $wx_msg_id 群发的消息ID
  28. * @param $sentcount 发送成功的粉丝数
  29. * @param $channel_id 渠道ID
  30. */
  31. public function saveSuccessCount($wx_msg_id, $sentcount, $channel_id)
  32. {
  33. LogService::info('[ SendChannelMsgService ] [ saveSuccessCount ] wx_msg_id:' . $wx_msg_id . 'sentcount:' . $sentcount . ', Channel_id:' . $channel_id);
  34. try{
  35. $rst = Db::name('send_channel_message')->where('wx_msg_id', $wx_msg_id)->where('channel_id', $channel_id)->update(['success_count' => $sentcount]);
  36. if(!$rst){
  37. LogService::info('[ SendChannelMsgService ] [ saveSuccessCount ] [ fail ] [ wx_msg_id ] ' . $wx_msg_id);
  38. }
  39. }catch (\Exception $exception){
  40. LogService::error('[ SendChannelMsgService ] [ saveSuccessCount ] ' . $exception->getMessage());
  41. }
  42. }
  43. }