commit | author | age
|
19351a
|
1 |
<?php |
B |
2 |
|
|
3 |
/** |
|
4 |
* UCenter 函数库 |
|
5 |
*/ |
|
6 |
|
|
7 |
|
|
8 |
/** |
|
9 |
* 通过判断is_feed 向UCenter提交Feed |
|
10 |
* |
|
11 |
* @access public |
|
12 |
* @param integer $value_id $order_id or $comment_id |
|
13 |
* @param interger $feed_type BUY_GOODS or COMMENT_GOODS |
|
14 |
* |
|
15 |
* @return void |
|
16 |
*/ |
|
17 |
function add_feed($id, $feed_type) |
|
18 |
{ |
|
19 |
$feed = array(); |
|
20 |
if ($feed_type == BUY_GOODS) |
|
21 |
{ |
|
22 |
if (empty($id)) |
|
23 |
{ |
|
24 |
return; |
|
25 |
} |
|
26 |
$id = intval($id); |
|
27 |
$order_res = $GLOBALS['db']->getAll("SELECT g.goods_id, g.goods_name, g.goods_sn, g.goods_desc, g.goods_thumb, o.goods_price FROM " . $GLOBALS['ecs']->table('order_goods') . " AS o, " . $GLOBALS['ecs']->table('goods') . " AS g WHERE o.order_id='{$id}' AND o.goods_id=g.goods_id"); |
|
28 |
foreach($order_res as $goods_data) |
|
29 |
{ |
|
30 |
if(!empty($goods_data['goods_thumb'])) |
|
31 |
{ |
|
32 |
$url = $GLOBALS['ecs']->url() . $goods_data['goods_thumb']; |
|
33 |
} |
|
34 |
else |
|
35 |
{ |
|
36 |
$url = $GLOBALS['ecs']->url() . $GLOBALS['_CFG']['no_picture']; |
|
37 |
} |
|
38 |
$link = $GLOBALS['ecs']->url() . "goods.php?id=" . $goods_data["goods_id"]; |
|
39 |
|
|
40 |
$feed['icon'] = "goods"; |
|
41 |
$feed['title_template'] = '<b>{username} ' . $GLOBALS['_LANG']['feed_user_buy'] . ' {goods_name}</b>'; |
|
42 |
$feed['title_data'] = array('username'=> $_SESSION['user_name'], 'goods_name'=> $goods_data['goods_name']); |
|
43 |
$feed['body_template'] = '{goods_name} ' . $GLOBALS['_LANG']['feed_goods_price'] . ':{goods_price} ' . $GLOBALS['_LANG']['feed_goods_desc'] . ':{goods_desc}'; |
|
44 |
$feed['body_data'] = array('goods_name'=>$goods_data['goods_name'], 'goods_price'=>$goods_data['goods_price'], 'goods_desc'=>sub_str(strip_tags($goods_data['goods_desc']), 150, true)); |
|
45 |
$feed['images'][] = array('url'=> $url, |
|
46 |
'link'=> $link); |
|
47 |
uc_call("uc_feed_add", array($feed['icon'], $_SESSION['user_id'], $_SESSION['user_name'], $feed['title_template'], $feed['title_data'], $feed ['body_template'], $feed['body_data'], '', '', $feed['images'])); |
|
48 |
} |
|
49 |
} |
|
50 |
return; |
|
51 |
} |
|
52 |
|
|
53 |
/** |
|
54 |
* 获得商品tag所关联的其他应用的列表 |
|
55 |
* |
|
56 |
* @param array $attr |
|
57 |
* |
|
58 |
* @return void |
|
59 |
*/ |
|
60 |
function get_linked_tags($tag_data) |
|
61 |
{ |
|
62 |
//取所有应用列表 |
|
63 |
$app_list = uc_call("uc_app_ls"); |
|
64 |
if ($app_list == '') |
|
65 |
{ |
|
66 |
return ''; |
|
67 |
} |
|
68 |
foreach($app_list as $app_key => $app_data) |
|
69 |
{ |
|
70 |
if ($app_data['appid'] == UC_APPID) |
|
71 |
{ |
|
72 |
unset($app_list[$app_key]); |
|
73 |
continue; |
|
74 |
} |
|
75 |
$get_tag_array[$app_data['appid']] = '5'; |
|
76 |
$app_array[$app_data['appid']]['name'] = $app_data['name']; |
|
77 |
$app_array[$app_data['appid']]['type'] = $app_data['type']; |
|
78 |
$app_array[$app_data['appid']]['url'] = $app_data['url']; |
|
79 |
$app_array[$app_data['appid']]['tagtemplates'] = $app_data['tagtemplates']; |
|
80 |
} |
|
81 |
|
|
82 |
$tag_rand_key = array_rand($tag_data); |
|
83 |
$get_tag_data = uc_call("uc_tag_get", array($tag_data[$tag_rand_key], $get_tag_array)); |
|
84 |
foreach($get_tag_data as $appid => $tag_data_array) |
|
85 |
{ |
|
86 |
$templates = $app_array[$appid]['tagtemplates']['template']; |
|
87 |
if (!empty($templates) && !empty($tag_data_array['data'])) |
|
88 |
{ |
|
89 |
foreach($tag_data_array['data'] as $tag_data) |
|
90 |
{ |
|
91 |
$show_data = $templates; |
|
92 |
foreach($tag_data as $tag_key => $data) |
|
93 |
{ |
|
94 |
$show_data = str_replace('{' . $tag_key . '}', $data, $show_data); |
|
95 |
} |
|
96 |
$app_array[$appid]['data'][] = $show_data; |
|
97 |
} |
|
98 |
} |
|
99 |
} |
|
100 |
|
|
101 |
return $app_array; |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* 兑换积分 |
|
106 |
* |
|
107 |
* @param integer $uid 用户ID |
|
108 |
* @param integer $fromcredits 原积分 |
|
109 |
* @param integer $tocredits 目标积分 |
|
110 |
* @param integer $toappid 目标应用ID |
|
111 |
* @param integer $netamount 积分数额 |
|
112 |
* |
|
113 |
* @return boolean |
|
114 |
*/ |
|
115 |
function exchange_points($uid, $fromcredits, $tocredits, $toappid, $netamount) |
|
116 |
{ |
|
117 |
$ucresult = uc_call('uc_credit_exchange_request', array($uid, $fromcredits, $tocredits, $toappid, $netamount)); |
|
118 |
if (!$ucresult) |
|
119 |
{ |
|
120 |
return false; |
|
121 |
} |
|
122 |
else |
|
123 |
{ |
|
124 |
return true; |
|
125 |
} |
|
126 |
} |
|
127 |
|
|
128 |
?> |