...
|
...
|
@@ -550,23 +550,30 @@ class DetailModel |
|
|
/**
|
|
|
* 获取咨询列表
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $productId 产品ID
|
|
|
* @param int $pageNum 页码数
|
|
|
* @param int $pageSize 每页显示个数
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getConsults($productId, $pageNum = 1, $pageSize = 300)
|
|
|
public static function getConsults($uid, $productId, $pageNum = 1, $pageSize = 300)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
|
|
|
$consultList = DetailData::consultList($productId, $pageNum, $pageSize);
|
|
|
if (!empty($consultList)) {
|
|
|
$consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize);
|
|
|
if (isset($consultList['code']) && $consultList['code'] === 200) {
|
|
|
$consultList = $consultList['data']['list'];
|
|
|
$build = array();
|
|
|
foreach ($consultList as $value) {
|
|
|
$build['question'] = $value['ask'];
|
|
|
$build['time'] = $value['askTime'];
|
|
|
$build['time'] = $value['ask_time'];
|
|
|
$build['answer'] = $value['answer'];
|
|
|
$build['id'] = $value['id'];
|
|
|
$build['isLike'] = $value['is_like'] === 'Y';
|
|
|
$build['like'] = $value['like'];
|
|
|
$build['isUseful'] = $value['is_useful'] === 'Y';
|
|
|
$build['useful'] = $value['useful'];
|
|
|
$result[] = $build;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -577,6 +584,70 @@ class DetailModel |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 咨询点赞
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $id 咨询ID
|
|
|
* @param int $productId 商品ID
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function upvoteConsult($uid, $id, $productId)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
do {
|
|
|
$record = DetailData::upvoteConsult($uid, $id);
|
|
|
|
|
|
if (empty($uid)) {
|
|
|
$result['code'] = 401;
|
|
|
$result['message'] = '用户id为空';
|
|
|
$result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consultform', array('product_id' => $productId))));
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 处理数据
|
|
|
if ($record && isset($record['code'])) {
|
|
|
$result['code'] = $record['code'];
|
|
|
$result['message'] = $record['message'];
|
|
|
}
|
|
|
}while(false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 咨询有用
|
|
|
*
|
|
|
* @param int $uid 用户ID
|
|
|
* @param int $id 咨询ID
|
|
|
* @param int $productId 商品ID
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function usefulConsult($uid, $id, $productId)
|
|
|
{
|
|
|
$result = array('code' => 400, 'message' => '出错啦~');
|
|
|
|
|
|
do {
|
|
|
$record = DetailData::usefulConsult($uid, $id);
|
|
|
|
|
|
if (empty($uid)) {
|
|
|
$result['code'] = 401;
|
|
|
$result['message'] = '用户id为空';
|
|
|
$result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consultform', array('product_id' => $productId))));
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
// 处理数据
|
|
|
if ($record && isset($record['code'])) {
|
|
|
$result['code'] = $record['code'];
|
|
|
$result['message'] = $record['message'];
|
|
|
}
|
|
|
}while(false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取为你优选的商品
|
|
|
*
|
|
|
* @param int $productSkn 商品SKN
|
...
|
...
|
|