virtual_order_optional_package_cards
This commit is contained in:
parent
f62c71a512
commit
e9b2c38179
@ -83,17 +83,19 @@ class AddedOrderSync extends Command
|
|||||||
|
|
||||||
$virtualTable = str_replace('real_', 'virtual_', $table);
|
$virtualTable = str_replace('real_', 'virtual_', $table);
|
||||||
|
|
||||||
$starttime = $this->datetime->copy()->startOfMonth()->startOfDay();
|
if (!in_array($virtualTable, ['virtual_order_optional_package_cards', 'virtual_order_additional_package_cards'])) {
|
||||||
$endtime = $this->datetime->copy()->endOfMonth()->endOfDay();
|
$starttime = $this->datetime->copy()->startOfMonth()->startOfDay();
|
||||||
|
$endtime = $this->datetime->copy()->endOfMonth()->endOfDay();
|
||||||
|
|
||||||
$orders = DB::table($virtualTable)->selectRaw('sim,MAX(order_id)')
|
$orders = DB::table($virtualTable)->selectRaw('sim,MAX(order_id)')
|
||||||
->where('created_at', '>=', $starttime)
|
->where('created_at', '>=', $starttime)
|
||||||
->where('created_at', '<=', $endtime)
|
->where('created_at', '<=', $endtime)
|
||||||
->whereIn('sim', array_pluck($data, 'sim'))
|
->whereIn('sim', array_pluck($data, 'sim'))
|
||||||
->groupBy('sim')->get()->pluck('order_id', 'sim');
|
->groupBy('sim')->get()->pluck('order_id', 'sim');
|
||||||
|
|
||||||
foreach ($data as &$value) {
|
foreach ($data as &$value) {
|
||||||
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
|
$value['virtual_order_id'] = $orders[$value['sim']] ?? 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::table($table)->upsert($data, ['sim', 'order_id'], true);
|
DB::table($table)->upsert($data, ['sim', 'order_id'], true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user