<?php /** * 【积分抽奖-手机端】添加中奖信息 * * @author: heyuelong * @date: 2018年3月26日11:18:07 */ namespace Api\Controller\Activity; use Common\Common\Constant; use Common\Service\ActivityService; use Common\Service\RecordService; class AddRemarkController extends \Api\Controller\AbstractController { /** @var ActivityService */ protected $_activity_service; /** @var RecordService */ protected $_record_service; public function before_action($action = '') { if (!parent::before_action($action)) { return false; } // 实例化活动表 $this->_activity_service = new ActivityService(); // 实例化活动奖品记录表 $this->_record_service = new RecordService(); return true; } /** * @return bool */ public function Index_post() { $params = I('post.'); // 获取参数 $lr_id = $params['lr_id'] ? intval($params['lr_id']) : 0; if (empty($lr_id)) { // 验证参数 E('_EMPTY_ACTIVITY_LR_ID'); } // 获取活动详细内容 $info = $this->_record_service->get_by_conds( [ 'lr_id' => $lr_id, 'uid' => $this->uid ] ); if (empty($info)) { // 如果没有数据 E('_ERR_DATA_NOT_AUTH'); } // 获取活动详细内容 $activity_info = $this->_activity_service->get_by_conds( [ 'ac_id' => $info['ac_id'], 'activity_status > ?' => 0 ] ); // 如果活动不存在 if (empty($activity_info)) { // 数据不存在时抛错 E('_ERR_DATA_NOT_EXIST'); } // 订单已发货 if (Constant::SEND_GOODS_STATUS_TRUE == $info['lr_status']) { E('_ERR_SEND_GOODS_STATUS'); } // 更新数据 $this->_record_service->update($lr_id, $params); $this->_result = []; return true; } }