From b0bda5044971a26a88df7d64b1e6ac9ae7326f23 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 17 Jun 2024 13:47:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreBranchProductController.php | 7 +- .../StoreBranchProductExchangeLists.php | 125 ++++++++++++++++++ app/api/controller/store/StoreController.php | 2 +- 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php diff --git a/app/admin/controller/store_branch_product/StoreBranchProductController.php b/app/admin/controller/store_branch_product/StoreBranchProductController.php index c26452cb4..8b97950eb 100644 --- a/app/admin/controller/store_branch_product/StoreBranchProductController.php +++ b/app/admin/controller/store_branch_product/StoreBranchProductController.php @@ -5,6 +5,7 @@ namespace app\admin\controller\store_branch_product; use app\admin\controller\BaseAdminController; use app\admin\lists\store_branch_product\StoreBranchProductLists; +use app\admin\lists\store_branch_product_exchange\StoreBranchProductExchangeLists; use app\admin\logic\store_branch_product\StoreBranchProductLogic; use app\admin\logic\store_product\StoreProductLogic; use app\admin\validate\store_product\StoreProductValidate; @@ -27,7 +28,11 @@ class StoreBranchProductController extends BaseAdminController */ public function lists() { - return $this->dataLists(new StoreBranchProductLists()); + if($this->request->get('exchange',0)==1){ + return $this->dataLists(new StoreBranchProductExchangeLists()); + }else{ + return $this->dataLists(new StoreBranchProductLists()); + } } diff --git a/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php b/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php new file mode 100644 index 000000000..f4144ab48 --- /dev/null +++ b/app/admin/lists/store_branch_product exchange/StoreBranchProductExchangeLists.php @@ -0,0 +1,125 @@ + ['product_id', 'cate_id','store_id','status'], + '%pipe_like%' => ['store_name_code'=>'store_name|bar_code'], + '%like%' => ['store_name'], + ]; + } + + + /** + * @notes 获取门店列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 17:45 + */ + public function lists(): array + { + $status = $this->params['status'] ?? ''; + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProductExchange::where($this->searchWhere)->where($where) + ->field(['id','store_id','product_id', 'image', 'store_name', 'cate_id', 'price', 'sales', 'stock', 'unit', 'cost', 'status']) + ->when(!empty($this->adminInfo['store_id']), function ($query) { + $query->where('store_id', $this->adminInfo['store_id']); + }) + ->when(!empty($status), function ($query) use ($status) { + if ($status == 1) { + $query->where('status', $status); + } elseif ($status == 2) { + $query->where('status', 0); + } elseif ($status == 3) { + $query->where('stock', '<=', 0); + } elseif ($status == 4) { + $query->where('stock', '<', 10)->where('stock', '>', 0); + } + }) + ->limit($this->limitOffset, $this->limitLength) + ->order(['sort' => 'desc','stock'=>'desc','id' => 'desc']) + ->select() + ->each(function ($item) { + $item['system_store_name']=SystemStore::where('id',$item['store_id'])->value('name'); + $item['unit_name'] = StoreProductUnit::where('id', $item['unit'])->value('name'); + $item['cate_name'] = StoreCategory::where('id', $item['cate_id'])->value('name'); + return $item; + }) + ->toArray(); + } + + + /** + * @notes 获取门店列表数量 + * @return int + * @author admin + * @date 2024/05/31 17:45 + */ + public function count(): int + { + $status = $this->params['status'] ?? ''; + $class_all=$this->request->get('class_all'); + $where=[]; + if($class_all){ + $arr=Cate::where('pid',$class_all)->column('id'); + if($arr){ + $arr2=Cate::where('pid','in',$arr)->column('id'); + $where[]=['cate_id','in',array_merge($arr,$arr2)]; + } + } + return StoreBranchProductExchange::where($this->searchWhere)->where($where) + ->when(!empty($this->adminInfo['store_id']), function ($query) { + $query->where('store_id', $this->adminInfo['store_id']); + }) + ->when(!empty($status), function ($query) use ($status) { + if ($status == 1) { + $query->where('status', $status); + } elseif ($status == 2) { + $query->where('status', 0); + } elseif ($status == 3) { + $query->where('stock', '<=', 0); + } elseif ($status == 4) { + $query->where('stock', '<', 10)->where('stock', '>', 0); + } + }) + ->count(); + } + +} diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 59493a688..a620c3d24 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -54,7 +54,7 @@ class StoreController extends BaseApiController 'uid'=>$find['id'], 'staff_id'=>0, 'order_id'=>getNewOrderId('CZ'), - 'price'=>1000, + 'price'=>0.01, ]; $order = UserRecharge::create($data);