From a9d04bdf1809b8adbd173dfd944dd09b252edacc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=BB=BA=E7=82=8A?= <924182103@qq.com> Date: Wed, 4 Sep 2024 16:43:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=B2=9C=E8=8A=B12.0-=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/DailyStockRecordReport.php | 4 ++-- app/Http/Controllers/Goods/GoodsSkusController.php | 2 +- app/Http/Controllers/Supplier/PurchaseRecordController.php | 4 +++- ...24_08_29_151908_add_field_to_purchase_records_table.php | 7 ++++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Console/Commands/DailyStockRecordReport.php b/app/Console/Commands/DailyStockRecordReport.php index 5b4d358..0e8d625 100644 --- a/app/Console/Commands/DailyStockRecordReport.php +++ b/app/Console/Commands/DailyStockRecordReport.php @@ -66,13 +66,13 @@ class DailyStockRecordReport extends Command //统计采购单数量 $purchaseRecords = PurchaseRecords::query() ->select(DB::raw("sum(num) as arrived_today_num"), "external_sku_id") - ->whereBetween("date", [$startDateTime, $endDateTime]) + ->whereBetween("check_time", [$startDateTime, $endDateTime]) ->where("status",1) ->groupBy("external_sku_id")->get()->pluck(null, "external_sku_id")->toArray(); //统计报损数量 $lossRecords = LossRecords::query() ->select(DB::raw("sum(num) as loss_num"), "external_sku_id") - ->whereBetween("date", [$startDateTime, $endDateTime]) + ->whereBetween("created_at", [$startDateTime, $endDateTime]) ->groupBy("external_sku_id")->get()->pluck(null, "external_sku_id")->toArray(); Log::info("{$date}每日库存记录", ["orderItems" => $orderItems , "purchaseRecords" => $purchaseRecords, "lossRecords" => $lossRecords]); diff --git a/app/Http/Controllers/Goods/GoodsSkusController.php b/app/Http/Controllers/Goods/GoodsSkusController.php index 68d1dce..b6281fc 100644 --- a/app/Http/Controllers/Goods/GoodsSkusController.php +++ b/app/Http/Controllers/Goods/GoodsSkusController.php @@ -93,7 +93,7 @@ class GoodsSkusController extends Controller $day = DateTimeUtils::getToday(); $goodsSkus = (clone $builder)->filter() ->where('is_combination', 0) - ->orderByDesc('stock') + ->orderByDesc('id') ->pluck('stock', 'id') ->toArray(); $finalIds = []; diff --git a/app/Http/Controllers/Supplier/PurchaseRecordController.php b/app/Http/Controllers/Supplier/PurchaseRecordController.php index 42924c0..46ccf30 100644 --- a/app/Http/Controllers/Supplier/PurchaseRecordController.php +++ b/app/Http/Controllers/Supplier/PurchaseRecordController.php @@ -266,6 +266,7 @@ class PurchaseRecordController extends Controller 'purchaseOrders.*.id' => 'required|integer', 'purchaseOrders.*.status' => 'required|in:1,2']); $allUpdateIds = []; + $now = Carbon::now()->toDateTimeString(); foreach ($params['purchaseOrders'] as $v) { $purchaseRecordBuilder = PurchaseRecords::query()->with("goodsSku")->where("id", $v['id'])->first(); if (empty($purchaseRecordBuilder)) { @@ -276,7 +277,7 @@ class PurchaseRecordController extends Controller continue; } if ($purchaseRecords['status'] == $v['status']) { - throw new \Exception("id:{$v["id"]}状态未变更,请勿重复操作"); + continue; } DB::beginTransaction(); try { @@ -285,6 +286,7 @@ class PurchaseRecordController extends Controller $allUpdateIds = array_merge($allUpdateIds, $updateIds); } $purchaseRecordBuilder->status = $v['status']; + $purchaseRecordBuilder->check_time = $now; $purchaseRecordBuilder->save(); DB::commit(); } catch (\Exception $exception) { diff --git a/database/migrations/2024_08_29_151908_add_field_to_purchase_records_table.php b/database/migrations/2024_08_29_151908_add_field_to_purchase_records_table.php index acb5627..e4dc8b9 100644 --- a/database/migrations/2024_08_29_151908_add_field_to_purchase_records_table.php +++ b/database/migrations/2024_08_29_151908_add_field_to_purchase_records_table.php @@ -13,12 +13,13 @@ class AddFieldToPurchaseRecordsTable extends Migration */ public function up() { - if (Schema::hasColumns('purchase_records', ["arrived_time", "status"])) { + if (Schema::hasColumns('purchase_records', ["arrived_time", "status","check_time"])) { return; } Schema::table('purchase_records', function (Blueprint $table) { $table->dateTime('arrived_time')->nullable()->comment('到货时间'); - $table->integer('status')->default(0)->comment('采购单状态 0待审核 1已审核'); + $table->integer('status')->default(0)->comment('采购单状态 0待审核 1已审核 2审核失败'); + $table->dateTime('check_time')->nullable()->comment('审核时间');; }); @@ -35,7 +36,7 @@ class AddFieldToPurchaseRecordsTable extends Migration // $table->dropColumn('arrived_time'); $table->dropColumn('status'); - + $table->dropColumn('check_time'); }); }