|
@@ -317,4 +317,47 @@ class CardService
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Notes: 储值卡修改
|
|
|
|
+ * User: ZhouBenXu
|
|
|
|
+ * DateTime: 2024/6/28 下午3:17
|
|
|
|
+ * @param $params
|
|
|
|
+ * @return \support\Response
|
|
|
|
+ */
|
|
|
|
+ public static function save($params)
|
|
|
|
+ {
|
|
|
|
+ Db::beginTransaction();
|
|
|
|
+ try {
|
|
|
|
+ $cardBatchModel = new Card();
|
|
|
|
+ $model = $cardBatchModel::find($params['card_id']);
|
|
|
|
+ $model->card_name = $params['card_name'];
|
|
|
|
+ $model->join_card_member_id = $params['join_card_member_id'];
|
|
|
|
+ $params['card_status'] && $params['card_status'] = $model->card_status = Card::CARD_STATUS[$params['card_status']]; // 储值卡状态
|
|
|
|
+ if ($params['validtimes_status'] == 0) { // 卡批次有效期 0 永久天 1 增加 2减少
|
|
|
|
+ $model->card_validtimes = 0;
|
|
|
|
+ } elseif ($params['validtimes_status'] == 1) {
|
|
|
|
+ $model->card_validtimes = Db::raw('card_validtimes+' . $params['card_batch_validtimes'] * 86400);
|
|
|
|
+ } elseif ($params['validtimes_status'] == 2) {
|
|
|
|
+ $model->card_validtimes = Db::raw('card_validtimes-' . $params['card_batch_validtimes'] * 86400);
|
|
|
|
+ }
|
|
|
|
+ $model->save();
|
|
|
|
+ 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("修改储值卡", "储值卡id【" . $params['card_id'] . "】");
|
|
|
|
+ return json_success('success');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|