Browse Source

储值卡

gorden 5 days ago
parent
commit
dafdf12a45

+ 1 - 1
app/admin/controller/coupon/CardController.php

@@ -90,7 +90,7 @@ class CardController extends Curd
                     $model = $model->where($column, $value[0], "%$value[1]%");
                 } elseif (in_array($value[0], ['>', '=', '<', '<>'])) {
                     $model = $model->where($column, $value[0], $value[1]);
-                } elseif ($value[0] == 'in' && !empty($value[1])) {
+                } elseif ($value[0] == 'in') {
                     $valArr = $value[1];
                     if (is_string($value[1])) {
                         $valArr = explode(",", trim($value[1]));

+ 11 - 5
app/admin/controller/coupon/CardIssueController.php

@@ -5,6 +5,7 @@ namespace app\admin\controller\coupon;
 use app\controller\Curd;
 use app\model\Card;
 use app\model\CardIssue;
+use app\model\CardMain;
 use app\model\SysCategory;
 use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
 use Illuminate\Database\Query\Builder as QueryBuilder;
@@ -26,16 +27,21 @@ class CardIssueController extends Curd
 
     public function select(Request $request): Response
     {
+        $cardMainName = $request->get('card_main_name');
         [$where, $format, $limit, $field, $order] = $this->selectInput($request);
         $order = $request->get('order', 'desc');
         $field = $field ?? 'card_issue_addtimes';
 
-        if (!empty($where['card_main_name'])) {
-            $where['card_main_name'] = ['like', $where['card_main_name']];
+        if (!empty($where['card_issue_name'])) {
+            $where['card_issue_name'] = ['like', $where['card_issue_name']];
         }
         if (!empty($where['card_issue_addtimes'])) {
-            $where['card_main_addtimes'][0] = strtotime($where['card_main_addtimes'][0]);
-            $where['card_main_addtimes'][1] = strtotime($where['card_main_addtimes'][1]);
+            $where['card_issue_addtimes'][0] = strtotime($where['card_issue_addtimes'][0]);
+            $where['card_issue_addtimes'][1] = strtotime($where['card_issue_addtimes'][1]);
+        }
+        if (!empty($cardMainName)) {
+            $cardMainIds = CardMain::where('card_main_name', 'like', '%' . $cardMainName . '%')->pluck('card_main_id')->toArray();
+            $where['join_issue_card_main_id'] = ['in', $cardMainIds];
         }
 
         $query = $this->doSelect($where, $field, $order);
@@ -62,7 +68,7 @@ class CardIssueController extends Curd
                     $model = $model->where($column, $value[0], "%$value[1]%");
                 } elseif (in_array($value[0], ['>', '=', '<', '<>'])) {
                     $model = $model->where($column, $value[0], $value[1]);
-                } elseif ($value[0] == 'in' && !empty($value[1])) {
+                } elseif ($value[0] == 'in') {
                     $valArr = $value[1];
                     if (is_string($value[1])) {
                         $valArr = explode(",", trim($value[1]));

+ 1 - 2
app/admin/controller/coupon/CardMainController.php

@@ -40,8 +40,7 @@ class CardMainController extends Curd
         $query = $this->doSelect($where, $field, $order);
         return $this->doFormat($query, $format, $limit);
     }
-
-
+    
     /**
      * 指定查询where条件,并没有真正的查询数据库操作
      * @param array $where