更新详情

This commit is contained in:
yaooo 2023-08-16 12:04:57 +08:00
parent 153d4d7406
commit 54cc347de2
2 changed files with 10 additions and 5 deletions

View File

@ -222,7 +222,7 @@ class CommunityRepository extends BaseRepository
]; ];
$config = systemConfig("community_app_switch"); $config = systemConfig("community_app_switch");
if ($config) $where['is_type'] = $config; if ($config) $where['is_type'] = $config;
return $this->dao->getSearch($where)->with([ $info = $this->dao->getSearch($where)->with([
'author' => function($query) { 'author' => function($query) {
$query->field('uid,real_name,status,avatar,nickname,count_start'); $query->field('uid,real_name,status,avatar,nickname,count_start');
}, },
@ -230,6 +230,12 @@ class CommunityRepository extends BaseRepository
'category', 'category',
'relevance.spu' 'relevance.spu'
])->find(); ])->find();
if ($info){
$merInfo = Db::name('StoreService')->alias('ss')->leftJoin('Merchant m','ss.mer_id = M.mer_id')->where('ss.uid', $info['uid'])->field('m.mer_avatar, m.mer_name')->find();
$info['mer_name'] = $merInfo['mer_name'] ?? '';
$info['mer_avatar'] = $merInfo['mer_avatar'] ?? '';
}
return $info;
} }
/** /**
@ -644,7 +650,7 @@ class CommunityRepository extends BaseRepository
* @throws \think\db\exception\DbException * @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException * @throws \think\db\exception\ModelNotFoundException
*/ */
public function addCart($uid, $id, $resaleType=1) public function addCart($uid, $id)
{ {
$where = [ $where = [
$this->dao->getPk() => $id, $this->dao->getPk() => $id,
@ -666,7 +672,7 @@ class CommunityRepository extends BaseRepository
$data = [ $data = [
'uid' => $uid, 'uid' => $uid,
'mer_id' => $item['mer_id'], 'mer_id' => $item['mer_id'],
'product_type' => $resaleType == 1 ? 98 : 99, 'product_type' => 98,
'product_id' => $item['product_id'], 'product_id' => $item['product_id'],
'product_attr_unique' => $item['product_attr_unique'], 'product_attr_unique' => $item['product_attr_unique'],
'cart_num' => $item['number'], 'cart_num' => $item['number'],

View File

@ -457,8 +457,7 @@ class Community extends BaseController
public function addCart() public function addCart()
{ {
$communityId = $this->request->param('community_id'); $communityId = $this->request->param('community_id');
$resaleType = $this->request->param('resale_type', 1); $cartIds = $this->repository->addCart($this->request->uid(), $communityId);
$cartIds = $this->repository->addCart($this->request->uid(), $communityId, $resaleType);
return app('json')->success(['cart_id' => $cartIds]); return app('json')->success(['cart_id' => $cartIds]);
} }