|
@@ -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,"标签添加失败");
|
|
|
+ }
|
|
|
+}
|