ZhouBenXu 4 månader sedan
förälder
incheckning
d33ea84283

+ 2 - 1
app/admin/controller/card/CardController.php

@@ -63,11 +63,12 @@ class CardController
         $params = $request->post();
         $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
         // 验证器
+        $params['validtimes_status'] = $params['validtimes_status'] ?? 3;
         $validate = new CardValidate();
         if (!$validate->scene('save')->check($params)) {
             return json_fail($validate->getError());
         }
-        // 校验有效期 0 永久 1增加 2 减少
+        // 校验有效期 0 永久 1增加 2 减少 3不修改
         return CardService::save($params);
     }
 

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

@@ -115,7 +115,7 @@ class CardBatchService
             $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']; // 批次状态
+            $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) {
@@ -132,7 +132,7 @@ class CardBatchService
                 // CardService::saveCardByCardBatchId($params['card_batch_id'], $params);
                 // 修改卡批次下面的卡信息
                 $model = new Card();
-                $data['card_name'] = $params['card_batch_name'];
+//                $data['card_name'] = $params['card_batch_name'];
 
                 $card_status = array_keys($model::CARD_STATUS);
                 if (in_array($params['card_batch_status'], $card_status)) {

+ 7 - 6
app/admin/service/card/CardService.php

@@ -368,16 +368,17 @@ class CardService
             $cardBatchModel = new Card();
             $model = $cardBatchModel::find($params['card_id']);
             $model->card_name = $params['card_name'];
-            $model->join_card_member_id = $params['join_card_member_id'];
-            $params['card_status'] && $params['card_status'] = $model->card_status = Card::CARD_STATUS[$params['card_status']]; // 储值卡状态
+            $model->card_remark = $params['card_remark'] ?? "";
+            $params['join_card_member_id'] && $model->join_card_member_id = $params['join_card_member_id'] ?? "";
+            $params['card_status'] && $model->card_status = $params['card_status']; // 储值卡状态
             if ($params['validtimes_status'] == 0) { // 卡批次有效期 0 永久天  1 增加 2减少
                 $model->card_validtimes = 0;
             } elseif ($params['validtimes_status'] == 1) {
-                $model->card_validtimes = baadd($model->card_validtimes + $params['card_batch_validtimes'] * 86400);
+                $model->card_validtimes = bcadd($model->card_validtimes, $params['card_validtimes'] * 86400);
             } elseif ($params['validtimes_status'] == 2) {
-                $card_validtimes = bcsub($model->card_validtimes - $params['card_batch_validtimes'] * 86400);
+                $card_validtimes = bcsub($model->card_validtimes, $params['card_validtimes'] * 86400);
                 // 修改后的有效期不允许小于当前时间
-                if (!$card_validtimes <= time()) {
+                if ($card_validtimes <= time()) {
                     return json_fail('储值卡有效期必须大于当前时间~');
                 }
                 $model->card_validtimes = $card_validtimes;
@@ -397,7 +398,7 @@ class CardService
             dump($e->getTrace());
             return json_fail('数据写入失败~');
         }
-//        _syslog("修改储值卡", "储值卡id【" . $params['card_id'] . "】");
+        _syslog("修改储值卡", "储值卡id【" . $params['card_id'] . "】");
         return json_success('success');
     }