RedEnterpriseController.class.php
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* 【业绩比拼-手机端】获取活动企业信息
* RedEnterpriseController.class.php
*
* User: daijun
* Date: 2017-11-03
*/
namespace Api\Controller\Red;
use Common\Service\PacketrecordService;
use Common\Service\ActivityService;
use VcySDK\Enterprise;
class RedEnterpriseController extends \Api\Controller\AbstractController
{
public function Index_get()
{
// 红包ID
$rid = I('get.rid', 0, 'intval');
$ac_id = I('get.ac_id', 0, 'intval');
if (empty($this->uid)) {
// 判断是否外部人员
E('_EMPTY_USER_ID');
}
if (empty($ac_id)) {
// 如果活动id为空
E('_EMPTY_ACTIVITY_ID');
}
if (empty($rid)) {
// 数据验证
E('_EMPTY_RED_RECORD_ID');
}
$activity_serv = new ActivityService();
$info = $activity_serv->get($ac_id);
if (empty($info)) {
// 活动被删除
E('_ERR_DATA_NOT_EXIST');
}
// 验证红包支付终止开关状态
$this->get_activity_pay_status($ac_id);
// 实例化红包记录表
$record_service = new PacketrecordService();
// 红包记录详情
$detail = $record_service->get_by_conds([
'rid' => $rid, // 红包记录id
'uid' => $this->uid, // 用户uid
'packet_status' => PacketrecordService::PACKET_STATUS_WAIT // 红包状态:遇领取
]);
if (empty($detail)) {
// 红包记录不存在
E('_ERR_RED_RECORD_DATA');
}
// 获取企业名称与logo
$enterpriseSDK = new Enterprise(\VcySDK\Service::instance());
// 获取企业详情
$ep_detail = $enterpriseSDK->detail();
$this->_result = [
'ep_name' => $ep_detail['epName'],
'ep_logo' => $ep_detail['corpSquareLogo'],
'packet_bless' => empty($info['packet_bless']) ? '' : $info['packet_bless']
];
return true;
}
}