From 7f5eeeb71eca0e04ac37c1d580cd5af9617ad164 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 14 Nov 2024 14:54:00 +0800 Subject: [PATCH] =?UTF-8?q?fix(admin):=20=E4=BF=AE=E5=A4=8D=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E5=91=98=E8=AE=BE=E7=BD=AE=E9=87=87=E8=B4=AD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=9D=83=E9=99=90=E9=97=AE=E9=A2=98=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E5=BA=93=E5=AD=98=E6=9F=A5=E8=AF=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 PurchaseProductOfferController 中添加 admin_id 参数 - 在 PurchaseProductOfferLogic 中增加采购员权限验证 - 在 WarehouseLogic 中添加商品名称和分类筛选功能 - 在 IndexController 中添加利润计算和订单数据处理逻辑 --- .../PurchaseProductOfferController.php | 1 + .../PurchaseProductOfferLogic.php | 5 ++- app/admin/logic/statistic/WarehouseLogic.php | 33 ++++++++++++++--- app/api/controller/IndexController.php | 35 ++++++++++++++++++- 4 files changed, 68 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index 3c6f03f61..65f9a7602 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -74,6 +74,7 @@ class PurchaseProductOfferController extends BaseAdminController public function setProcureInfo() { $params = $this->request->post(); + $params['admin_id']=$this->adminId; PurchaseProductOfferLogic::setProcureInfo($params); return $this->success('设置成功', [], 1, 1); } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index f3405a1ab..985b39ec5 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -111,9 +111,12 @@ class PurchaseProductOfferLogic extends BaseLogic */ public static function setProcureInfo(array $params): bool { + $offer = PurchaseProductOffer::where(['id' => $params['id']])->find(); + if($offer['buyer_id']!=$params['admin_id']){ + throw new BusinessException('您不是当事采购员,无法设置采购信息'); + } Db::startTrans(); try { - $offer = PurchaseProductOffer::where(['id' => $params['id']])->find(); $offer->save([ 'buyer_nums' => $params['buyer_nums'], 'supplier_id' => $params['supplier_id'], diff --git a/app/admin/logic/statistic/WarehouseLogic.php b/app/admin/logic/statistic/WarehouseLogic.php index 399e1dd0e..a3692cc8b 100644 --- a/app/admin/logic/statistic/WarehouseLogic.php +++ b/app/admin/logic/statistic/WarehouseLogic.php @@ -208,8 +208,15 @@ class WarehouseLogic extends BaseLogic public static function negativeInventory($parmas) { if ($parmas['type'] == 1) { - $list = StoreProduct::where('stock', '<', 0)->page($parmas['page_no'], 15)->select()->toArray(); - $count = StoreProduct::where('stock', '<', 0)->count(); + $where[]= ['stock', '<', 0]; + if($parmas['store_name']!=''){ + $where[]=['store_name','like','%'.$parmas['store_name'].'%']; + } + if($parmas['top_cate_id']!=''){ + $where[]=['top_cate_id','=',$parmas['top_cate_id']]; + } + $list = StoreProduct::where($where)->page($parmas['page_no'], 15)->select()->toArray(); + $count = StoreProduct::where($where)->count(); } elseif ($parmas['type'] == 2) { $where[] = ['stock', '<', 0]; if (isset($parmas['store_id']) && $parmas['store_id'] > 0) { @@ -220,6 +227,12 @@ class WarehouseLogic extends BaseLogic $store_arr = explode(',', $store_arr); $where[] = ['store_id', 'not in', $store_arr]; } + if($parmas['store_name']!=''){ + $where[]=['store_name','like','%'.$parmas['store_name'].'%']; + } + if($parmas['top_cate_id']!=''){ + $where[]=['top_cate_id','=',$parmas['top_cate_id']]; + } $list = StoreBranchProduct::where($where)->page($parmas['page_no'], 15)->select() ->each(function ($item) { $item->remark = SystemStore::where('id', $item['store_id'])->value('name'); @@ -227,7 +240,19 @@ class WarehouseLogic extends BaseLogic ->toArray(); $count = StoreBranchProduct::where($where)->count(); } elseif ($parmas['type'] == 3) { - $list = WarehouseProductStorege::where('nums', '<', 0)->page($parmas['page_no'], 15)->select() + $where[]=['nums','<',0]; + $where2=[]; + if($parmas['store_name']!=''){ + $where2[]=['store_name','like','%'.$parmas['store_name'].'%']; + } + if($parmas['top_cate_id']!=''){ + $where2[]=['top_cate_id','=',$parmas['top_cate_id']]; + } + if($where2){ + $ids=StoreProduct::where($where2)->column('id'); + $where[]=['product_id','in',$ids]; + } + $list = WarehouseProductStorege::where($where)->page($parmas['page_no'], 15)->select() ->each(function ($item) { $find = StoreProduct::where('id', $item['product_id'])->find(); $item->store_name = $find['store_name']; @@ -235,7 +260,7 @@ class WarehouseLogic extends BaseLogic $item->stock = $item['nums']; $item->remark = Warehouse::where('id', $item['warehouse_id'])->value('name'); })->toArray(); - $count = WarehouseProductStorege::where('nums', '<', 0)->count(); + $count = WarehouseProductStorege::where($where)->count(); } return ['lists' => $list, 'count' => $count]; } diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index ee26fd9eb..4194e98d6 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -54,8 +54,41 @@ class IndexController extends BaseApiController public function index() { d(1); + $arr=Db::name('ceshi_copy')->select(); + foreach ($arr as $k => $v) { + $data = [ - $arr=StoreOrder::where('store_id',8)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray(); + 'cost' => $v['cost'], + 'purchase' => $v['purchase'], + 'price' => $v['price'], + 'vip_price' => $v['price'], + + ]; + $rose = 0; + //零售-供货 + $rose_price = bcsub($v['price'], $v['purchase'], 2); + if ($rose_price > 0) { + //利润除于零售 + $price_div = bcdiv($rose_price, $v['price'], 2); + $rose=bcmul($price_div, 100, 2); + } + $data['rose']=$rose; + StoreProduct::update($data, ['id' => $v['product_id']]); + //修改 + StoreBranchProduct::where('product_id', $v['product_id'])->whereNotIn('store_id', [17, 18])->update([ + 'price' => $v['price'], + 'vip_price' => $v['price'], + 'cost' => $v['cost'], + 'purchase' => $v['purchase'], + 'rose' => $rose + + ]); + } + d(11); + $pay_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('pay_price'); + $refund_price=StoreOrder::where('store_id',3)->where('id','>=',1867)->where('id','<=',4826)->where('paid',1)->sum('refund_price'); + d($pay_price,$refund_price); + $arr=StoreOrder::where('store_id',3)->where('id','>',551)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray(); $data=[]; foreach ($arr as $k => $v) { $total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');