<?php /** * 【业绩比拼-手机端】红包详情 * RedInfoController.class.php * * User: daijun * Date: 2017-11-04 */ namespace Api\Controller\Red; use Common\Service\PacketrecordService; use VcySDK\Enterprise; class RedInfoController extends \Api\Controller\AbstractController { public function Index_get() { // 红包记录ID $rid = I('get.rid', 0, 'intval'); if (empty($rid)) { // 数据验证 E('_EMPTY_RED_RECORD_ID'); } if (empty($this->uid)) { // 判断是否外部人员 E('_EMPTY_USER_ID'); } // 实例化红包记录表 $record_service = new PacketrecordService(); // 红包记录详情 $detail = $record_service->get_by_conds([ 'rid' => $rid, // 红包记录id 'uid' => $this->uid, // 用户uid 'packet_status' => PacketrecordService::PACKET_STATUS_SUCCESS // 红包状态:领取成功 ]); if (empty($detail)) { // 红包记录不存在 E('_ERR_RED_RECORD_DATA'); } // 获取企业名称与logo $enterpriseSDK = new Enterprise(\VcySDK\Service::instance()); // 获取企业详情 $ep_detail = $enterpriseSDK->detail(); $result = [ 'red_type' => intval($detail['p_type']), 'username' => strval($detail['username']), 'ep_name' => $ep_detail['epName'], 'ep_logo' => $ep_detail['corpSquareLogo'], 'user_money' => sprintf("%.2f", $detail['rand_money'] / 100), ]; // 如果是随机比例红包类型 if (PacketrecordService::RED_PACKET_RAND == $detail['p_type']) { // 查询当前活动领取成功的红包记录数 $total = $record_service->count_by_conds( [ 'ac_id' => $detail['ac_id'], // 同一个活动 'p_type' => $detail['p_type'], // 相同的红包类型 'packet_status' => PacketrecordService::PACKET_STATUS_SUCCESS // 红包状态:领取成功 ] ); $result['total'] = $total; } else { // 如果是其他红包 $result['total'] = 0; } $this->_result = $result; return true; } }