Browse Source

商品评价

master
林一峰 7 years ago
parent
commit
8edc331577
  1. 5
      app/Http/Controllers/Api/CommentController.php
  2. 2
      app/Http/Model/Comment.php
  3. 86
      app/Http/Model/UserWithdraw.php
  4. 20
      composer.lock

5
app/Http/Controllers/Api/CommentController.php

@ -5,6 +5,7 @@ use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Token;
use App\Common\Helper;
use App\Http\Model\Comment;
class CommentController extends CommonController
@ -46,6 +47,7 @@ class CommentController extends CommonController
if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
$data['ip_address'] = Helper::getRemoteIp();
if($data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null)
{
@ -75,8 +77,9 @@ class CommentController extends CommonController
if($request->input('parent_id', null) !== null){$data['parent_id'] = $request->input('parent_id');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
$data['ip_address'] = Helper::getRemoteIp();
if($id===null || $data['comment_type']===null || $data['id_value']===null || $data['content']===null || $data['comment_rank']===null)
if($id===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}

2
app/Http/Model/Comment.php

@ -24,7 +24,7 @@ class Comment extends BaseModel
{
extract($param); //参数:limit,offset
$where['user_id'] = Token::$uid;
$where['user_id'] = $user_id;
$where['comment_type'] = $comment_type; //0商品评价,1文章评价
$where['status'] = self::SHOW_COMMENT;

86
app/Http/Model/UserWithdraw.php

@ -0,0 +1,86 @@
<?php
namespace App\Http\Model;
use App\Common\Token;
use DB;
class UserWithdraw extends BaseModel
{
//用户余额明细
protected $table = 'user_withdraw';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$where['user_id'] = Token::$uid;
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new UserWithdraw;
if(isset($type)){$where['type'] = $type;}
$model = $model->where($where);
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get()->toArray();
}
else
{
return false;
}
return $res;
}
public static function getOne($id)
{
return self::where('id', $id)->first()->toArray();
}
public static function add(array $data)
{
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
}
}

20
composer.lock

@ -1332,16 +1332,16 @@
},
{
"name": "overtrue/socialite",
"version": "1.2.0",
"version": "1.3.0",
"source": {
"type": "git",
"url": "https://github.com/overtrue/socialite.git",
"reference": "0b943f2b2063c8c4f1672b4d2f4451e57d7415a7"
"reference": "fda55f0acef43a144799b1957a8f93d9f5deffce"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/overtrue/socialite/0b943f2b2063c8c4f1672b4d2f4451e57d7415a7.zip",
"reference": "0b943f2b2063c8c4f1672b4d2f4451e57d7415a7",
"url": "https://files.phpcomposer.com/files/overtrue/socialite/fda55f0acef43a144799b1957a8f93d9f5deffce.zip",
"reference": "fda55f0acef43a144799b1957a8f93d9f5deffce",
"shasum": ""
},
"require": {
@ -1378,7 +1378,7 @@
"wechat",
"weibo"
],
"time": "2017-07-27T08:22:56+00:00"
"time": "2017-08-04T06:28:22+00:00"
},
{
"name": "overtrue/wechat",
@ -3324,16 +3324,16 @@
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "3.2.1",
"version": "3.2.2",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "183824db76118b9dddffc7e522b91fa175f75119"
"reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157"
},
"dist": {
"type": "zip",
"url": "https://files.phpcomposer.com/files/phpDocumentor/ReflectionDocBlock/183824db76118b9dddffc7e522b91fa175f75119.zip",
"reference": "183824db76118b9dddffc7e522b91fa175f75119",
"url": "https://files.phpcomposer.com/files/phpDocumentor/ReflectionDocBlock/4aada1f93c72c35e22fb1383b47fee43b8f1d157.zip",
"reference": "4aada1f93c72c35e22fb1383b47fee43b8f1d157",
"shasum": ""
},
"require": {
@ -3365,7 +3365,7 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-08-04T20:55:59+00:00"
"time": "2017-08-08T06:39:58+00:00"
},
{
"name": "phpdocumentor/type-resolver",

Loading…
Cancel
Save