4
0
Fork 0
panliang 2022-10-08 13:59:44 +08:00
parent eea0c744c0
commit a197f7254d
2 changed files with 6 additions and 4 deletions

View File

@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Rules\Enum;
use Peidikeji\Order\Enums\PayStatus;
use Peidikeji\Order\Enums\PayWay;
use Peidikeji\Order\Enums\ShipStatus;
@ -19,7 +18,6 @@ use Peidikeji\Order\Http\Resources\OrderResource;
use Peidikeji\Order\Http\Resources\OrderShipResouce;
use Peidikeji\Order\OrderService;
use Peidikeji\Order\OrderStore;
use Peidikeji\User\Models\User;
class OrderController extends Controller
{

View File

@ -72,7 +72,7 @@ class OrderStore
foreach ($params as $item) {
$goods = $goodsList->firstWhere('id', $item['id']);
if (!$goods) {
throw new OrderException('商品未上架');
throw new OrderException('商品不存在');
}
if (! data_get($goods, 'on_sale')) {
throw new OrderException($goods->name.' 未上架');
@ -91,7 +91,11 @@ class OrderStore
'amount' => data_get($item, 'amount', 1),
'money' => 0,
];
if (data_get($item, 'spec')) {
$spec = data_get($item, 'spec');
if ($goods->spec) {
if (!$spec) {
throw new OrderException('请选择 '.$goods->name.' 的规格');
}
$sku = $goods->skus()->jsonArray($item['spec'])->first();
if (! $sku) {
throw new OrderException($goods->name.' 规格不存在');