Browse Source

支付

master
jianglong 3 years ago
parent
commit
1ec822948f
  1. 12
      app/api/controller/Resource.php
  2. 29
      app/api/logic/ResourceLogic.php

12
app/api/controller/Resource.php

@ -47,4 +47,16 @@ class Resource extends Api
$detail = ResourceLogic::detail($id,$this->user_id);
return JsonServer::success('获取成功', $detail);
}
/**
* @Notes: 文章详细
* @Author: 张无忌
*/
public function downloadLog()
{
$id = $this->request->get('id');
$detail = ResourceLogic::downloadLog($id,$this->user_id);
return JsonServer::success('获取成功', ["data"=>$detail]);
}
}

29
app/api/logic/ResourceLogic.php

@ -161,6 +161,7 @@ class ResourceLogic extends Logic
}
$article['goodsType'] = $goodsType;
$article['path'] = $article['path']?UrlServer::getFileUrl($article['path']):'';
$article['address'] = $article['province_id']?AreaServer::getAddress([
$article['province_id'],
@ -171,4 +172,32 @@ class ResourceLogic extends Logic
return $article;
}
/**
* @Notes: 文章详细
* @Author: 张无忌
* @param $id
* @return int
*/
public static function downloadLog($id,$uid)
{
$article = Resource::field('*')->where('id', $id)->findOrEmpty();
if($article->isEmpty()) {
return 0;
}else{
$article->download = $article->download + 1;
$article->save();
//下载记录
$userResource = [];
$userResource['user_id'] = $uid;
$userResource['resource_id'] = $id;
$userResource['type'] = 0;
$userResource['create_time'] = time();
$userResourceModel = new UserResource();
$userResourceModel->insert($userResource);
return 1;
}
}
}
Loading…
Cancel
Save