|
@@ -116,6 +116,10 @@ class CardBatchService
|
|
|
$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']; // 批次状态
|
|
|
+ // 是否有激活的卡片
|
|
|
+ if (Card::where('join_card_batch_id', $params['card_batch_id'])->where('card_status', 'ACTIVED')->exists()) {
|
|
|
+ return json_fail('存在已激活卡片不可以修改状态');
|
|
|
+ }
|
|
|
if ($params['validtimes_status'] == 0) {
|
|
|
$model->card_batch_validtimes = 0; // 卡批次有效期 0=永久 天
|
|
|
} elseif ($params['validtimes_status'] == 1) {
|
|
@@ -245,39 +249,30 @@ class CardBatchService
|
|
|
-- INIT
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'INIT' THEN counts ELSE 0 END),0) as status_INIT_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'INIT' THEN amounts ELSE 0 END),0) as status_INIT_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'INIT' THEN addeds ELSE 0 END),0) as status_INIT_addeds,
|
|
|
-- PRODUCTED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'PRODUCTED' THEN counts ELSE 0 END),0) as status_PRODUCTED_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'PRODUCTED' THEN amounts ELSE 0 END),0) as status_PRODUCTED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'PRODUCTED' THEN addeds ELSE 0 END),0) as status_PRODUCTED_addeds,
|
|
|
-- ENABLED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'ENABLED' THEN counts ELSE 0 END),0) as status_ENABLED_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'ENABLED' THEN amounts ELSE 0 END),0) as status_ENABLED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'ENABLED' THEN addeds ELSE 0 END),0) as status_ENABLED_addeds,
|
|
|
-- WAITING
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'WAITING' THEN counts ELSE 0 END),0) as status_WAITING_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'WAITING' THEN amounts ELSE 0 END),0) as status_WAITING_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'WAITING' THEN addeds ELSE 0 END),0) as status_WAITING_addeds,
|
|
|
-- PENDING
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'PENDING' THEN counts ELSE 0 END),0) as status_PENDING_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'PENDING' THEN amounts ELSE 0 END),0) as status_PENDING_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'PENDING' THEN addeds ELSE 0 END),0) as status_PENDING_addeds,
|
|
|
-- ACTIVED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'ACTIVED' THEN counts ELSE 0 END),0) as status_ACTIVED_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'ACTIVED' THEN amounts ELSE 0 END),0) as status_ACTIVED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'ACTIVED' THEN addeds ELSE 0 END),0) as status_ACTIVED_addeds,
|
|
|
-- DISABLED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'DISABLED' THEN counts ELSE 0 END),0) as status_DISABLED_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'DISABLED' THEN amounts ELSE 0 END),0) as status_DISABLED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'DISABLED' THEN addeds ELSE 0 END),0) as status_DISABLED_addeds,
|
|
|
-- EXPIRED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'EXPIRED' THEN counts ELSE 0 END),0) as status_EXPIRED_counts,
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'EXPIRED' THEN amounts ELSE 0 END),0) as status_EXPIRED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'EXPIRED' THEN addeds ELSE 0 END),0) as status_EXPIRED_addeds,
|
|
|
-- PAUSED
|
|
|
IFNULL(SUM(CASE WHEN card_status = 'PAUSED' THEN counts ELSE 0 END),0) as status_PAUSED_counts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'PAUSED' THEN amounts ELSE 0 END),0) as status_PAUSED_amounts,
|
|
|
- IFNULL(SUM(CASE WHEN card_status = 'PAUSED' THEN addeds ELSE 0 END),0) as status_PAUSED_addeds
|
|
|
+ IFNULL(SUM(CASE WHEN card_status = 'PAUSED' THEN amounts ELSE 0 END),0) as status_PAUSED_amounts
|
|
|
from (select join_card_batch_id, card_status, COUNT(*) as counts, SUM(card_amount) as amounts, SUM(card_added) as addeds from app_card where join_card_batch_id in (" . $card_batch_id_string . ") group by join_card_batch_id, card_status) group_data
|
|
|
group by join_card_batch_id";
|
|
|
|