订单列表增加订单类型字段及名称显示;采购产品报价列表增加用户ID筛选

- 在 BeforehandOrderLists 类的 lists 方法中添加 order_type 字段,并增加对应的订单类型名称显示
- 在 PurchaseProductOfferController 类的 lists 方法中设置 uid 参数为当前用户 ID
- 在 PurchaseProductOfferLists 类的 lists 方法中根据 uid 进行搜索条件设置,并在 count 方法中添加对应逻辑
This commit is contained in:
mkm 2024-10-10 16:19:32 +08:00
parent ef47fe0147
commit 00fb209800
3 changed files with 21 additions and 3 deletions

View File

@ -43,7 +43,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
public function lists(): array
{
return BeforehandOrder::where($this->searchWhere)
->field(['id','order_id', 'uid','total_num','total_price','admin_id', 'pay_price', 'deduction_price','create_time', 'status', 'mark'])
->field(['id','order_id', 'uid','order_type','total_num','total_price','admin_id', 'pay_price', 'deduction_price','create_time', 'status', 'mark'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item){
@ -52,6 +52,13 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte
}else{
$item->admin_name='';
}
if($item->order_type==1){
$item->order_type_name='普通订单';
}elseif($item->order_type==2){
$item->order_type_name='商贩订单';
}elseif($item->order_type==3){
$item->order_type_name='一条龙订单';
}
})
->toArray();
}

View File

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

View File

@ -18,7 +18,7 @@ use app\api\lists\BaseApiDataLists;
class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchInterface
{
public $userId;
/**
* @notes 设置搜索条件
* @return \string[][]
@ -44,6 +44,12 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
*/
public function lists(): array
{
$uid=$this->request->__get('uid');
if($uid){
$this->searchWhere[]=['buyer_id','=',$uid];
}else{
return [];
}
return PurchaseProductOffer::where($this->searchWhere)
->field(['id', 'order_id', 'product_id', 'price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm','need_num', 'buyer_id', 'status', ])
->limit($this->limitOffset, $this->limitLength)
@ -81,7 +87,11 @@ class PurchaseProductOfferLists extends BaseApiDataLists implements ListsSearchI
*/
public function count(): int
{
return PurchaseProductOffer::where($this->searchWhere)->count();
if($this->userId){
return 0;
}else{
return PurchaseProductOffer::where($this->searchWhere)->count();
}
}
}