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 1/2] =?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'); From f93a8d8a1f9ee048e474d0151fd92f38bbb79e22 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 14 Nov 2024 15:17:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix(warehouse=5Forder):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BB=93=E5=BA=93=E8=AE=A2=E5=8D=95=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在导出功能中添加供应商名称显示 - 修复订单详情导出时的单价计算问题 - 优化导出表格的列标题和内容显示 - 增加对不支持的操作类型进行提示 --- .../warehouse_order/WarehouseOrderController.php | 9 +++++++++ app/common/service/xlsx/WarehouseOrdeRentry.php | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/admin/controller/warehouse_order/WarehouseOrderController.php b/app/admin/controller/warehouse_order/WarehouseOrderController.php index fa7470f0a..7c20b1dc0 100644 --- a/app/admin/controller/warehouse_order/WarehouseOrderController.php +++ b/app/admin/controller/warehouse_order/WarehouseOrderController.php @@ -13,6 +13,7 @@ use app\common\model\store_branch_product\StoreBranchProduct; use app\common\model\store_order\StoreOrder; use app\common\model\store_product\StoreProduct; use app\common\model\store_product_unit\StoreProductUnit; +use app\common\model\supplier\Supplier; use app\common\model\system_store\SystemStore; use app\common\model\warehouse_order\WarehouseOrder; use app\common\model\warehouse_product\WarehouseProduct; @@ -209,6 +210,7 @@ class WarehouseOrderController extends BaseAdminController $value->unit_name = ''; } $order['total_num'] += $value->nums; + $value->supplier_name= Supplier::where('id', $value->supplier_id)->value('mer_name'); } $file_path = $xlsx->export($data, $order); @@ -222,6 +224,9 @@ class WarehouseOrderController extends BaseAdminController { $id = $this->request->post('id'); $type = $this->request->post('type'); + if(in_array($type, [2,3])){ + return $this->fail('暂不支持此操作'); + } $xlsx = new OrderDetail(); $order = WarehouseOrder::where('id', $id)->findOrEmpty(); $system_store = SystemStore::where('id', $order['store_id'])->value('name'); @@ -249,8 +254,12 @@ class WarehouseOrderController extends BaseAdminController // $value->total_price=bcmul($find['price'],$value['nums'],2); // $total_price+=$value->total_price; // }else{ + if($type==1){ $value->price = $value['purchase']; + $value->total_price=bcmul($value['purchase'],$value['nums'],2); $total_price+=$value->total_price; + } + // } $value->cart_num = $value['nums']; diff --git a/app/common/service/xlsx/WarehouseOrdeRentry.php b/app/common/service/xlsx/WarehouseOrdeRentry.php index 004964022..05af5bdda 100644 --- a/app/common/service/xlsx/WarehouseOrdeRentry.php +++ b/app/common/service/xlsx/WarehouseOrdeRentry.php @@ -34,7 +34,7 @@ class WarehouseOrdeRentry $sheet->setCellValue('G2', $order['code']??''); $sheet->setCellValue('A3', '序号'); $sheet->setCellValue('B3', '商品名称'); - $sheet->setCellValue('D3', '规格'); + $sheet->setCellValue('D3', '供应商'); $sheet->setCellValue('F3', '单位'); $sheet->setCellValue('G3', '单价'); $sheet->setCellValue('H3', '数量'); @@ -53,10 +53,10 @@ class WarehouseOrdeRentry $spreadsheet->getDefaultStyle()->applyFromArray($defaultStyle); foreach ($data as $k => $v) { - $sheet->setCellValue('A' . ($k + 4), $k+1 ); + $sheet->setCellValue('A' . ($k + 4), $v['product_id'] ); $sheet->setCellValue('B' . ($k + 4), $v['store_name']); $sheet->mergeCells('B' . ($k + 4) . ':C' . $k + 4); - $sheet->setCellValue('D' . ($k + 4), $v['store_info']); + $sheet->setCellValue('D' . ($k + 4), $v['supplier_name']); $sheet->mergeCells('D' . ($k + 4) . ':E' . $k + 4); $sheet->setCellValue('F' . ($k + 4), $v['unit_name']); $sheet->setCellValue('G' . ($k + 4), $v['purchase']);