ActivityData.php
4.77 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
namespace LibModels\Wap\Cuxiao;
use Api\Sign;
use Api\Yohobuy;
/**
* 活动的数据模型
*
* @name ActivityData
* @package LibModels/Wap/Cuxiao
* @copyright yoho.inc
* @version 1.0 (2015-11-25 19:10:52)
* @author fei.hong <fei.hong@yoho.cn>
*/
class ActivityData
{
const URI_GET_ACTIVITY_INFO = 'event/api/v1/activity/get';
const URI_GET_NAMED_COUPON = 'event/api/v1/activity/getCoupon';
const URI_GET_ALL_COUPON = 'event/api/v1/activity/getCoupon';
const URI_SEND_MESSAGE = 'inbox/service/v1/inbox';
const URI_YUANXIAO_CHOUQIAN = 'union/ActivityRest/draw';
const URI_YUANXIAO_CHOUQIAN_SHARE = 'union/ActivityRest/getDrawInfo';
const URL_YUANXIAO_API = 'http://union.yoho.cn/';
/**
* 用户获取某个活动指定的单个优惠券
*
* @param int $uid 用户ID
* @param int $activityId 活动ID
* @param int $couponId 优惠券ID
* @return array
*/
public static function getCouponNamed($uid, $activityId, $couponId)
{
$param = array();
$param = Yohobuy::param();
$param['method'] = 'app.activity.getCoupon';
$param['uid'] = $uid;
$param['activity_id'] = $activityId;
$param['coupon_id'] = $couponId;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
/**
* 用户获取某个活动所有的优惠券操作
*
* @param int $uid 用户ID
* @param int $activityId 活动ID
* @return array
*/
public static function getCouponAll($uid, $activityId)
{
$param = array();
$param['uid'] = $uid;
$param['activity_id'] = $activityId;
return Yohobuy::get(SERVICE_URL . self::URI_GET_ALL_COUPON, $param);
}
/**
* 获取活动信息
*
* @param int $activityId 活动ID
* @return array
*/
public static function getActivityInfo($activityId)
{
$param = array('activity_id' => $activityId);
return Yohobuy::get(SERVICE_URL . self::URI_GET_ACTIVITY_INFO, $param, 3600); // 有缓存1小时
}
/**
* 获取元宵抽签的结果
*
* @param int $uid 用户UID
* @param string $nickName 用户昵称
* @param string $birthday 用户生日
* @param int $gender 用户性别
* @return mixed 抽签的结果
*/
public static function getYuanxiaoInfo($uid, $nickName, $birthday, $gender)
{
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
$param['nickname'] = $nickName;
$param['birthday'] = $birthday;
$param['gender'] = $gender;
return Yohobuy::jsonPost(self::URL_YUANXIAO_API . self::URI_YUANXIAO_CHOUQIAN, $param);
}
/**
* 获取分享结果页元宵抽签的结果
*
* @param int $uid 用户UID
* @return mixed 抽签的结果
*/
public static function getYuanxiaoShareInfo($uid)
{
$param = array();
$param['method'] = 'wap.activity.draw';
$param['uid'] = $uid;
return Yohobuy::jsonPost(self::URL_YUANXIAO_API . self::URI_YUANXIAO_CHOUQIAN_SHARE, $param);
}
/**
* 发送站内信
*
* @param int $uid
* @param string $title
* @param int $content
* @param int $type
* @param string $verify_key
* @param int $send_uid
* @param string $call_back
* @return array
*/
// public static function message($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '')
// {
// //调用接口发送站内信
// return Yohobuy::yarClient(SERVICE_URL . self::URI_SEND_MESSAGE, 'setSingleMessage', array(
// $uid, $title, $content, $type, $verify_key, $send_uid, $call_back
// ));
// }
public static function message($uid, $title, $content, $type = 1, $verify_key = '', $send_uid = 0, $call_back = '')
{
$param = array();
$param = Yohobuy::param();
$param['method'] = 'web.inbox.setSingleMessage';
$param['uid'] = $uid;
$param['send_uid'] = $send_uid;
$param['verify_key'] = $verify_key;
$param['content'] = $content;
$param['title'] = $title;
$param['type'] = $type;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(API_URL, $param);
}
/**
* 发放优惠券
*
* @param int $uid 用户ID
* @param string $token 发券标记
* @return mixed
*/
public static function couponSend($uid, $token)
{
$param = Yohobuy::param();
$param['method'] = 'app.coupons.couponSend';
$param['uid'] = $uid;
$param['coupon_send_token'] = $token;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(API_URL, $param);
}
}