Index.php
3.59 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
<?php
namespace Home;
use Home\UserModel;
use LibModels\Web\Home\UserData;
use LibModels\Web\Product\BrandData;
use WebPlugin\Helpers;
use WebPlugin\HelperHome;
use WebPlugin\Images;
use Api\Yohobuy;
use LibModels\Web\Home\IndexData;
use LibModels\Web\Product\SearchData;
/**
* 个人中心-首页相关业务逻辑处理
*/
class IndexModel
{
/**
* 个人中心——消息提示
* @param type $uid
* @param type $udid
* @return array
*/
public static function getInfoNumData($uid, $udid)
{
$result = array(
array('href' => Helpers::url('/home/orders'), 'name' => '待处理订单', 'count' => 0),
array('href' => Helpers::url('/home/message'), 'name' => '未读消息', 'count' => 0),
array('href' => Helpers::url('/home/comment'), 'name' => '待评论商品', 'count' => 0),
);
$getPendingOrderCount = IndexData::getPendingOrderCount($uid); //待处理订单
$infoNumData = IndexData::infoNum($uid, $udid); //未读消息
$notCommentRecordCount = IndexData::notCommentRecordCount($uid); //待评论商品
$result[0]['count'] = isset($getPendingOrderCount['data']['count']) ? $getPendingOrderCount['data']['count'] : 0;
$result[1]['count'] = isset($infoNumData['data']['inbox_total']) ? $infoNumData['data']['inbox_total'] : 0;
$result[2]['count'] = isset($notCommentRecordCount['data']) ? $notCommentRecordCount['data'] : 0;
return $result;
}
/**
* 个人中心——最新订单
* @param type $uid
* @return array
*/
public static function latestOrders($uid)
{
$orders = OrderModel::getOrders($uid, 1, 2, 1);
$result = array('more' => Helpers::url('/home/orders'), 'orders' => $orders);
return $result;
}
/**
* 获取个人中心数据(猜你喜欢的品牌、新品上架)
* @return array
*/
public static function homeData()
{
$result = array();
//猜你喜欢的品牌
$url['fav_brand'] = SearchData::getBrandListUrl();
//新品上架
$productParam['new'] = 'Y';
$productParam['viewNum'] = 10;
$url['new'] = SearchData::getProductUrl($productParam);
//调用接口数据
$data = Yohobuy::getMulti($url);
//格式化数据
$result['brand'] = isset($data['fav_brand']) && !empty($data['fav_brand']) ? HelperHome::formatFavBrand($data['fav_brand'], 6) : array();
$result['new'] = isset($data['new']['product_list']) && !empty($data['new']['product_list']) ? HelperHome::formatNew($data['new']['product_list']) : array();
return $result;
}
/**
* @param $channel
* @param $uid
* @param $udid
* @param $recPos
* @param $limit
* @return array
*/
public static function preferenceData($channel, $uid, $udid, $recPos, $limit)
{
$response = UserData::newPreference($channel, $uid, $udid, $recPos, $limit);
if ($response['code'] === 200) {
return HelperHome::formatNew($response['data']['product_list']);
} else {
return array();
}
}
/**
* 底部banner
* @param string $code
* @return mixed
*/
public static function getFooterBanner($code = '20110609-152143')
{
$banner = BrandData::getByNodeContent($code);
if (isset($banner['code']) && !empty($banner['data'])) {
return strtr($banner['data'], array('http://' => '//'));
}
}
}