order
parent
aa00a8d82d
commit
e36f67a189
|
|
@ -5,7 +5,7 @@ namespace App\Listeners;
|
|||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use App\Models\Store\{Desk, ProductSku};
|
||||
use App\Models\{Tag, Order};
|
||||
use App\Models\{Tag, Order, OrderPre};
|
||||
|
||||
/**
|
||||
* 自动完成订单
|
||||
|
|
@ -21,8 +21,18 @@ class OrderAutoComplete
|
|||
// 门店
|
||||
if ($store = $order->store) {
|
||||
$order = Order::find($order->id);
|
||||
|
||||
// 发货
|
||||
$package = (new \App\Admin\Services\OrderPackageService())->createAll($order);
|
||||
|
||||
// 操作人
|
||||
$operator = '';
|
||||
$remarks = '桌号订单自动提货';
|
||||
if ($order->source_type == OrderPre::class) {
|
||||
$operator = $order->inviter;
|
||||
$remarks = '店铺提货(自动)';
|
||||
}
|
||||
|
||||
// 添加门店库存记录
|
||||
foreach($package->orderProducts as $item) {
|
||||
$sku = ProductSku::where('store_id', $store->id)->where('product_sku_id', $item->sku_id)->first();
|
||||
|
|
@ -41,7 +51,9 @@ class OrderAutoComplete
|
|||
'source_id' => $order->id,
|
||||
'source_type' => $order->getMorphClass(),
|
||||
'tag_id' => $tag->id,
|
||||
'operator_name' => '积趣吧台',
|
||||
'operator_type' => $operator ? $operator->getMorphClass() : null,
|
||||
'operator_id' => $operator ? $operator->id : null,
|
||||
'operator_name' => $operator ? $operator->phone : '积趣吧台',
|
||||
]);
|
||||
|
||||
$sku->update(['amount' => $balance]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue