鲜花2.0-采购流程变更

This commit is contained in:
杨建炊 2024-09-04 16:43:15 +08:00
parent 7fb90a77f9
commit a9d04bdf18
4 changed files with 10 additions and 7 deletions

View File

@ -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]);

View File

@ -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 = [];

View File

@ -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) {

View File

@ -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');
});
}