فهرست منبع

商品加一个字段,type

wufeng 2 سال پیش
والد
کامیت
8fd7044ae1

+ 2 - 0
app/admin/controller/Good.php

@@ -22,6 +22,7 @@ class Good extends BaseController
             'good_code' => '',
             'good_name' => '',
             'status' => '',
+            'type' => ''
         ], 'post');
 
         return GoodLogic::list($param);
@@ -40,6 +41,7 @@ class Good extends BaseController
             'good_img',
             'good_param',
             'unit_id',
+            'type',
             'good_remark' => '',
         ], 'post');
 

+ 1 - 1
app/admin/controller/GoodGroup.php

@@ -69,6 +69,6 @@ class GoodGroup extends BaseController
         $id = $this->request->post('id/d', 0);
         return GoodGroupLogic::delete($id);
     }
-    
+
 
 }

+ 3 - 1
app/admin/logic/GoodLogic.php

@@ -18,11 +18,12 @@ class GoodLogic extends BaseLogic
         if ($data['good_code'] !== '') $db->whereLike('good_code', '%' . $data['good_code'] . '%');
         if ($data['good_name']) $db->whereLike('good_name', '%' . $data['good_name'] . '%');
         if ($data['status'] != '') $db->where('status', $data['status']);
+        if ($data['type'] != '') $db->where('type', $data['type']);
 
         $count = $db->count('id');
 
         $list = $db
-            ->field('id,good_cover_img,good_code,good_name,status,creater,addtime')
+            ->field('id,good_cover_img,good_code,good_name,status,type,creater,addtime')
             ->page($data['page'], $data['size'])
             ->order('addtime desc')
             ->select()
@@ -50,6 +51,7 @@ class GoodLogic extends BaseLogic
             'good_name' => $data['good_name'],
             'moq' => $data['moq'],
             'step' => $data['step'],
+            'type' => $data['type'],
             'good_banner_img' => implode(',', $data['good_banner_img']),
             'good_img' => implode(',', $data['good_img']),
             'good_param' => json_encode($data['good_param'], JSON_UNESCAPED_UNICODE),

+ 3 - 1
app/admin/validate/GoodValidate.php

@@ -2,6 +2,7 @@
 
 namespace app\admin\validate;
 
+use app\model\GoodModel;
 use think\facade\Db;
 use think\Validate;
 
@@ -20,6 +21,7 @@ class GoodValidate extends Validate
         'good_param|商品参数' => 'require|array|min:1|max:100',
         'unit_id|单位id' => 'require|number|gt:0',
         'good_remark|商品备注' => 'require|max:255',
+        'type|商品类型' => 'require|number|in:1,2'
     ];
 
     //创建商品
@@ -36,11 +38,11 @@ class GoodValidate extends Validate
                 'good_param',
                 'unit_id',
                 'good_remark',
+                'type'
             ]);
     }
 
 
-
     //修改商品信息
     public function sceneEdit()
     {

+ 3 - 0
app/model/GoodModel.php

@@ -8,4 +8,7 @@ class GoodModel extends Model
 {
     protected $table = 'fc_good';
     protected $pk = 'id';
+
+    public static $type_exchange = 1;//兑换商品
+    public static $type_shopping = 2;//商城商品
 }