wugg 2 years ago
parent
commit
6eec0dec74
3 changed files with 189 additions and 7 deletions
  1. 5 7
      app/admin/controller/Payment.php
  2. 176 0
      app/admin/controller/TagGood.php
  3. 8 0
      app/admin/route/app.php

+ 5 - 7
app/admin/controller/Payment.php

@@ -4,7 +4,8 @@ declare (strict_types = 1);
 namespace app\admin\controller;
 
 use app\admin\BaseController;
-use app\admin\model\ReportCode;use app\command\datacopy;use think\facade\Db;
+use app\admin\model\ReportCode;
+use think\facade\Db;
 
 class Payment extends BaseController
 {
@@ -26,7 +27,7 @@ class Payment extends BaseController
         $payNo= isset($post['payNo'])&&$post['payNo']!="" ? trim($post['payNo']) :"";
         $apply= isset($post['apply_name'])&&$post['apply_name']!="" ? trim($post['apply_name']) :"";
         $paystatus= isset($post['status'])&&$post['status']!="" ? $post['status'] :"";
-//        $inv_status= isset($post['inv_status'])&&$post['inv_status']!="" ? $post['inv_status'] :"";
+
         if($startTime!=""){
             $condition.=" and `b`.`addtime` >= '{$startTime}'";
         }
@@ -47,9 +48,6 @@ class Payment extends BaseController
         if($paystatus!=""){
             $condition .=" and `b`.`status` = {$paystatus}";
         }
-//        if($inv_status!=""){
-//            $condition .=" and `a`.`inv_status`  = {$inv_status}";
-//        }
         $page =  isset($post['page'])&&$post['page']!="" ? intval($post['page']) :1;
         $size =  isset($post['size'])&&$post['size']!="" ? intval($post['size']) :10;
         $count = Db::name("pay_payment")->alias('b')
@@ -90,7 +88,7 @@ class Payment extends BaseController
         }
         return app_show(0,"获取成功",["list"=>$data,"count"=>$count]);
     }
-/**
+    /**
      *对账单列表
      * @return \think\Response
      */
@@ -227,7 +225,7 @@ class Payment extends BaseController
                         H:i:s")]);
                       if($cgddup){
                             Db::commit();
-                             return app_show(0,"添加成功",["payNo"=>$payNo]);
+                            return app_show(0,"添加成功",["payNo"=>$payNo]);
                       }
 
                     }

+ 176 - 0
app/admin/controller/TagGood.php

@@ -0,0 +1,176 @@
+<?php
+
+
+namespace app\admin\controller;
+use app\admin\BaseController;
+use think\App;
+use think\facade\Db;
+
+class TagGood extends BaseController{
+    public function __construct(App $app) {parent::__construct($app);}
+    //新建标签
+    public function create(){
+        $post = $this->post;
+        $type = isset($post['type'])&& $post['type']!="" ? intval($post['type']) :"";
+        if($type==''){
+            return error_show(1004,"参数 type 不能未空");
+        }
+        $tagName =isset($post['tag_name'])&&$post['tag_name']!='' ? trim($post['tag_name']):"";
+        if($tagName==''){
+            return error_show(1004,"参数 tag_name 不能未空");
+        }
+        $isT =Db::name("order_tag")->where(["type"=>$type,"tag_name"=>$tagName,"is_del"=>0])->findOrEmpty();
+        if(!empty($isT)){
+               return error_show(1004,"标签名称已存在");
+        }
+        $tagData=[
+            "type"=>$type,
+            "tag_name"=>$tagName,
+            "status"=>1,
+            "apply_id"=>$this->uid,
+            "apply_name"=>$this->uname,
+            "addtime"=>date("Y-m-d H:i:s"),
+            "updatetime"=>date("Y-m-d H:i:s")
+        ];
+        $ins=Db::name("order_tag")->insert($tagData);
+        return $ins?app_show(0,"标签新建成功"): error_show(1004,"标签新建失败");
+    }
+    //标签列表翻页
+    public function list(){
+        $page = isset($this->post['page'])&&$this->post['page']!=''?intval($this->post['page']):1;
+        $size = isset($this->post['size'])&&$this->post['size']!=''?intval($this->post['size']):15;
+        $type = isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
+        $condition =[["is_del","=",0]];
+        if($type!=''){
+            $condition[]=["type","=",$type];
+        }
+         $tagName =isset($post['tag_name'])&&$post['tag_name']!='' ? trim($post['tag_name']):"";
+        if($tagName!=''){
+          $condition[]=["tag_name","like","%$tagName%"];
+        }
+        $count =Db::name("order_tag")->where($condition)->count();
+        $total=ceil($count/$size);
+        $page = $page>=$total ? intval($total):$page;
+        $list =Db::name("order_tag")->where($condition)->page($page,$size)->order("addtime desc")->select()->toArray();
+        return error_show(1004,"获取成功",["list"=>$list,"count"=>$count]);
+    }
+    //根据条件筛选合适的标签数据
+    public function query(){
+        $type = isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
+        $condition =[["is_del","=",0]];
+        if($type!=''){
+            $condition[]=["type","=",$type];
+        }
+         $tagName =isset($post['tag_name'])&&$post['tag_name']!='' ? trim($post['tag_name']):"";
+        if($tagName!=''){
+          $condition[]=["tag_name","like","%$tagName%"];
+        }
+         $list =Db::name("order_tag")->where($condition)->order("addtime desc")->select()->toArray();
+        return error_show(1004,"获取成功",$list);
+    }
+    //启禁用状态
+    public function status(){
+        $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
+        if($id==''){
+            return error_show(1004,"参数 id 不能为空");
+        }
+        $taginfo =Db::name("order_tag")->find(["id"=>$id]);
+        if($taginfo==false){
+             return error_show(1004,"标签数据不存在");
+        }
+        $status=isset($this->post['status'])&&$this->post['status']!==''?intval($this->post['status']):'';
+        if($status===''){
+           return error_show(1004,"参数 status 不能为空");
+        }
+        $update =["status"=>$status,"updatetime"=>date("Y-m-d H:i:s")];
+        $up =Db::name("order_tag")->where($taginfo)->update($update);
+         return $up?app_show(0,"标签更新成功"): error_show(1004,"标签更新失败");
+    }
+        //编辑标签名称类型数据
+    public function save(){
+        $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
+        if($id==''){
+            return error_show(1004,"参数 id 不能为空");
+        }
+        $taginfo =Db::name("order_tag")->find(["id"=>$id]);
+        if($taginfo==false){
+             return error_show(1004,"标签数据不存在");
+        }
+        $tagName=isset($this->post['tag_name'])&&$this->post['tag_name']!=''?trim($this->post['tag_name']):'';
+        if($tagName===''){
+           return error_show(1004,"参数 tag_name 不能为空");
+        }
+         $type=isset($this->post['type'])&&$this->post['type']!=''?intval($this->post['type']):'';
+        if($type==''){
+           return error_show(1004,"参数 type 不能为空");
+        }
+        $tag =Db::name("order_tag")->where([['tag_name',"=",$tagName],['type',"=",$type],["id","<>",$id],["is_del","=",0]])->find();
+        if($tag!=false){
+             return error_show(1004,"标签名称已存在");
+        }
+        $update =["type"=>$type,"tag_name"=>$tagName,"updatetime"=>date("Y-m-d H:i:s")];
+        $up =Db::name("order_tag")->where($taginfo)->update($update);
+         return $up?app_show(0,"标签更新成功"): error_show(1004,"标签更新失败");
+    }
+    //删除标签
+    public function  delete(){
+        $id =isset($this->post['id'])&&$this->post['id']!=''?intval($this->post['id']):'';
+        if($id==''){
+            return error_show(1004,"参数 id 不能为空");
+        }
+        $taginfo =Db::name("order_tag")->find(["id"=>$id]);
+        if($taginfo==false){
+             return error_show(1004,"标签数据不存在");
+        }
+        $update=["is_del"=>1,"updatetime"=>date("Y-m-d H:i:s")];
+        $up =Db::name("order_tag")->where($taginfo)->update($update);
+         return $up?app_show(0,"标签删除成功"): error_show(1004,"标签删除失败");
+    }
+        //单号添加标签
+    public function AddTag(){
+        $tagid =isset($this->post["tag_id"]) && $this->post["tag_id"]!=""?intval($this->post["tag_id"]) :"";
+        if($tagid==""){
+            return error_show(1004,"参数 tag_id 不能为空");
+        }
+        $taginfo =Db::name("order_tag")->where(["id"=>$tagid,"is_del"=>0])->find();
+        if($taginfo==false){
+             return error_show(1005,"标签数据不存在");
+        }
+        if($taginfo['status']==0){
+             return error_show(1005,"标签已禁用");
+        }
+        $code =isset($this->post['code']) &&$this->post["code"]!="" ? trim($this->post["code"]):"";
+        if($code==''){
+            return error_show(1004,"参数 code 不能为空");
+        }
+
+        switch ($taginfo['type']){
+                case 1:
+                    $model=Db::name("pay_payment")->where(["dzNo"=>$code,"is_del"=>0]);
+                    break;
+                case 2:
+                    $model=Db::name("pay_invoice")->where(["hpNo"=>$code,"is_del"=>0]);
+                    break;
+                case 3:
+                    $model=Db::name("trade_pool")->where(["logNo"=>$code,"is_del"=>0]);
+                    break;
+                case 4:
+                    $model=Db::name("invoice_pool")->where(["invNo"=>$code,"is_del"=>0]);
+                    break;
+                default:
+                     $model=False;
+                      break;
+
+        }
+        if($model==false){
+           return error_show(1005,"未找到对应的单号数据");
+        }
+        $data=$model->findOrEmpty();
+        if(empty($data)){
+          return error_show(1005,"未找到对应的单号数据");
+        }
+        $update=["tag_id"=>$tagid,"updatetime"=>date("Y-m-d H:i:s")];
+        $up =$model->update($update);
+        return $up?app_show(0,"标签添加成功"):error_show(1005,"标签添加失败");
+    }
+}

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

@@ -123,6 +123,14 @@ Route::rule("tradeloginfo","admin/OrderPay/logInfo");
 Route::rule("tradeinfo","admin/OrderPay/tradeInfo");
 Route::rule("returnpayinfo","admin/OrderPay/returnInfo");
 
+Route::rule("tagadd","admin/TagGood/create");
+Route::rule("taglist","admin/TagGood/list");
+Route::rule("tagquery","admin/TagGood/query");
+Route::rule("tagstatus","admin/TagGood/status");
+Route::rule("tagdel","admin/TagGood/delete");
+Route::rule("tagedit","admin/TagGood/save");
+Route::rule("addtag","admin/TagGood/AddTag");
+