6
0
Fork 0
panliang 2023-02-27 14:26:23 +08:00
parent a819f64dd5
commit aa00a8d82d
5 changed files with 11 additions and 8 deletions

View File

@ -18,7 +18,8 @@ class RowAddStock extends RowAction
if ($model->status) {
return $this->response()->error('已经确认过了');
}
$type = (new Administrator())->getMorphClass();
$admin = $model->adminUser;
$type = $admin->getMorphClass();
foreach($model->productSkus()->get() as $item) {
$amount = $item->pivot?->amount;
if ($amount) {
@ -36,8 +37,8 @@ class RowAddStock extends RowAction
}
array_push($list, [
'operator_type' => $type,
'operator_id' => $model->admin_user_id,
'operator_name' => $model->adminUser->name,
'operator_id' => $admin->id,
'operator_name' => $admin->name,
'amount' => $amount,
'product_sku_id' => $item->id,
'balance' => $balance,

View File

@ -66,8 +66,9 @@ class OrderPackage extends Form implements LazyRenderable
'amount' => $product->pivot->amount - $amount
]);
$store->stockLogs()->create([
'operator_type' => get_class($operator),
'operator_type' => $operator->getMorphClass(),
'operator_id' => $operator->id,
'operator_name' => $operator->name,
'source_type' => Order::class,
'source_id' => $order->id,
'amount' => 0-$amount,

View File

@ -18,8 +18,8 @@ class OrderAutoComplete
public function handle($event)
{
$order = $event->order;
// 门店, 桌号订单
if ($order->source_type === Desk::class && $store = $order->store) {
// 门店
if ($store = $order->store) {
$order = Order::find($order->id);
$package = (new \App\Admin\Services\OrderPackageService())->createAll($order);

View File

@ -71,7 +71,8 @@ class OrderPackage
]);
// 添加店铺发货记录
$store->stockLogs()->create([
'operator_type' => $inviter ? get_class($inviter) : '',
'operator_type' => $inviter ? $inviter->getMorphClass() : '',
'operator_name' => $inviter? $inviter->phone : '',
'operator_id' => $inviter ? $inviter->id : '',
'source_type' => Order::class,
'source_id' => $order->id,

View File

@ -19,7 +19,7 @@ class EventServiceProvider extends ServiceProvider
\App\Events\OrderPaid::class => [
\App\Listeners\OrderPaidNotify::class,
\App\Listeners\SendCoupons::class,
\App\Listeners\OrderPackage::class,
// \App\Listeners\OrderPackage::class,
\App\Listeners\OrderDistribute::class,
\App\Listeners\OrderPrint::class,
\App\Listeners\OrderAutoComplete::class,