<?php /** * 【销售活动-后台】活动参与提醒接口 * * User: WJY * Date: 2017-11-06 */ namespace Apicp\Controller\Activity; use Common\Common\Helper; use Common\Service\ActivityService; use Common\Service\CommentService; class RemindController extends \Apicp\Controller\AbstractController { /** @var ActivityService */ protected $activity_s; /** @var CommentService */ protected $comment_s; public function before_action($action = '') { if (!parent::before_action($action)) { return false; } // 实例化活动信息表 $this->activity_s = new ActivityService(); // 实例化评论表 $this->comment_s = new CommentService(); return true; } public function Index_post() { $params = I('post.'); $this->remind_activity($params); return true; } protected function remind_activity($param = []) { // 不合理性排除 if (empty($param['ac_id'])) { E('_ERR_REMIND'); } $activity = $this->activity_s->get($param['ac_id']); // 获取活动状态 1:草稿,2:未开始,3:进行中,4:已结束,5:已终止 $status = $this->activity_s->activity_status($activity['activity_status'], $activity['begin_time'], $activity['end_time']); if (!in_array($status, [Helper::STATUS_NOT_START, Helper::STATUS_ING])) { // 如果不是未开始和进行中的活动,则不能提醒 E('_ERR_ACTIVITY_REMIND_STATUS'); } // 如果是个人通知 if (!empty($param['memId'])) { $params = [ 'uids' => $param['memId'], 'ac_id' => $param['ac_id'], 'subject' => $activity['subject'], 'begin_time' => $activity['begin_time'], 'end_time' => $activity['end_time'], 'content' => unserialize($activity['content']), ]; // 发送消息 $this->activity_s->send_msg($params, ActivityService::MSG_REMAIND_NO_JOIN_USERS); } // 如果是全部未参与通知 if (empty($param['memId'])) { // 获取参与列表 $joinlist = $this->comment_s->list_join(['ac_id' => $param['ac_id']]); // 获取未参与列表 $unjoinlist = $this->comment_s->count_unjoin(['ac_id' => $param['ac_id']], $joinlist); $params = [ 'uids' => $unjoinlist['unjoin_uids'], 'ac_id' => $param['ac_id'], 'subject' => $activity['subject'], 'begin_time' => $activity['begin_time'], 'end_time' => $activity['end_time'], 'content' => unserialize($activity['content']), ]; // 发送消息 $this->activity_s->send_msg($params, ActivityService::MSG_REMAIND_NO_JOIN_USERS); } return true; } }