|
@@ -76,13 +76,14 @@ class CardService
|
|
|
return json_success('success');
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Notes: 根据卡批次修改卡信息
|
|
|
* User: ZhouBenXu
|
|
|
* DateTime: 2024/6/27 下午5:03
|
|
|
* @param $join_card_batch_id
|
|
|
* @param $save
|
|
|
- * @return \support\Response
|
|
|
+ * @return string|\support\Response|true
|
|
|
*/
|
|
|
public static function saveCardByCardBatchId($join_card_batch_id, $save)
|
|
|
{
|
|
@@ -101,25 +102,25 @@ class CardService
|
|
|
} 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);
|
|
|
+ $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('数据写入失败~');
|
|
|
+ return false;
|
|
|
} catch (BusinessException $e) {
|
|
|
Db::rollBack();
|
|
|
dump($e->getFile() . '(' . $e->getLine() . '):' . $e->getMessage());
|
|
|
- return json_fail($e->getMessage());
|
|
|
+ return $e->getMessage();
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
dump($e->getTrace());
|
|
|
- return json_fail('数据写入失败~');
|
|
|
+ return false;
|
|
|
}
|
|
|
_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减少
|
|
|
$model->card_validtimes = 0;
|
|
|
} 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) {
|
|
|
- $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();
|
|
|
Db::commit();
|