瀏覽代碼

卡批次修改校验以及接口修改

ZhouBenXu 4 月之前
父節點
當前提交
228a60e5d0

+ 2 - 2
app/admin/controller/card/CardBatchController.php

@@ -48,13 +48,13 @@ class CardBatchController
     {
         $params = $request->post();
         $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
+        $params['validtimes_status'] = $params['validtimes_status'] ?? 3;
         // 验证器
         $validate = new CardBatchValidate();
         if (!$validate->scene('save')->check($params)) {
             return json_fail($validate->getError());
         }
-
-        // 校验有效期 0 永久 1增加 2 减少
+        // 校验有效期 0 永久 1增加 2 减少 3不变
         return CardBatchService::save($params);
     }
 

+ 8 - 1
app/admin/service/card/CardBatchService.php

@@ -114,6 +114,7 @@ class CardBatchService
             $cardBatchModel = new CardBatch();
             $model = $cardBatchModel::find($params['card_batch_id']);
             $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 ($params['validtimes_status'] == 0) {
                 $model->card_batch_validtimes = 0; // 卡批次有效期 0=永久 天
@@ -127,7 +128,7 @@ class CardBatchService
                 $model->card_batch_validtimes = bcsub($model->card_batch_validtimes, $params['card_batch_validtimes']); // 卡批次有效期 0=永久 天
             }
             if ($model->save()) {
-                 // 修改卡批次下面的卡信息
+                // 修改卡批次下面的卡信息
                 // CardService::saveCardByCardBatchId($params['card_batch_id'], $params);
                 // 修改卡批次下面的卡信息
                 $model = new Card();
@@ -284,6 +285,12 @@ 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'] = $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_extend_json']) && $value['card_batch_extend_json'] = json_decode($value['card_batch_extend_json'], true);
                 // 合并储值卡面值以及状态数量

+ 3 - 0
app/admin/validate/card/CardBatchValidate.php

@@ -52,6 +52,9 @@ class CardBatchValidate extends Validate
      */
     public function checkCardSort($params)
     {
+        if ($params['card_batch_serial_begin'] < $params['card_batch_serial_end']) {
+            return false;
+        }
         // 查询是否存在相同前缀后缀信息
         $cardBatchInfo = CardBatch::where('card_batch_prefix', $params['card_batch_prefix'])
             ->where('card_batch_suffix', $params['card_batch_prefix'])