产品
This commit is contained in:
@@ -3,6 +3,7 @@ namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\PostCategory;
|
||||
use app\common\model\SkuAttribute;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\SkuService;
|
||||
@@ -48,8 +49,12 @@ class SkuController extends BaseController
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (isset($data['spec_json']))
|
||||
if (isset($data['spec_json'])){
|
||||
$data['spec'] = json_decode($data['spec_json'], true);
|
||||
foreach ($data['spec'] as $k=>$v){
|
||||
$data['spec'][$k]['attr_type'] = SkuAttribute::where('id', $v['attr_id'])->value('attr_type');
|
||||
}
|
||||
}
|
||||
if (isset($data['category_id']))
|
||||
$data['category_name'] = PostCategory::where('id', $data['category_id'])->value('name');
|
||||
$ossservice = new OssService();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\model\Post;
|
||||
use app\common\model\PostComment;
|
||||
use app\common\model\User;
|
||||
use app\common\service\OssService;
|
||||
@@ -19,6 +20,34 @@ class PostCommentController extends BaseController
|
||||
{
|
||||
$this->service = new PostCommentService();
|
||||
}
|
||||
/**
|
||||
* 获取列表
|
||||
*
|
||||
* @param Request $request 请求对象
|
||||
* @return mixed 返回分页数据及总数
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
try {
|
||||
$scene = $request->get('scene');
|
||||
$raw = $this->service->serviceList($request);
|
||||
$data = $this->transformData($raw, method_exists($this, 'indexFormat')
|
||||
? [$this, 'indexFormat']
|
||||
: null);
|
||||
$records = $data['records'];
|
||||
|
||||
if($scene == 'self'){
|
||||
foreach ($records as $k=>$record){
|
||||
$record['parent'] = PostComment::where('id',$record['parent_id'])->value('content');
|
||||
$record['post'] = Post::where('id',$record['post_id'])->first();
|
||||
$record['post']['user'] = User::where('id',$record['post']['user_id'])->first();
|
||||
}
|
||||
}
|
||||
return $this->success($data);
|
||||
} catch (\Throwable $e) {
|
||||
return $this->error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表页数据格式化
|
||||
|
||||
@@ -59,6 +59,11 @@ class PostCommentService
|
||||
if (isset($p['user_id']) && !empty($p['user_id'])) {
|
||||
$config['where']['user_id'] = $p['user_id'];
|
||||
}
|
||||
if (isset($p['scene']) && $p['scene']=='self') {
|
||||
if(!empty($request->user) && !empty($request->user->uid)){
|
||||
$config['where']['user_id'] = $request->user->uid;
|
||||
}
|
||||
}
|
||||
// 只查询根评论
|
||||
if (isset($p['parent_id']) && $p['parent_id'] == 0) {
|
||||
$config['where']['parent_id'] = 0;
|
||||
|
||||
@@ -240,7 +240,7 @@ class PostService
|
||||
LIMIT 50";
|
||||
|
||||
// 根据场景设置半径
|
||||
$radius = $scene === 'nearby' ? 5000 : 20000;
|
||||
$radius = $scene === 'nearby' ? 20000 : 200000;
|
||||
|
||||
// $query = Db::select($sql, [
|
||||
// 'lat' => $lat,
|
||||
|
||||
Reference in New Issue
Block a user