From 465e8823198a76b34ceb817513711dbe40ae354e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 14 Oct 2024 12:49:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E9=87=91=E9=A2=9D=E8=AE=A1=E7=AE=97=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修正入库订单的总金额、已完成金额和待完成金额的计算方式 - 使用数据库查询替代手动输入金额,提高数据准确性和逻辑性 - 优化代码可维护性,减少手动计算引入的潜在错误 --- .../BeforehandOrderCartInfoLogic.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php index 52f4095ed..8ef7314e9 100644 --- a/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php +++ b/app/admin/logic/beforehand_order_cart_info/BeforehandOrderCartInfoLogic.php @@ -131,6 +131,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic throw new BusinessException('请勿重复入库'); } $offer_list = PurchaseProductOffer::where(['order_id' => $params['bhoid'], 'is_storage' => 0])->select(); + $total_price= PurchaseProductOffer::where(['order_id' => $params['bhoid']])->sum('total_price'); + $completed_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>1])->sum('total_price'); + $outstanding_amount= PurchaseProductOffer::where(['order_id' => $params['bhoid'],'pay_type'=>2])->sum('total_price'); Db::startTrans(); try { $code = getNewOrderId('RK'); @@ -142,9 +145,9 @@ class BeforehandOrderCartInfoLogic extends BaseLogic 'batch' => 0, 'code' => $code, 'mark' => $params['remark'] ?? '', - 'total_price' => $params['total_price'], - 'completed_amount' => $params['completed_amount'] ?? 0, - 'outstanding_amount' => $params['outstanding_amount'] ?? 0, + 'total_price' => $total_price, + 'completed_amount' => $completed_amount, + 'outstanding_amount' => $outstanding_amount, ]; $res = WarehouseOrder::create($arr); foreach ($offer_list as $k => $v) { From bb0bc0c29a15bc36d17b9f578a91087f4b68e930 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Mon, 14 Oct 2024 14:51:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E5=90=8D=E7=A7=B0=E5=92=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E4=BC=98=E5=8C=96=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=8A=A5=E4=BB=B7=E5=8D=95=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在预订单购物详情表中添加商品单位名称字段 - 实现预订单商品列表的导出功能 - 在采购报价单列表中添加顶级分类名称字段 --- .../BeforehandOrderCartInfoLists.php | 35 ++++++++++++++++++- .../PurchaseProductOfferLists.php | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php index 29e254235..90513d2ac 100644 --- a/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php +++ b/app/admin/lists/beforehand_order_cart_info/BeforehandOrderCartInfoLists.php @@ -9,13 +9,15 @@ use app\common\lists\ListsSearchInterface; use app\common\model\purchase_product_offer\PurchaseProductOffer; use app\common\model\store_product\StoreProduct; use app\common\model\warehouse_product_storege\WarehouseProductStorege; +use app\common\lists\ListsExcelInterface; +use app\common\model\store_product_unit\StoreProductUnit; /** * 预订单购物详情表列表 * Class BeforehandOrderCartInfoLists * @package app\admin\listsbeforehand_order_cart_info */ -class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface +class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchInterface,ListsExcelInterface { @@ -50,6 +52,7 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe ->order(['id' => 'desc']) ->select()->each(function($item){ $find=StoreProduct::where('id',$item['product_id'])->field('store_name,image,unit')->withTrashed()->find(); + $item->unit_name=StoreProductUnit::where('id',$find->unit)->value('name'); $item['warehouse_stock']=WarehouseProductStorege::where('product_id',$item['product_id'])->value('nums')??0; $item['store_name']=$find['store_name']; $item['image']=$find['image']; @@ -79,4 +82,34 @@ class BeforehandOrderCartInfoLists extends BaseAdminDataLists implements ListsSe return BeforehandOrderCartInfo::where($this->searchWhere)->count(); } + /** + * @notes 导出文件名 + * @return string + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setFileName(): string + { + return '预订单商品列表'; + } + + + /** + * @notes 导出字段 + * @return string[] + * @author 乔峰 + * @date 2022/11/24 16:17 + */ + public function setExcelFields(): array + { + $data=[ + 'store_name' => '商品名称', + 'warehouse_stock' => '仓库数量', + 'cart_num' => '需求数量', + 'unit_name' => '单位', + 'price' => '单价', + 'total_price' => '总价', + ]; + return $data; + } } \ No newline at end of file diff --git a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php index 1bbb9e654..f292d17ee 100644 --- a/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php +++ b/app/admin/lists/purchase_product_offer/PurchaseProductOfferLists.php @@ -58,6 +58,7 @@ class PurchaseProductOfferLists extends BaseAdminDataLists implements ListsSearc $item->image=$find->image; $item->unit_name=StoreProductUnit::where('id',$item->unit)->value('name'); $item->cate_name=StoreCategory::where('id',$find->cate_id)->value('name'); + $item->top_cate_name=StoreCategory::where('id',$find->top_cate_id)->value('name'); if($item->is_buyer==1){ $item->is_buyer_name='需要采购'; }elseif($item->is_buyer==-1){