Browse Source

添加了排行榜递增方法

master
tanghuijun 4 years ago
parent
commit
77be5f301e
  1. 23
      app/api/controller/Goods.php

23
app/api/controller/Goods.php

@ -5,6 +5,7 @@ namespace app\api\controller;
use app\Request;
use app\service\Goods\GoodsService;
use think\cache\driver\Redis;
use think\facade\Db;
class Goods extends Base
{
@ -94,6 +95,28 @@ class Goods extends Base
return _error($e->getMessage(), $e->getCode() ?: 400, $e);
}
}
/**
* 排行榜递增
*/
public function incrRanking()
{
$params = input('get.');
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('失败');
}
}
public function test(){

Loading…
Cancel
Save