settter
parent
8a3deee5f0
commit
13dd86109c
|
@ -5,6 +5,7 @@ namespace app\controller\api;
|
||||||
use app\exception\RepositoryException;
|
use app\exception\RepositoryException;
|
||||||
use app\model\Comment as CommentModel;
|
use app\model\Comment as CommentModel;
|
||||||
use app\repository\AccountRepository;
|
use app\repository\AccountRepository;
|
||||||
|
use app\repository\CommentRepository;
|
||||||
use app\repository\CouponRepository;
|
use app\repository\CouponRepository;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\exception\ValidateException;
|
use think\exception\ValidateException;
|
||||||
|
@ -24,23 +25,18 @@ class Comment extends Base
|
||||||
/**
|
/**
|
||||||
* 群聊列表 开发中
|
* 群聊列表 开发中
|
||||||
* */
|
* */
|
||||||
public function commentList()
|
public function myCommentZone()
|
||||||
{
|
{
|
||||||
$page = $this->request->param('page/d', 1);
|
$page = $this->request->param('page/d', 1);
|
||||||
$size = $this->request->param('size/d', 30);
|
$size = $this->request->param('size/d', 30);
|
||||||
$whereMap = [
|
$data = CommentRepository::getInstance()->myCommentZone( $page, $size);
|
||||||
["is_delete", "=", CommentModel::COMMON_OFF],//未删除
|
|
||||||
["state", "=", CommentModel::COMMON_ON],//审核通过
|
|
||||||
];
|
|
||||||
|
|
||||||
$data = CommentModel::findList($whereMap, [], $page, $size, null, ["id" => "desc"]);
|
|
||||||
return $this->json(0, "success", $data);
|
return $this->json(0, "success", $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建一条评论 开发中
|
* 创建一条文字评论 开发中
|
||||||
* */
|
* */
|
||||||
public function createComment()
|
public function commentText()
|
||||||
{
|
{
|
||||||
$accountId = $this->request->user['user_id'] ?? 0;
|
$accountId = $this->request->user['user_id'] ?? 0;
|
||||||
$accountRepo = AccountRepository::getInstance();
|
$accountRepo = AccountRepository::getInstance();
|
||||||
|
@ -55,24 +51,28 @@ class Comment extends Base
|
||||||
throw new ValidateException('用户无效!');
|
throw new ValidateException('用户无效!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//检测评论规则
|
||||||
|
|
||||||
|
|
||||||
$param = [
|
$param = [
|
||||||
"comment" => input("comment/s", ""),//评论内容 图片类型放入地址 语音类型放置语音文件地址
|
"comment" => input("comment/s", ""),//评论内容 图片类型放入地址 语音类型放置语音文件地址
|
||||||
"user_code" => $account['user_code'],
|
"user_code" => $account['user_code'],
|
||||||
"create_time" => date("Y-m-d H:i:s"),
|
"create_time" => date("Y-m-d H:i:s"),
|
||||||
"url" => input("url/s", ""),//图片地址 仅图片评论才有
|
"url" => input("url/s", ""),//图片地址 仅图片评论才有
|
||||||
"state" => CommentModel::state_default,
|
"state" => CommentModel::state_default,
|
||||||
"type" => input("type/s"),//评论类型
|
"type" => input("type/d",0),//评论类型
|
||||||
"lng" => input("lng/s"),//经度
|
"lng" => input("lng/s"),//经度
|
||||||
"lat" => input("lat/s"),//纬度
|
"lat" => input("lat/s"),//纬度
|
||||||
"location" => input("location/s"),
|
"location" => input("location/s"),
|
||||||
];
|
];
|
||||||
CommentModel::create($param);
|
CommentModel::create($param);
|
||||||
return $this->json();
|
return $this->json(0,"评论成功,等待审核");
|
||||||
} catch (ValidateException $e) {
|
} catch (ValidateException $e) {
|
||||||
return $this->json(4001, $e->getError());
|
return $this->json(4001, $e->getError());
|
||||||
} catch (RepositoryException $e) {
|
} catch (RepositoryException $e) {
|
||||||
return $this->json(4001, $e->getError());
|
return $this->json(4001, $e->getError());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
return $this->json(5001, '服务器繁忙!获取用户个人信息失败');
|
return $this->json(5001, '服务器繁忙!获取用户个人信息失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,10 +164,7 @@ class Consumer extends Base
|
||||||
* */
|
* */
|
||||||
public function flowBusiness()
|
public function flowBusiness()
|
||||||
{
|
{
|
||||||
|
|
||||||
$accountId = $this->request->user['user_id'] ?? 0;
|
$accountId = $this->request->user['user_id'] ?? 0;
|
||||||
|
|
||||||
|
|
||||||
$accountRepo = AccountRepository::getInstance();
|
$accountRepo = AccountRepository::getInstance();
|
||||||
try {
|
try {
|
||||||
$account = $accountRepo->findById($accountId, [], function ($q) {
|
$account = $accountRepo->findById($accountId, [], function ($q) {
|
||||||
|
@ -198,6 +195,37 @@ class Consumer extends Base
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
return $this->json(5001, '服务器繁忙!');
|
return $this->json(5001, '服务器繁忙!');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关注商家的列表
|
||||||
|
* */
|
||||||
|
public function getFlowBusiness()
|
||||||
|
{
|
||||||
|
$accountId = $this->request->user['user_id'] ?? 0;
|
||||||
|
$page = $this->request->param('page/d', 1);
|
||||||
|
$size = $this->request->param('size/d', 10);
|
||||||
|
$keyword = input("keyWord/s");
|
||||||
|
$accountRepo = AccountRepository::getInstance();
|
||||||
|
try {
|
||||||
|
$account = $accountRepo->findById($accountId, [], function ($q) {
|
||||||
|
return $q->with(['business', 'parent']);
|
||||||
|
});
|
||||||
|
if (empty($account)) {
|
||||||
|
throw new ValidateException('用户无效!');
|
||||||
|
}
|
||||||
|
$data = AccountRepository::getInstance()->getBusinessFlowList($account->user_code,$page,$size,$keyword);
|
||||||
|
$data->each(function ($item){
|
||||||
|
$item->businessCover = $this->request->domain() . $item->background;
|
||||||
|
});
|
||||||
|
return $this->json(0,"success",$data);
|
||||||
|
}catch (ValidateException $e) {
|
||||||
|
return $this->json(4001, $e->getError());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo $e->getMessage();
|
||||||
|
return $this->json(5001, '服务器繁忙!获取用户个人信息失败');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -147,9 +147,5 @@ class Coupon extends Base
|
||||||
return $this->json(5001,"领取失败");
|
return $this->json(5001,"领取失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -224,32 +224,4 @@ class User extends Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关注商家的列表
|
|
||||||
* */
|
|
||||||
public function businessFlowList()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
$page = $this->request->param('page/d', 1);
|
|
||||||
$size = $this->request->param('size/d', 30);
|
|
||||||
|
|
||||||
$accountRepo = AccountRepository::getInstance();
|
|
||||||
try {
|
|
||||||
$account = $accountRepo->findById($accountId, [], function ($q) {
|
|
||||||
return $q->with(['business', 'parent']);
|
|
||||||
});
|
|
||||||
if (empty($account)) {
|
|
||||||
throw new ValidateException('用户无效!');
|
|
||||||
}
|
|
||||||
}catch (ValidateException $e) {
|
|
||||||
return $this->json(4001, $e->getError());
|
|
||||||
} catch (Exception $e) {
|
|
||||||
return $this->json(5001, '服务器繁忙!获取用户个人信息失败');
|
|
||||||
}
|
|
||||||
$data = AccountRepository::getInstance()->getBusinessFlowList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\repository;
|
||||||
|
use app\model\Comment as CommentModel;
|
||||||
|
use app\service\Repository;
|
||||||
|
use think\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评论相关
|
||||||
|
*
|
||||||
|
* Class CommentRepository
|
||||||
|
* @package app\repository
|
||||||
|
* @method self getInstance(Model $model = null) static
|
||||||
|
*/
|
||||||
|
class CommentRepository extends Repository
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 评论列表
|
||||||
|
* @param array $whereMap
|
||||||
|
* @param array $field
|
||||||
|
* @param int $page
|
||||||
|
* @param int $size
|
||||||
|
* @param array $order
|
||||||
|
*/
|
||||||
|
public function myCommentZone($page = 1, $size = 10)
|
||||||
|
{
|
||||||
|
$whereMap = [
|
||||||
|
["a.is_delete", "=", CommentModel::COMMON_OFF],//未删除
|
||||||
|
["a.state", "=", CommentModel::COMMON_ON],//审核通过
|
||||||
|
];
|
||||||
|
return CommentModel::alias("a")
|
||||||
|
->join("account b" ,"a.user_code = b.user_code")
|
||||||
|
->where($whereMap)
|
||||||
|
->field([
|
||||||
|
"a.comment",
|
||||||
|
"a.user_code as userCode",
|
||||||
|
"a.business_code as businessCode",
|
||||||
|
"b.nick_name as consumerName",
|
||||||
|
"a.create_time as createTime",
|
||||||
|
"a.url",
|
||||||
|
"a.type",
|
||||||
|
])
|
||||||
|
->page($page,$size)
|
||||||
|
->order("a.create_time desc")
|
||||||
|
->select();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,22 +11,27 @@ trait BusinessFlowTrait
|
||||||
* @param $accountCode
|
* @param $accountCode
|
||||||
* @param $page
|
* @param $page
|
||||||
* @param $size
|
* @param $size
|
||||||
|
* @param $keyword
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public function getBusinessFlowList($accountCode, $page, $size)
|
public function getBusinessFlowList($accountCode, $page, $size,$keyword=null)
|
||||||
{
|
{
|
||||||
return BusinessFlow::alias("a")
|
return BusinessFlow::alias("a")
|
||||||
->join("business b","a.business_code = b.code")
|
->join("business b","a.business_code = b.code")
|
||||||
->where("a.user_code",$accountCode)
|
->where("a.user_code",$accountCode)
|
||||||
->field(["b.code",
|
->when(!empty($keyword), function ($q) use ($keyword) {
|
||||||
"b.business_name",
|
$q->where("b.business_name", "like", "%{$keyword}%");
|
||||||
"b.business_subtitle",
|
})
|
||||||
"b.lat",
|
->field([
|
||||||
"b.lng",
|
"b.id",
|
||||||
"b.characteristic",
|
"b.code as businessCode",
|
||||||
|
"b.business_name as businessName",
|
||||||
"b.background",
|
"b.background",
|
||||||
|
"a.create_time as createTime",
|
||||||
|
"a.user_code as userCode",
|
||||||
])
|
])
|
||||||
->page($page,$size)
|
->page($page,$size)
|
||||||
|
->order("a.id desc")
|
||||||
->select();
|
->select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue