Bladeren bron

物流公司列表及启禁用

wufeng 2 jaren geleden
bovenliggende
commit
be1e55cc2f

+ 32 - 0
app/admin/controller/Express.php

@@ -0,0 +1,32 @@
+<?php
+
+namespace app\admin\controller;
+
+use app\admin\logic\ExpressLogic;
+use app\BaseController;
+use think\exception\ValidateException;
+use think\facade\Config;
+use think\facade\Validate;
+
+class Express extends BaseController
+{
+
+    //列表
+    public function list(){
+
+        $param = $this->request->only(['page'=>1,'size'=>10,'express_code'=>'','express_name'=>'','mobile'=>'','status'=>''],'post');
+        return ExpressLogic::list($param);
+    }
+
+    //启禁用
+    public function status(){
+
+        $param = $this->request->only(['id','status'],'post');
+
+        $val = Validate::rule(Config::get('validate_rules.status'));
+        if(!$val->check($param)) throw new ValidateException($val->getError());
+
+        return ExpressLogic::status($param);
+    }
+
+}

+ 50 - 0
app/admin/logic/ExpressLogic.php

@@ -0,0 +1,50 @@
+<?php
+
+namespace app\admin\logic;
+
+use app\model\AccountBatchLogModel;
+use app\model\ExpressModel;
+use app\model\CommonModel;
+use app\model\VideoModel;
+use think\Exception;
+use think\exception\ValidateException;
+use think\facade\Config;
+use think\facade\Db;
+use think\response\Json;
+
+class ExpressLogic extends BaseLogic
+{
+
+    //列表
+    public static function list(array $data = []): Json
+    {
+
+        $where = [];
+        if ($data['express_code'] != '') $where[] = ['express_code', 'like', '%' . $data['express_code'] . '%'];
+        if ($data['express_name'] != '') $where[] = ['express_name', 'like', '%' . $data['express_name'] . '%'];
+        if ($data['mobile'] != '') $where[] = ['mobile', 'like', '%' . $data['mobile'] . '%'];
+        if ($data['status'] != '') $where[] = ['status', '=', $data['status']];
+
+
+        $count = ExpressModel::where($where)->count('id');
+
+        $list = ExpressModel::where($where)
+            ->field(true)
+            ->order('id', 'desc')
+            ->page($data['page'], $data['size'])
+            ->select()
+            ->toArray();
+        return json_show(CommonModel::$success, '获取快递公司列表成功', ['count' => $count, 'list' => $list]);
+    }
+
+    //删除
+    public static function status(array $data = []): Json
+    {
+        $rs = ExpressModel::where(['id' => $data['id']])
+            ->where('status', '<>', $data['status'])
+            ->save(['status' => $data['status']]);
+
+        return $rs ? json_show(CommonModel::$success, '操作成功') : json_show(CommonModel::$error_param, '操作失败,该快递公司不存在或重复操作');
+    }
+
+}

+ 3 - 0
app/admin/route/app.php

@@ -152,5 +152,8 @@ Route::rule('themeRead', 'admin/Theme/read');//详情
 Route::rule('themeEdit', 'admin/Theme/edit');//修改
 Route::rule('themeStatus', 'admin/Theme/status');//启禁用
 
+//【物流公司】
+Route::rule('expressList', 'admin/Express/list');//列表
+Route::rule('expressStatus', 'admin/Express/status');//启禁用
 
 

+ 0 - 1
app/mobile/controller/Order.php

@@ -5,7 +5,6 @@ namespace app\mobile\controller;
 use app\BaseController;
 use app\mobile\logic\OrderLogic;
 
-
 //【订单】
 class Order extends BaseController
 {

+ 12 - 0
app/model/ExpressModel.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace app\model;
+
+use think\Model;
+
+class ExpressModel extends Model
+{
+    protected $table = 'fc_express';
+    protected $pk = 'id';
+
+}