diff --git a/app/admin/controller/operation/OpurchaseclassController.php b/app/admin/controller/operation/OpurchaseclassController.php index 3f5e939..3cd72d8 100644 --- a/app/admin/controller/operation/OpurchaseclassController.php +++ b/app/admin/controller/operation/OpurchaseclassController.php @@ -134,7 +134,7 @@ class OpurchaseclassController extends BaseAdminController */ public function storage_list() { - // $this->request->__set('storage_list',1); + $this->request->__set('storage_list',1); return $this->dataLists(new OpurchaseclassofferLists()); } @@ -147,8 +147,8 @@ class OpurchaseclassController extends BaseAdminController $order_arr= Opurchaseclass::where('id',$id)->where('is_mer',2)->value('order_arr'); $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_value',['id'=>explode(',',$arr)]); + $this->request->__set('class_key',['in'=>['id']]); } return $this->dataLists(new CashierclassStreamLists()); } diff --git a/app/admin/lists/operation/OpurchaseclassofferLists.php b/app/admin/lists/operation/OpurchaseclassofferLists.php index 3ded277..64e0d4d 100644 --- a/app/admin/lists/operation/OpurchaseclassofferLists.php +++ b/app/admin/lists/operation/OpurchaseclassofferLists.php @@ -64,20 +64,20 @@ class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearch $where[] = ['supplier_id', '=', $this->request->supplierId]; } $this->where = $where; - // if ($this->request->__get('storage_list') == 1) { - // $list = OpurchaseGoodsOffer::where($this->searchWhere) - // ->where($where) - // ->limit($this->limitOffset, $this->limitLength) - // ->order('update_time', 'desc') - // ->select()->each(function ($item) { - // $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); - // if ($find) { - // $item['goods_name'] = $find['name']; - // $item['unit_name'] = $find['unit_name']; - // } - // $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name'); - // })->toArray(); - // } else { + if ($this->request->__get('storage_list') == 1) { + $list = OpurchaseGoodsOffer::where($this->searchWhere) + ->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->order('update_time', 'desc') + ->select()->each(function ($item) { + $find = Goods::where('id', $item['goods_id'])->with('unitName')->find(); + if ($find) { + $item['goods_name'] = $find['name']; + $item['unit_name'] = $find['unit_name']; + } + $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name'); + })->toArray(); + } else { $list = OpurchaseGoodsOffer::where($this->searchWhere) ->where($where) ->limit($this->limitOffset, $this->limitLength) @@ -90,7 +90,7 @@ class OpurchaseclassofferLists extends BaseAdminDataLists implements ListsSearch } $item['supplier_name'] = Supplier::where('id', $item['supplier_id'])->value('mer_name'); })->toArray(); - // } + } return $list; } diff --git a/app/api/controller/financial/FinancialRecordController.php b/app/api/controller/financial/FinancialRecordController.php index 5e44c42..58917df 100644 --- a/app/api/controller/financial/FinancialRecordController.php +++ b/app/api/controller/financial/FinancialRecordController.php @@ -56,9 +56,9 @@ class FinancialRecordController extends BaseApiController { $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']]); + $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(); @@ -70,9 +70,9 @@ class FinancialRecordController extends BaseApiController 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']]); + $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(); diff --git a/app/api/controller/goods/GoodsController.php b/app/api/controller/goods/GoodsController.php index 9e68a5f..7ec6cc0 100644 --- a/app/api/controller/goods/GoodsController.php +++ b/app/api/controller/goods/GoodsController.php @@ -17,7 +17,7 @@ class GoodsController extends BaseApiController{ * 商品列表 */ public function mer_list(){ - // $this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0); + $this->request->__set('mer_id',$this->request->userInfo['merchant']['mer_id']??0); return $this->dataLists(new GoodsLists()); } diff --git a/app/api/lists/financial/FinancialRecordLists.php b/app/api/lists/financial/FinancialRecordLists.php index e937a94..4490ef2 100644 --- a/app/api/lists/financial/FinancialRecordLists.php +++ b/app/api/lists/financial/FinancialRecordLists.php @@ -44,52 +44,51 @@ class FinancialRecordLists extends BaseAdminDataLists implements ListsSearchInte */ public function lists(): array { - // $class_value = $this->request->__get('class_value'); - // if ($class_value) { - // $where = [ - // 'type' => $class_value['type'], - // 'mer_id' => $class_value['mer_id'], - // ]; - // }else{ - // $where=[]; - // } + $class_value = $this->request->__get('class_value'); + if ($class_value) { + $where = [ + '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'); - // if ($is_detail == 1) { - // $list = FinancialRecord::where($this->searchWhere) - // ->where($where) - // ->limit($this->limitOffset, $this->limitLength) - // ->order('create_time', 'desc') - // ->select()->each(function ($item) { - // $item['user_nickname'] = ''; - // if ($item['user_id'] != 0) { - // $item['user_nickname'] = User::where('id', $item['user_id'])->value('nickname'); - // } - // $item['financial_pm'] = $item['financial_pm'] == 0 ? "支出" : "获得"; - // return $item; - // }); - // } else { - // $list = FinancialRecord::where($this->searchWhere) - // ->where($where) - // ->limit($this->limitOffset, $this->limitLength) - // ->field("FROM_UNIXTIME(create_time, '%Y-%m-%d') as record_date, SUM(number) as total_amount") - // ->group('record_date') - // ->order('record_date') - // ->select()->each(function ($item) use ($where, $searchWhere) { - // $cashier_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_ORDER_PAY)->sum('number'); - // $item['cashier_total_amount'] = $cashier_total_amount; - // $cashier_cash_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_CASH_ORDER_PAY)->sum('number'); - // $item['cashier_cash_total_amount'] = $cashier_cash_total_amount; - // $platofrm_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::USER_ORDER_PAY)->sum('number'); - // $item['platofrm_total_amount'] = $platofrm_total_amount; - // }); - // } + $this->where = $where; + $searchWhere = $this->searchWhere; + $is_detail = $this->request->__get('is_detail'); + if ($is_detail == 1) { + $list = FinancialRecord::where($this->searchWhere) + ->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->order('create_time', 'desc') + ->select()->each(function ($item) { + $item['user_nickname'] = ''; + if ($item['user_id'] != 0) { + $item['user_nickname'] = User::where('id', $item['user_id'])->value('nickname'); + } + $item['financial_pm'] = $item['financial_pm'] == 0 ? "支出" : "获得"; + return $item; + }); + } else { + $list = FinancialRecord::where($this->searchWhere) + ->where($where) + ->limit($this->limitOffset, $this->limitLength) + ->field("FROM_UNIXTIME(create_time, '%Y-%m-%d') as record_date, SUM(number) as total_amount") + ->group('record_date') + ->order('record_date') + ->select()->each(function ($item) use ($where, $searchWhere) { + $cashier_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_ORDER_PAY)->sum('number'); + $item['cashier_total_amount'] = $cashier_total_amount; + $cashier_cash_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::CASHIER_CASH_ORDER_PAY)->sum('number'); + $item['cashier_cash_total_amount'] = $cashier_cash_total_amount; + $platofrm_total_amount = FinancialRecord::where($where)->where($searchWhere)->where('financial_type', OrderEnum::USER_ORDER_PAY)->sum('number'); + $item['platofrm_total_amount'] = $platofrm_total_amount; + }); + } - // return $list?->toArray(); - return []; + return $list?->toArray(); } diff --git a/app/api/lists/goods/GoodsLists.php b/app/api/lists/goods/GoodsLists.php index acbbfef..ba3f2d5 100644 --- a/app/api/lists/goods/GoodsLists.php +++ b/app/api/lists/goods/GoodsLists.php @@ -98,20 +98,20 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface }else{ $order['id'] = 'desc'; } - // $mer_id=$this->request->__get('mer_id'); - // if($mer_id){ - // $goods_id=Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->limit($this->limitOffset, $this->limitLength)->column('goods_id'); - // if($goods_id){ - // return Goods::where($this->searchWhere)->where('id','in',$goods_id) - // ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec']) - // ->with(['className','brandName','unitName']) - // ->order($order) - // ->select() - // ->toArray(); - // }else{ - // return []; - // } - // } + $mer_id=$this->request->__get('mer_id'); + if($mer_id){ + $goods_id=Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->limit($this->limitOffset, $this->limitLength)->column('goods_id'); + if($goods_id){ + return Goods::where($this->searchWhere)->where('id','in',$goods_id) + ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec']) + ->with(['className','brandName','unitName']) + ->order($order) + ->select() + ->toArray(); + }else{ + return []; + } + } return Goods::where($this->searchWhere)->where($where) ->field(['id', 'name','brand','class','unit', 'sell', 'code','imgs','sales','spec']) ->limit($this->limitOffset, $this->limitLength) @@ -143,10 +143,10 @@ class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface $where[]=['class','=',$class_all]; } } - // $mer_id=$this->request->__get('mer_id'); - // if($mer_id){ - // return Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->count(); - // } + $mer_id=$this->request->__get('mer_id'); + if($mer_id){ + return Db::name('merchant_bind_goods')->where('mer_id',$mer_id)->count(); + } return Goods::where($this->searchWhere)->where($where)->count(); } diff --git a/app/common/lists/ListsSearchTrait.php b/app/common/lists/ListsSearchTrait.php index 849c39d..6439682 100644 --- a/app/common/lists/ListsSearchTrait.php +++ b/app/common/lists/ListsSearchTrait.php @@ -22,24 +22,24 @@ trait ListsSearchTrait return []; } $where = []; - // $class_key=$this->request->__get('class_key'); - // if($class_key!==null){ - // foreach($class_key as $key => $value){ - // if(isset($search[$key])){ - // foreach($value as $v){ // 遍历class_key的值,添加到search数组中 - // array_push($search[$key], $v); // 添加class_key的搜索条件 - // } - // }else{ - // $search[$key] = [$value[0]]; // 创建新的搜索条件 - // } - // } - // } + $class_key=$this->request->__get('class_key'); + if($class_key!==null){ + foreach($class_key as $key => $value){ + if(isset($search[$key])){ + foreach($value as $v){ // 遍历class_key的值,添加到search数组中 + array_push($search[$key], $v); // 添加class_key的搜索条件 + } + }else{ + $search[$key] = [$value[0]]; // 创建新的搜索条件 + } + } + } - // $class_value=$this->request->__get('class_value'); // 获取class_value的值 - // if($class_value!==null){ - // $this->params=array_merge($this->params,$class_value); + $class_value=$this->request->__get('class_value'); // 获取class_value的值 + if($class_value!==null){ + $this->params=array_merge($this->params,$class_value); - // } + } foreach ($search as $whereType => $whereFields) { switch ($whereType) { case '=':