6
0
Fork 0

app login

base
panliang 2026-04-22 18:38:57 +08:00
parent 1c2c7107b9
commit 26165fb7f1
2 changed files with 5 additions and 5 deletions

View File

@ -61,9 +61,10 @@ class OrderPackage extends Form implements LazyRenderable
if ($product->pivot->amount - $amount < 0) { if ($product->pivot->amount - $amount < 0) {
throw new BizException('店铺的 ' . $product->name .' 库存不足'); throw new BizException('店铺的 ' . $product->name .' 库存不足');
} }
$balance = $product->pivot->amount - $amount;
$store->productSkus()->updateExistingPivot($product->id, [ $store->productSkus()->updateExistingPivot($product->id, [
'amount' => $product->pivot->amount - $amount 'amount' => $balance
]); ]);
$store->stockLogs()->create([ $store->stockLogs()->create([
'operator_type' => $operator->getMorphClass(), 'operator_type' => $operator->getMorphClass(),
@ -72,6 +73,7 @@ class OrderPackage extends Form implements LazyRenderable
'source_type' => Order::class, 'source_type' => Order::class,
'source_id' => $order->id, 'source_id' => $order->id,
'amount' => 0-$amount, 'amount' => 0-$amount,
'balance' => $balance,
'product_sku_id' => $product->id, 'product_sku_id' => $product->id,
'remarks' => '后台发货', 'remarks' => '后台发货',
'tag_id' => $tag_id, 'tag_id' => $tag_id,

View File

@ -35,8 +35,6 @@ class MiniprogramController extends Controller
if (!$openid) { if (!$openid) {
throw new BizException('授权失败, 未找到 openid'); throw new BizException('授权失败, 未找到 openid');
} }
$time = now();
$ip = $request->realIp();
try { try {
DB::beginTransaction(); DB::beginTransaction();
@ -127,9 +125,9 @@ class MiniprogramController extends Controller
* *
* @throws \App\Exceptions\BizException * @throws \App\Exceptions\BizException
*/ */
protected function findUserByCode(string $code): ?User protected function findUserByCode($code): ?User
{ {
if ($code === '') { if (!$code) {
return null; return null;
} }