From a43f3a8a72f9d7e4641b41bd62d6d81c83b9b980 Mon Sep 17 00:00:00 2001 From: betaxab Date: Sun, 7 Aug 2022 20:46:34 +0800 Subject: [PATCH] createOrder: Use uppercase chars for order numbers --- app/Service/OrderProcessService.php | 2 +- database/factories/OrderFactory.php | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Service/OrderProcessService.php b/app/Service/OrderProcessService.php index 550ccc86..46b489a6 100644 --- a/app/Service/OrderProcessService.php +++ b/app/Service/OrderProcessService.php @@ -312,7 +312,7 @@ public function createOrder(): Order try { $order = new Order(); // 生成订单号 - $order->order_sn = Str::random(16); + $order->order_sn = strtoupper(Str::random(16)); // 设置商品 $order->goods_id = $this->goods->id; // 标题 diff --git a/database/factories/OrderFactory.php b/database/factories/OrderFactory.php index c80a806e..2096927b 100644 --- a/database/factories/OrderFactory.php +++ b/database/factories/OrderFactory.php @@ -4,10 +4,11 @@ use App\Model; use Faker\Generator as Faker; +use Illuminate\Support\Str; $factory->define(\App\Models\Order::class, function (Faker $faker) { return [ - 'order_sn' => \Illuminate\Support\Str::random(12), + 'order_sn' => strtoupper(Str::random(12)), 'goods_id' => rand(1, 3), 'coupon_id' => rand(1, 3), 'title' => $faker->words(3, true), @@ -23,7 +24,7 @@ 'info' => $faker->words(3, true), 'pay_id' => rand(1, 20), 'buy_ip' => $faker->ipv4, - 'trade_no' => \Illuminate\Support\Str::random(12), + 'trade_no' => strtoupper(Str::random(12)), 'status' => rand(1, 5), 'created_at' => $faker->dateTimeBetween('-7 days', 'now', 'PRC'), 'updated_at' => $faker->dateTimeBetween('-7 days', 'now', 'PRC'),