PrizeConvertListController.class.php
1.74 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
<?php
/**
* Created by IntelliJ IDEA.
* 微信端我的奖品兑换记录列表
* User: zs_anything
* Date: 2016/12/07
* Time: 上午14:27
*/
namespace Api\Controller\Mall;
use Common\Service\ConvertService;
use Common\Common\Attach;
class PrizeConvertListController extends AbstractController
{
public function Index()
{
$page = I('post.page', 1);
$limit = I('post.limit', 20);
list($start, $limit, $page) = page_limit($page, $limit);
$loginUserInfo = $this->_login->user;
$params = array(
'memUid' => $loginUserInfo['memUid'],
);
$convertService = new ConvertService();
$total = $convertService->countWxPrizeConvert($params);
$data = $convertService->getWxPrizeConvertPageList($params, array($start, $limit), array('created' => 'DESC'));
$this->formatAttrUrl($data);
$this->_result = [
'list' => $data,
'page' => $page,
'total' => $total
];
return true;
}
/**
* 封装奖品图片url
* @param $data
* @return mixed
*/
private function formatAttrUrl(&$data)
{
$attIdArr = [];
foreach ($data as &$item) {
$item['picture'] = explode(',', $item['picture']);
$item['picture'] = $item['picture'][0];
$attIdArr[] = $item['picture'];
}
$attachUtil = new Attach();
$attArr = $attachUtil->listAttachUrl($attIdArr);
foreach ($data as &$item) {
if (isset($attArr[$item['picture']])) {
$item['picture'] = $attArr[$item['picture']]['atAttachment'];
} else {
$item['picture'] = '';
}
}
return $data;
}
}