|
@@ -76,13 +76,14 @@ class CardService
|
|
return json_success('success');
|
|
return json_success('success');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Notes: 根据卡批次修改卡信息
|
|
* Notes: 根据卡批次修改卡信息
|
|
* User: ZhouBenXu
|
|
* User: ZhouBenXu
|
|
* DateTime: 2024/6/27 下午5:03
|
|
* DateTime: 2024/6/27 下午5:03
|
|
* @param $join_card_batch_id
|
|
* @param $join_card_batch_id
|
|
* @param $save
|
|
* @param $save
|
|
- * @return \support\Response
|
|
|
|
|
|
+ * @return string|\support\Response|true
|
|
*/
|
|
*/
|
|
public static function saveCardByCardBatchId($join_card_batch_id, $save)
|
|
public static function saveCardByCardBatchId($join_card_batch_id, $save)
|
|
{
|
|
{
|
|
@@ -101,25 +102,25 @@ class CardService
|
|
} elseif ($save['validtimes_status'] == 1) {
|
|
} elseif ($save['validtimes_status'] == 1) {
|
|
$data['card_validtimes'] = Db::raw('card_validtimes+' . $save['card_batch_validtimes'] * 86400);
|
|
$data['card_validtimes'] = Db::raw('card_validtimes+' . $save['card_batch_validtimes'] * 86400);
|
|
} elseif ($save['validtimes_status'] == 2) {
|
|
} elseif ($save['validtimes_status'] == 2) {
|
|
- $data['card_validtimes'] = Db::raw('card_validtimes-' . $save['card_batch_validtimes'] * 86400);
|
|
|
|
|
|
+ $data['card_validtimes'] = Db::raw('card_validtimes-' . $save['card_batch_validtimes'] * 86400);;
|
|
}
|
|
}
|
|
$model->where('join_card_batch_id', $join_card_batch_id)->update($data);
|
|
$model->where('join_card_batch_id', $join_card_batch_id)->update($data);
|
|
Db::commit();
|
|
Db::commit();
|
|
} catch (\PDOException $e) {
|
|
} catch (\PDOException $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
- return json_fail('数据写入失败~');
|
|
|
|
|
|
+ return false;
|
|
} catch (BusinessException $e) {
|
|
} catch (BusinessException $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
- return json_fail($e->getMessage());
|
|
|
|
|
|
+ return $e->getMessage();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
dump($e->getTrace());
|
|
dump($e->getTrace());
|
|
- return json_fail('数据写入失败~');
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
_syslog("修改储值卡", "卡批次名称【" . $save['card_batch_name'] . "】");
|
|
_syslog("修改储值卡", "卡批次名称【" . $save['card_batch_name'] . "】");
|
|
- return json_success('success');
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -336,9 +337,14 @@ class CardService
|
|
if ($params['validtimes_status'] == 0) { // 卡批次有效期 0 永久天 1 增加 2减少
|
|
if ($params['validtimes_status'] == 0) { // 卡批次有效期 0 永久天 1 增加 2减少
|
|
$model->card_validtimes = 0;
|
|
$model->card_validtimes = 0;
|
|
} elseif ($params['validtimes_status'] == 1) {
|
|
} elseif ($params['validtimes_status'] == 1) {
|
|
- $model->card_validtimes = Db::raw('card_validtimes+' . $params['card_batch_validtimes'] * 86400);
|
|
|
|
|
|
+ $model->card_validtimes = baadd($model->card_validtimes + $params['card_batch_validtimes'] * 86400);
|
|
} elseif ($params['validtimes_status'] == 2) {
|
|
} elseif ($params['validtimes_status'] == 2) {
|
|
- $model->card_validtimes = Db::raw('card_validtimes-' . $params['card_batch_validtimes'] * 86400);
|
|
|
|
|
|
+ $card_validtimes = bcsub($model->card_validtimes - $params['card_batch_validtimes'] * 86400);
|
|
|
|
+ // 修改后的有效期不允许小于当前时间
|
|
|
|
+ if (!$card_validtimes <= time()) {
|
|
|
|
+ return json_fail('储值卡有效期必须大于当前时间~');
|
|
|
|
+ }
|
|
|
|
+ $model->card_validtimes = $card_validtimes;
|
|
}
|
|
}
|
|
$model->save();
|
|
$model->save();
|
|
Db::commit();
|
|
Db::commit();
|