Authored by 周少峰

modify yohocoin

... ... @@ -194,9 +194,10 @@ class UserData
* @param int $uid 用户ID
* @param int $page 第几页,默认1
* @param int $limit 限制读取的数目,默认10
* @param string $type 请求类型 get,post
* @return array YOHO币接口返回的数据
*/
public static function yohoCoinData($uid, $page = 1, $limit = 10)
public static function yohoCoinData($uid, $page = 1, $limit = 10,$type = 'get')
{
$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.lists';
... ... @@ -205,7 +206,7 @@ class UserData
$param['limit'] = $limit;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::$type(Yohobuy::API_URL, $param);
}
/**
... ...
... ... @@ -827,8 +827,11 @@ class HomeController extends AbstractAction
{
$this->setTitle('YOHO币');
$this->setNavHeader('YOHO币', true, false);
$uid = $this->getUid();
$page = $this->get('page', 1);
$size = $this->get('size', 10);
//$currency = UserModel::getYohoCoinLists($this->_uid,$page,$size);
$currency = UserModel::getYohoCoinLists(3965746,$page,$size);
print_r($currency);exit;
$currency = array(
array(
'title' => '购买商品 Nike XXXXXX 运动鞋',
... ...
... ... @@ -354,6 +354,34 @@ class UserModel
}
/**
* 处理YOHO币变化履历数据
*
* @param int $uid 用户ID
* @param int $page 当前页
* @param int $limit 一页记录数
* @return array|mixed 处理之后的YOHO币数据
*/
public static function getYohoCoinLists($uid, $page, $limit)
{
$result = array();
// 调用接口获取YOHO币
$yohoCoin = UserData::yohoCoinData($uid, $page, $limit, 'post');
// 处理YOHO币数据
$coinList = $yohoCoin['data']['coinlist'];
$result['many'] = $yohoCoin['data']['total'];
foreach($coinList as $key => $val){
$result[$key]['title'] = $val['message'];
$result[$key]['time'] = $val['date'];
if($val['num'] > 0){
$val['num'] = '+'.$val['num'];
}
$result[$key]['count'] = $val['num'];
}
return $result;
}
/**
* 处理优惠券数据
*
* @param int $uid 用户ID
... ...