Skip to content

Commit

Permalink
dtb_shippingのデッドロックを回避
Browse files Browse the repository at this point in the history
  • Loading branch information
nobuhiko committed Mar 18, 2024
1 parent 62b8b9f commit 6be4f90
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions data/class/helper/SC_Helper_Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,10 @@ public static function registerShipping($order_id, $arrParams, $convert_shipping
$objQuery = SC_Query_Ex::getSingletonInstance();
$table = 'dtb_shipping';
$where = 'order_id = ?';
$objQuery->delete($table, $where, array($order_id));

if ($objQuery->count($table, $where, [$order_id]) > 0) {
$objQuery->delete($table, $where, array($order_id));
}

foreach ($arrParams as $key => $arrShipping) {
$arrValues = $objQuery->extractOnlyColsOf($table, $arrShipping);
Expand Down Expand Up @@ -709,6 +712,21 @@ public static function registerShipping($order_id, $arrParams, $convert_shipping

$objQuery->insert($table, $arrValues);
}

$sql_sub = <<< __EOS__
SELECT deliv_time
FROM dtb_delivtime
WHERE time_id = dtb_shipping.time_id
AND deliv_id = (SELECT dtb_order.deliv_id FROM dtb_order WHERE order_id = dtb_shipping.order_id)
__EOS__;
$objQuery->update(
'dtb_shipping',
array(),
$where,
array($order_id),
array('shipping_time' => "($sql_sub)")
);

}

/**
Expand Down Expand Up @@ -1267,20 +1285,6 @@ public static function sfUpdateOrderNameCol($order_id, $temp_table = false)
} else {
$tgt_table = 'dtb_order';
$sql_where = 'order_id = ?';

$sql_sub = <<< __EOS__
SELECT deliv_time
FROM dtb_delivtime
WHERE time_id = dtb_shipping.time_id
AND deliv_id = (SELECT dtb_order.deliv_id FROM dtb_order WHERE order_id = dtb_shipping.order_id)
__EOS__;
$objQuery->update(
'dtb_shipping',
array(),
$sql_where,
array($order_id),
array('shipping_time' => "($sql_sub)")
);
}

$objQuery->update(
Expand Down

0 comments on commit 6be4f90

Please sign in to comment.