Browse Source

修改排行榜输出接口和排行榜统计方法

master
tanghuijun 4 years ago
parent
commit
4d6bf2dcac
  1. 17
      app/api/controller/Goods.php

17
app/api/controller/Goods.php

@ -52,14 +52,9 @@ class Goods extends Base
*/
public function getTypeGoods(){
try {
// todo 被请求首页排行榜 接口
// $this->checkVaild($this->valid, 'getTypeGoods', 'post');
// $goods_type = $this->request->post('goods_type');
// $type = $this->request->post('type');
$createtime = $this->request->post('createtime');
$goodsService = new GoodsService();
$result = $goodsService->getTypeGoods('1', $createtime);
return _success('成功', $result);
$params = ['type'=> 1];
$result = $this->curl_request_post('http://www.wenhuayun.com/index.php/api/goods/getTypeGoods', $params);
return $result;
}catch(\Exception $e){
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
@ -100,20 +95,16 @@ class Goods extends Base
*/
public function incrRanking()
{
$params = input('get.');
$params = $this->request->post('id');
if (empty($params['id'])){
return _error('params error');
}
Db::startTrans();
try {
$goods = \app\model\Goods::find($params['id']);
$this->curl_request_post('http://www.wenhuayun.com/index.php/api/goods/incrRanking', $params);
$goods->recommend_sort = $goods['recommend_sort']+1;
$goods->save();
Db::commit();
return _success('成功');
}catch (\Exception $e){
Db::rollback();
return _error('失败');
}
}

Loading…
Cancel
Save