insert($insertData); Db::commit(); } catch (\PDOException $e) { Db::rollBack(); dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage()); return json_fail('数据写入失败~'); } catch (BusinessException $e) { Db::rollBack(); dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage()); return json_fail($e->getMessage()); } catch (\Exception $e) { Db::rollBack(); dump($e->getTrace()); return json_fail('数据写入失败~'); } _syslog("添加储值卡", "卡批次名称【" . $card_info['card_batch_name'] . "】", $insertData); return json_success('success'); } /** * Notes: 根据卡批次修改卡信息 * User: ZhouBenXu * DateTime: 2024/6/27 下午5:03 * @param $join_card_batch_id * @param $save * @return \support\Response */ public static function saveCardByCardBatchId($join_card_batch_id, $save) { Db::beginTransaction(); try { $model = new Card(); $data['card_name'] = $save['card_batch_name']; $card_status = array_values($model::CARD_STATUS); if (in_array($save['card_batch_status'], $card_status)) { $data['card_status'] = $save['card_batch_status']; // 卡批次状态 } if ($save['validtimes_status'] == 0) { // 卡批次有效期 0 永久天 1 增加 2减少 $data['card_validtimes'] = 0; } elseif ($save['validtimes_status'] == 1) { $data['card_validtimes'] = Db::raw('card_validtimes+' . $save['card_batch_validtimes'] * 86400); } elseif ($save['validtimes_status'] == 2) { $data['card_validtimes'] = Db::raw('card_validtimes-' . $save['card_batch_validtimes'] * 86400); } $model->where('join_card_batch_id', $join_card_batch_id)->update($data); Db::commit(); } catch (\PDOException $e) { Db::rollBack(); dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage()); return json_fail('数据写入失败~'); } catch (BusinessException $e) { Db::rollBack(); dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage()); return json_fail($e->getMessage()); } catch (\Exception $e) { Db::rollBack(); dump($e->getTrace()); return json_fail('数据写入失败~'); } _syslog("修改储值卡", "卡批次名称【" . $save['card_batch_name'] . "】"); return json_success('success'); } }