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() public function lists()
{ {
$this->request->__set('uid',$this->userId);
return $this->dataLists(new PurchaseProductOfferLists()); return $this->dataLists(new PurchaseProductOfferLists());
} }

View File

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