Merge pull request '优化购买产品优惠列表查询逻辑' (#251) from dev into main

Reviewed-on: #251
This commit is contained in:
mkm 2024-10-10 16:37:27 +08:00
commit 90fb0129ed
2 changed files with 5 additions and 8 deletions

View File

@ -26,7 +26,6 @@ class PurchaseProductOfferController extends BaseApiController
*/
public function lists()
{
$this->request->__set('uid',$this->userId);
return $this->dataLists(new PurchaseProductOfferLists());
}

View File

@ -18,7 +18,6 @@ use app\api\lists\BaseApiDataLists;
class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchInterface
{
public $userId;
/**
* @notes 设置搜索条件
* @return \string[][]
@ -44,9 +43,8 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
*/
public function lists(): array
{
$uid=$this->request->__get('uid');
if($uid){
$this->searchWhere[]=['buyer_id','=',$uid];
if($this->userId>0){
$this->searchWhere[]=['buyer_id','=',$this->userId];
}else{
return [];
}
@ -87,10 +85,10 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
*/
public function count(): int
{
if($this->userId){
return 0;
}else{
if($this->userId>0){
return PurchaseProductOffer::where($this->searchWhere)->count();
}else{
return 0;
}
}