RegiveController.class.php 1.18 KB
<?php
/**
 * 【销售活动-后台】管理员补发红包接口
 *
 * author daijun
 */

namespace Apicp\Controller\Red;

use Common\Service\PacketrecordService;

class RegiveController extends \Apicp\Controller\AbstractController
{

    /**
     * 接收参数
     * red_id int 必填 红包ID
     *
     * @return bool
     */
    public function Index_post()
    {

        $red_id = I('post.red_id', 0, 'intval');
        if (empty($red_id)) {
            // 验证数据
            E('_EMPTY_RED_ID');
        }

        // 实例化用户红包记录表
        $packet_records = new PacketrecordService();
        // 查询红包记录
        $record_info = $packet_records->get($red_id);

        if (empty($record_info)) {
            // 如果记录为空
            E('_ERR_PACKET_RECORD_DATA');
        }

        if ($record_info['packet_status'] != PacketrecordService::PACKET_STATUS_FAIL) {
            // 如果原红包记录的领取状态不是失败状态
            E('_ERR_PACKET_STATUS');
        }

        // 补发新的红包关联为旧红包的子红包,并推送消息
        $packet_records->regive_red($record_info, $this->_login->user);

        return true;
    }
}