|
|
@@ -35,8 +35,17 @@ class OrderItemController extends BaseController
|
|
|
if (floatval($order->actPrice) != 0) {
|
|
|
util::fail('订单金额不是0');
|
|
|
}
|
|
|
- OrderItemClass::bookDelItem($order, $smallId);
|
|
|
- util::complete('删除成功');
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderItemClass::bookDelItem($order, $smallId);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('删除成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("删除出错了:" . $e->getMessage());
|
|
|
+ util::fail('删除出错了');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//添加花材
|
|
|
@@ -72,8 +81,17 @@ class OrderItemController extends BaseController
|
|
|
}
|
|
|
$new[$id] = ['num' => $num, 'productId' => $id];
|
|
|
}
|
|
|
- OrderItemClass::bookAddItem($order, $new);
|
|
|
- util::complete('添加成功');
|
|
|
+ $connection = Yii::$app->db;//事务处理
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderItemClass::bookAddItem($order, $new);
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('添加成功');
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("添加出错了:" . $e->getMessage());
|
|
|
+ util::fail('添加出错了');
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//赠送花材 ssh 20230411
|