Quellcode durchsuchen

卡状态修改

ZhouBenXu vor 4 Monaten
Ursprung
Commit
4a63181065

+ 4 - 4
app/admin/service/card/CardBatchService.php

@@ -33,7 +33,7 @@ class CardBatchService
             $model = new CardBatch();
             $model->join_card_batch_user_id = $params['join_card_batch_user_id']; // 批次创建用户 user_id
             $model->join_card_batch_category_id = $params['join_card_batch_category_id']; // 批次卡分类ID
-            $model->card_batch_status = $model::CARD_BATCH_STATUS[$params['card_batch_status']]; // 批次状态
+            $model->card_batch_status = $params['card_batch_status']; // 批次状态
             $model->card_batch_category = $params['card_batch_category'] ?? "NORMAL"; // 批次类型 NORMAL
             $model->card_batch_name = $params['card_batch_name']; // 卡批次名称
             $model->card_batch_prefix = $params['card_batch_prefix']; // 卡批次前缀
@@ -86,7 +86,7 @@ class CardBatchService
             $cardBatchModel = new CardBatch();
             $model = $cardBatchModel::find($params['card_batch_id']);
             $model->card_batch_name = $params['card_batch_name'];
-            $params['card_batch_status'] = $model->card_batch_status = $cardBatchModel::CARD_BATCH_STATUS[$params['card_batch_status']]; // 批次状态
+            $params['card_batch_status'] = $model->card_batch_status = $params['card_batch_status']; // 批次状态
             if ($params['validtimes_status'] == 0) {
                 $model->card_batch_validtimes = 0; // 卡批次有效期 0=永久 天
             } elseif ($params['validtimes_status'] == 1) {
@@ -105,7 +105,7 @@ class CardBatchService
                 $model = new Card();
                 $data['card_name'] = $params['card_batch_name'];
 
-                $card_status = array_values($model::CARD_STATUS);
+                $card_status = array_keys($model::CARD_STATUS);
                 if (in_array($params['card_batch_status'], $card_status)) {
                     $data['card_status'] = $params['card_batch_status']; // 卡批次状态
                 }
@@ -256,7 +256,7 @@ class CardBatchService
             $card_status_total = array_column($card_status_total, null, 'join_card_batch_id');
             foreach ($rows as $key => &$value) {
                 $value['card_batch_status_value'] = $value['card_batch_status'];
-                $value['card_batch_status'] = array_flip($cardBatchModel::CARD_BATCH_STATUS)[$value['card_batch_status']];
+                $value['card_batch_status'] = $cardBatchModel::CARD_BATCH_STATUS[$value['card_batch_status']];
                 !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);
                 // 合并储值卡面值以及状态数量

+ 2 - 2
app/admin/service/card/CardService.php

@@ -140,7 +140,7 @@ class CardService
         $join_card_batch_id = $params['join_card_batch_id'] ?? "";
         $join_card_category_id = $params['join_card_category_id'] ?? "";
         $join_card_member_id = $params['join_card_member_id'] ?? "";
-        $card_status = !empty($params['card_status']) ? Card::CARD_STATUS[$params['card_status']] : "";
+        $card_status = !empty($params['card_status']) ? $params['card_status'] : "";
         $card_category = $params['card_category'] ?? "";
         $card_name = $params['card_name'] ?? "";
 
@@ -181,7 +181,7 @@ class CardService
         if (!empty($rows)) {
             foreach ($rows as $key => &$value) {
                 $value['card_status_value'] = $value['card_status'];
-                $value['card_status'] = array_flip(Card::CARD_STATUS)[$value['card_status']];
+                $value['card_status'] = Card::CARD_STATUS[$value['card_status']];
                 !empty($value['card_json']) && $value['card_json'] = json_decode($value['card_json'], true);
                 !empty($value['card_assign_json']) && $value['card_assign_json'] = json_decode($value['card_assign_json'], true);
                 !empty($value['card_process_json']) && $value['card_process_json'] = json_decode($value['card_process_json'], true);

+ 1 - 1
app/model/Card.php

@@ -18,7 +18,7 @@ class Card extends Model
     const UPDATED_AT = null;
 
     //卡状态 INTI=初始化|PRODUCTED=制作完成|ENABLED=已启用|WAITING=已分配|PENDING=待激活|ACTIVED=已激活|DISABLED=已禁用|EXPIRED=已过期|PAUSED=暂停使用
-    public const CARD_STATUS = [1 => 'INIT', 2 => 'PRODUCTED', 3 => 'ENABLED', 4 => 'WAITING', 5 => 'PENDING', 6 => 'ACTIVED', 7 => 'DISABLED', 8 => 'EXPIRED', 9 => 'PAUSED'];
+    public const CARD_STATUS = ['INIT' => '初始化', 'PRODUCTED' => '制作完成', 'ENABLED' => '已启用', 'WAITING' => '已分配', 'PENDING' => '待激活', 'ACTIVED' => '已激活', 'DISABLED' => '已禁用', 'EXPIRED' => '已过期', 'PAUSED' => '暂停使用'];
 
 
     public function serializeDate(DateTimeInterface $date)

+ 1 - 1
app/model/CardBatch.php

@@ -19,7 +19,7 @@ class CardBatch extends Model
 
 
     // 批次状态 CREATE=已创建|PRODUCTED=制作完成|ENABLED=启用|DISABLED=禁用
-    public const CARD_BATCH_STATUS = [1 => 'CREATE', 2 => 'PRODUCTED', 3 => 'ENABLED', 4 => 'DISABLED'];
+    public const CARD_BATCH_STATUS = ['CREATE' => '已创建', 'PRODUCTED' => '制作完成', 'ENABLED' => '启用', 'DISABLED' => '禁用'];
 
     public function serializeDate(DateTimeInterface $date)
     {