diff --git a/app/admin/controller/SkuController.php b/app/admin/controller/SkuController.php index 9554618..b2fbc73 100644 --- a/app/admin/controller/SkuController.php +++ b/app/admin/controller/SkuController.php @@ -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(); diff --git a/app/common/controller/PostCommentController.php b/app/common/controller/PostCommentController.php index 801e6c7..9e248a1 100644 --- a/app/common/controller/PostCommentController.php +++ b/app/common/controller/PostCommentController.php @@ -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()); + } + } /** * 列表页数据格式化 diff --git a/app/common/service/PostCommentService.php b/app/common/service/PostCommentService.php index 57bf76b..8087436 100644 --- a/app/common/service/PostCommentService.php +++ b/app/common/service/PostCommentService.php @@ -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; diff --git a/app/common/service/PostService.php b/app/common/service/PostService.php index c76c8b7..0aaf1ee 100644 --- a/app/common/service/PostService.php +++ b/app/common/service/PostService.php @@ -240,7 +240,7 @@ class PostService LIMIT 50"; // 根据场景设置半径 - $radius = $scene === 'nearby' ? 5000 : 20000; + $radius = $scene === 'nearby' ? 20000 : 200000; // $query = Db::select($sql, [ // 'lat' => $lat,