优化了代码逻辑,增加了余额明细功能,并修改了搜索条件设置方式。

This commit is contained in:
mkm 2024-05-27 18:21:47 +08:00
parent 5550cc8c94
commit e9df9d9041
4 changed files with 66 additions and 42 deletions

View File

@ -148,7 +148,7 @@ class OpurchaseclassController extends BaseAdminController
$arr=Opurchaseclass::where('id','in',explode(',',$order_arr))->where('is_mer',1)->value('order_arr');
if($arr){
$this->request->__set('class_value',['id'=>explode(',',$arr)]);
$this->request->__set('class_key',['in'=>'id']);
$this->request->__set('class_key',['in'=>['id']]);
}
return $this->dataLists(new CashierclassStreamLists());
}

View File

@ -54,7 +54,27 @@ class FinancialRecordController extends BaseApiController
*/
public function api_lists()
{
$mer_id=$this->request->userInfo['merchant']['mer_id']??0;
if($mer_id!=0){
$this->request->__set('is_detail',1);
$this->request->__set('class_value',['mer_id'=>$mer_id,'type'=>1]);
$this->request->__set('class_key',['='=>['mer_id','type']]);
return $this->dataLists((new FinancialRecordLists));
}
return $this->success();
}
/**
* 余额明细
*/
public function supplier_list(){
$id=$this->request->userInfo['supplier']['id']??0;
if($id!=0){
$this->request->__set('is_detail',1);
$this->request->__set('class_value',['mer_id'=>$id,'type'=>3]);
$this->request->__set('class_key',['='=>['mer_id','type']]);
return $this->dataLists((new FinancialRecordLists));
}
return $this->success();
}
}

View File

@ -44,14 +44,16 @@ class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInte
*/
public function lists(): array
{
$mer_id = $this->request->userInfo['merchant']['mer_id'] ?? 0;
if ($mer_id <= 0) {
return [];
}
$class_value = $this->request->__get('class_value');
if ($class_value) {
$where = [
'type' => 1,
'mer_id' => $mer_id,
'type' => $class_value['type'],
'mer_id' => $class_value['mer_id'],
];
}else{
$where=[];
}
$this->where = $where;
$searchWhere = $this->searchWhere;
$is_detail = $this->request->__get('is_detail');

View File

@ -26,9 +26,11 @@ trait ListsSearchTrait
if($class_key!==null){
foreach($class_key as $key => $value){
if(isset($search[$key])){
array_push($search[$key], $value); // 添加class_key的搜索条件
foreach($value as $v){ // 遍历class_key的值添加到search数组中
array_push($search[$key], $v); // 添加class_key的搜索条件
}
}else{
$search[$key] = [$value]; // 创建新的搜索条件
$search[$key] = [$value[0]]; // 创建新的搜索条件
}
}
}