From b37080e87364ac5fee5e6dd8cceee489f5fb551b Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 14 Oct 2024 18:10:47 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E6=8A=A5=E4=BB=B7=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E5=90=8D=E7=A7=B0=E6=90=9C=E7=B4=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在搜索条件中增加店铺名称(store_name) - 实现根据店铺名称搜索相关产品,并返回对应报价信息 - 添加店铺名称搜索逻辑,优化搜索结果准确性 - 修复可能存在的搜索空结果问题 --- .../PurchaseProductOfferLists.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index f292d17ee..348efc919 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -21,6 +21,7 @@ use app\common\model\supplier\Supplier; class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface { + public $is_ids; /** * @notes 设置搜索条件 @@ -47,6 +48,15 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc */ public function lists(): array { + $store_name=$this->request->get('store_name'); + if($store_name){ + $ids=StoreProduct::where('store_name','like','%'.$store_name.'%')->column('id'); + if($ids){ + $this->searchWhere[]=['product_id','in',$ids]; + }else{ + $this->is_ids=1; + } + } return PurchaseProductOffer::where($this->searchWhere) ->field(['id', 'supplier_id', 'order_id', 'product_id', 'price','total_price', 'buyer_nums', 'unit', 'is_buyer', 'buyer_confirm', 'is_storage', 'is_stream', 'need_num', 'mark', 'buyer_id', 'status', 'stream_admin_id', 'stream_time', 'storage_admin_id']) ->limit($this->limitOffset, $this->limitLength) @@ -84,6 +94,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc }else{ $item->is_storage_name='未入库'; } + $item->pay_type_name=$item->pay_type==1?'赊账':'现金'; }) ->toArray(); @@ -98,6 +109,9 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc */ public function count(): int { + if($this->is_ids==1){ + return 0; + } return PurchaseProductOffer::where($this->searchWhere)->count(); } From d1d019ac16000ecd890fab84d42ad866bd071740 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 14 Oct 2024 20:33:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=87=87=E8=B4=AD=E4=BF=A1=E6=81=AF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 PurchaseProductOfferController 中添加 setBatchProcureInfo 方法,实现批量设置采购信息的功能 - 在 PurchaseProductOfferLogic 中实现 setBatchProcureInfo 逻辑,支持批量保存采购信息 - 更新 BeforehandOrderLists 和 PurchaseProductOfferLists 中的搜索条件,增加新的搜索字段 - 优化 PurchaseProductOfferLogic 中的 outbound_price 字段赋值逻辑,防止空值导致的错误 --- .../PurchaseProductOfferController.php | 8 +++-- .../beforehand_order/BeforehandOrderLists.php | 2 +- .../PurchaseProductOfferLists.php | 2 +- .../PurchaseProductOfferLogic.php | 35 +++++++++++++++++-- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php index f1c5eb635..c4a5ef6ab 100644 --- a/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php +++ b/app/admin/controller/purchase_product_offer/PurchaseProductOfferController.php @@ -75,10 +75,14 @@ class PurchaseProductOfferController extends BaseAdminController { $params = $this->request->post(); PurchaseProductOfferLogic::setProcureInfo($params); - return $this->success('设置成功', [], 1, 1); } - + public function setBatchProcureInfo() + { + $params = $this->request->post(); + PurchaseProductOfferLogic::setBatchProcureInfo($params); + return $this->success('设置成功', [], 1, 1); + } /** * @notes 删除采购供应链商品 diff --git a/app/admin/lists/beforehand_order/BeforehandOrderLists.php b/app/admin/lists/beforehand_order/BeforehandOrderLists.php index 77da3c764..47e7c0444 100644 --- a/app/admin/lists/beforehand_order/BeforehandOrderLists.php +++ b/app/admin/lists/beforehand_order/BeforehandOrderLists.php @@ -27,7 +27,7 @@ class BeforehandOrderLists extends BaseAdminDataLists implements ListsSearchInte public function setSearch(): array { return [ - '=' => ['store_id', 'order_id', 'uid','paid','status',], + '=' => ['store_id', 'order_id', 'uid','paid','status','order_type'], ]; } diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 348efc919..ae004f90f 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -32,7 +32,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc public function setSearch(): array { return [ - '=' => ['order_id'], + '=' => ['order_id','buyer_confirm'], ]; } diff --git a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php index 4744192ff..25f0c588e 100644 --- a/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php +++ b/app/admin/logic/purchase_product_offer/PurchaseProductOfferLogic.php @@ -105,7 +105,7 @@ class PurchaseProductOfferLogic extends BaseLogic 'buyer_nums' => $params['buyer_nums'], 'supplier_id' => $params['supplier_id'], 'price' => $params['purchase'], - 'outbound_price' => $params['outbound_price'], + 'outbound_price' => $params['outbound_price']??0, 'total_price' => $params['total_price'], 'pay_type' => $params['pay_type']??0, 'buyer_confirm' => 1, @@ -124,7 +124,38 @@ class PurchaseProductOfferLogic extends BaseLogic throw new BusinessException($e->getMessage()); } } - + /** + * @notes 设置批量采购信息 + * @param array $params + * @return bool + * @author admin + * @date 2024/08/14 15:06 + */ + public static function setBatchProcureInfo(array $params): bool + { + Db::startTrans(); + try { + $data=[]; + foreach($params['product_arr'] as $k=>$v){ + $data[]=[ + 'id'=>$v['id'], + 'total_price'=>$v['total_price'], + 'price'=>$v['purchase'], + 'buyer_nums'=>$v['buyer_nums'], + 'supplier_id'=>$params['supplier_id'], + 'outbound_price'=>0, + 'pay_type'=>$v['pay_type']??0, + 'buyer_confirm'=>1, + ]; + } + (new PurchaseProductOffer())->saveAll($data); + Db::commit(); + return true; + } catch (\Throwable $e) { + Db::rollback(); + throw new BusinessException($e->getMessage()); + } + } /** * 是否需采购 */