Fecmall 使用yii事务,下面是详细代码
对函数Yii::$service->wallet->cash->customerCash($customerId, $name, $phone, $paymentMethod, $paymentNo, $cashWalletAmount
进行事务处理
$innerTransaction = Yii::$app->db->beginTransaction();
try {
if (!Yii::$service->wallet->cash->customerCash($customerId, $name, $phone, $paymentMethod, $paymentNo, $cashWalletAmount)) {
throw new \Exception('audit return accept fail');
}
$innerTransaction->commit();
} catch (\Exception $e) {
Yii::$service->helper->errors->add($e->getMessage());
$innerTransaction->rollBack();
return false;
}