|
@@ -41,7 +41,6 @@ class CardBatchService
|
|
$model->card_batch_serial_begin = $params['card_batch_serial_begin']; // 卡批次序号起始
|
|
$model->card_batch_serial_begin = $params['card_batch_serial_begin']; // 卡批次序号起始
|
|
$model->card_batch_serial_end = $params['card_batch_serial_end']; // 卡批次序号结束
|
|
$model->card_batch_serial_end = $params['card_batch_serial_end']; // 卡批次序号结束
|
|
$model->card_batch_amount = $params['card_batch_amount']; // 卡批次面额
|
|
$model->card_batch_amount = $params['card_batch_amount']; // 卡批次面额
|
|
- $model->card_batch_added = $params['card_batch_added']; // 卡批次增值赠送
|
|
|
|
$model->card_batch_validtimes = $params['card_batch_validtimes']; // 卡批次有效期 0=永久 天
|
|
$model->card_batch_validtimes = $params['card_batch_validtimes']; // 卡批次有效期 0=永久 天
|
|
$model->card_batch_json = $params['card_batch_json'] ?? "{}"; // 卡JSON {}
|
|
$model->card_batch_json = $params['card_batch_json'] ?? "{}"; // 卡JSON {}
|
|
$model->card_batch_remark = $params['card_batch_remark'] ?? ""; // 备注
|
|
$model->card_batch_remark = $params['card_batch_remark'] ?? ""; // 备注
|
|
@@ -50,7 +49,36 @@ class CardBatchService
|
|
if ($model->save()) {
|
|
if ($model->save()) {
|
|
$join_card_batch_id = $model->card_batch_id;
|
|
$join_card_batch_id = $model->card_batch_id;
|
|
// 添加卡信息
|
|
// 添加卡信息
|
|
- CardService::insert($join_card_batch_id, $params);
|
|
|
|
|
|
+// CardService::insert($join_card_batch_id, $params);
|
|
|
|
+
|
|
|
|
+ $cardModel = new Card();
|
|
|
|
+ // 生成包含序号数组
|
|
|
|
+ $card_sort = range($params['card_batch_serial_begin'], $params['card_batch_serial_end']);
|
|
|
|
+ $insertData = [];
|
|
|
|
+ if ($params['card_batch_validtimes'] != 0) { // 卡批次有效期 0=永久 天
|
|
|
|
+ $params['card_batch_validtimes'] = (strtotime(date('Y-m-d 00:00:00')) + $params['card_batch_validtimes'] * 86400) - 1;
|
|
|
|
+ }
|
|
|
|
+ foreach ($card_sort as $value) {
|
|
|
|
+ $info['join_card_batch_id'] = $join_card_batch_id;
|
|
|
|
+ $info['join_card_category_id'] = $params['join_card_batch_category_id'];
|
|
|
|
+ $info['card_status'] = "INIT";
|
|
|
|
+ $info['card_category'] = $params['card_batch_category'] ?? "NORMAL"; // 批次类型 NORMAL
|
|
|
|
+ $info['card_name'] = $params['card_batch_name'];
|
|
|
|
+ $info['card_prefix'] = $params['card_batch_prefix'];
|
|
|
|
+ $info['card_suffix'] = $params['card_batch_suffix'];
|
|
|
|
+ $info['card_pass'] = mt_rand(100000, 999999);// 卡密
|
|
|
|
+ $info['card_amount'] = $params['card_batch_amount'];
|
|
|
|
+ $info['card_validtimes'] = $params['card_batch_validtimes']; // 卡批次有效期 0=永久 天
|
|
|
|
+ $info['card_json'] = "{}";
|
|
|
|
+ $info['card_assign_json'] = "{}";
|
|
|
|
+ $info['card_process_json'] = "{}";
|
|
|
|
+ $info['card_sort'] = $value;
|
|
|
|
+ $info['card_remark'] = $params['card_batch_remark'] ?? ""; // 备注
|
|
|
|
+ $info['card_extend_json'] = "{}";
|
|
|
|
+ $info['card_addtimes'] = time();
|
|
|
|
+ $insertData[] = $info;
|
|
|
|
+ }
|
|
|
|
+ $cardModel->insert($insertData);
|
|
}
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
@@ -86,6 +114,7 @@ class CardBatchService
|
|
$cardBatchModel = new CardBatch();
|
|
$cardBatchModel = new CardBatch();
|
|
$model = $cardBatchModel::find($params['card_batch_id']);
|
|
$model = $cardBatchModel::find($params['card_batch_id']);
|
|
$model->card_batch_name = $params['card_batch_name'];
|
|
$model->card_batch_name = $params['card_batch_name'];
|
|
|
|
+ $model->card_batch_remark = $params['card_batch_remark'] ?? "";
|
|
$params['card_batch_status'] = $model->card_batch_status = $params['card_batch_status']; // 批次状态
|
|
$params['card_batch_status'] = $model->card_batch_status = $params['card_batch_status']; // 批次状态
|
|
if ($params['validtimes_status'] == 0) {
|
|
if ($params['validtimes_status'] == 0) {
|
|
$model->card_batch_validtimes = 0; // 卡批次有效期 0=永久 天
|
|
$model->card_batch_validtimes = 0; // 卡批次有效期 0=永久 天
|
|
@@ -99,7 +128,7 @@ class CardBatchService
|
|
$model->card_batch_validtimes = bcsub($model->card_batch_validtimes, $params['card_batch_validtimes']); // 卡批次有效期 0=永久 天
|
|
$model->card_batch_validtimes = bcsub($model->card_batch_validtimes, $params['card_batch_validtimes']); // 卡批次有效期 0=永久 天
|
|
}
|
|
}
|
|
if ($model->save()) {
|
|
if ($model->save()) {
|
|
- // 修改卡批次下面的卡信息
|
|
|
|
|
|
+ // 修改卡批次下面的卡信息
|
|
// CardService::saveCardByCardBatchId($params['card_batch_id'], $params);
|
|
// CardService::saveCardByCardBatchId($params['card_batch_id'], $params);
|
|
// 修改卡批次下面的卡信息
|
|
// 修改卡批次下面的卡信息
|
|
$model = new Card();
|
|
$model = new Card();
|
|
@@ -255,8 +284,13 @@ class CardBatchService
|
|
$card_status_total = Db::select($sql);
|
|
$card_status_total = Db::select($sql);
|
|
$card_status_total = array_column($card_status_total, null, 'join_card_batch_id');
|
|
$card_status_total = array_column($card_status_total, null, 'join_card_batch_id');
|
|
foreach ($rows as $key => &$value) {
|
|
foreach ($rows as $key => &$value) {
|
|
- $value['card_batch_status_value'] = $value['card_batch_status'];
|
|
|
|
- $value['card_batch_status'] = $cardBatchModel::CARD_BATCH_STATUS[$value['card_batch_status']];
|
|
|
|
|
|
+ $value['card_batch_status_value'] = $cardBatchModel::CARD_BATCH_STATUS[$value['card_batch_status']];
|
|
|
|
+ if ($value['card_batch_validtimes'] == 0) {
|
|
|
|
+ $value['card_batch_validtimes_value'] = "永久";
|
|
|
|
+ } else {
|
|
|
|
+ $value['card_batch_validtimes_value'] = $value['card_batch_validtimes'];
|
|
|
|
+ }
|
|
|
|
+
|
|
!empty($value['card_batch_json']) && $value['card_batch_json'] = json_decode($value['card_batch_json'], true);
|
|
!empty($value['card_batch_json']) && $value['card_batch_json'] = json_decode($value['card_batch_json'], true);
|
|
!empty($value['card_batch_extend_json']) && $value['card_batch_extend_json'] = json_decode($value['card_batch_extend_json'], true);
|
|
!empty($value['card_batch_extend_json']) && $value['card_batch_extend_json'] = json_decode($value['card_batch_extend_json'], true);
|
|
// 合并储值卡面值以及状态数量
|
|
// 合并储值卡面值以及状态数量
|
|
@@ -284,12 +318,30 @@ class CardBatchService
|
|
{
|
|
{
|
|
$cardBatch = CardBatch::where('card_batch_id', $card_batch_id)->first() ?? [];
|
|
$cardBatch = CardBatch::where('card_batch_id', $card_batch_id)->first() ?? [];
|
|
if (!empty($cardBatch)) {
|
|
if (!empty($cardBatch)) {
|
|
- $cardBatch['card_batch_status_value'] = $cardBatch['card_batch_status'];
|
|
|
|
- $cardBatch['card_batch_status'] = array_flip(CardBatch::CARD_BATCH_STATUS)[$cardBatch['card_batch_status']];
|
|
|
|
|
|
+ $cardBatch['card_batch_status_value'] = array_flip(CardBatch::CARD_BATCH_STATUS)[$cardBatch['card_batch_status']];
|
|
!empty($cardBatch['card_batch_json']) && $cardBatch['card_batch_json'] = json_decode($cardBatch['card_batch_json'], true);
|
|
!empty($cardBatch['card_batch_json']) && $cardBatch['card_batch_json'] = json_decode($cardBatch['card_batch_json'], true);
|
|
!empty($cardBatch['card_batch_extend_json']) && $cardBatch['card_batch_extend_json'] = json_decode($cardBatch['card_batch_extend_json'], true);
|
|
!empty($cardBatch['card_batch_extend_json']) && $cardBatch['card_batch_extend_json'] = json_decode($cardBatch['card_batch_extend_json'], true);
|
|
}
|
|
}
|
|
return json_success('', $cardBatch);
|
|
return json_success('', $cardBatch);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Notes: 卡状态下拉列表
|
|
|
|
+ * User: ZhouBenXu
|
|
|
|
+ * DateTime: 2024/7/1 上午9:27
|
|
|
|
+ * @return Response
|
|
|
|
+ */
|
|
|
|
+ public static function getStatusList()
|
|
|
|
+ {
|
|
|
|
+ $data = [];
|
|
|
|
+ $statusList = CardBatch::CARD_BATCH_STATUS;
|
|
|
|
+ foreach ($statusList as $key => $value) {
|
|
|
|
+ $info = [];
|
|
|
|
+ $info['status'] = $key;
|
|
|
|
+ $info['status_value'] = $value;
|
|
|
|
+ $data[] = $info;
|
|
|
|
+ }
|
|
|
|
+ return json_success('', $data);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|