RedRemindController.class.php 1.81 KB
<?php
/**
 * 【销售活动-后台】红包提醒接口
 *
 * author daijun
 */

namespace Apicp\Controller\Red;

use Common\Service\ActivityService;
use Common\Service\PacketrecordService;

class RedRemindController extends \Apicp\Controller\AbstractController
{

    public function Index_post()
    {

        $red_ids = I('post.red_ids');
        if (empty($red_ids)) {
            // 红包id不能为空
            E('_EMPTY_RED_IDS');
        }

        $records_serv = new PacketrecordService();
        $records_list = $records_serv->list_by_conds([
            'rid' => $red_ids,  // 红包id
            'packet_status' => PacketrecordService::PACKET_STATUS_WAIT, // 待领取
        ]);

        $activity = [];
        if ($records_list) {

            $activity_serv = new ActivityService();
            $activity = $activity_serv->get($records_list[0]['ac_id']);
        }

        foreach ($records_list as $v) {

            if (PacketrecordService::RED_PACKET_RAND == $v['p_type']) {
                // 提醒领取随机红包
                $msg_type = PacketrecordService::MSG_REMAIND_RECEIVE_RANDOM_REDPACKET;
            } elseif ($v['p_type'] == PacketrecordService::RED_PACKET_VIP) {
                // 提醒领取定向红包
                $msg_type = PacketrecordService::MSG_REMAIND_RECEIVE_VIP_REDPACKET;
            } else {

                continue;
            }

            $params = [
                'uids' => $v['uid'],
                'ac_id' => $v['ac_id'],
                'rid' => $v['rid'],
                'comment_id' => $v['comment_id'],
                'subject' => $activity['subject'],
                'rand_money' => $v['rand_money'],
                'give_time' => $v['give_time']
            ];

            $records_serv->send_msg($params, $msg_type);
        }

        return true;
    }
}