From 97a34521cf1fae7799571c08fd0702e3cc92298f Mon Sep 17 00:00:00 2001 From: Anyon Date: Fri, 5 May 2017 16:04:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0]=E4=BF=AE=E6=94=B9=E7=B2=89?= =?UTF-8?q?=E4=B8=9D=E6=A0=87=E7=AD=BE=E6=B7=BB=E5=8A=A0=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/wechat/controller/Tags.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/application/wechat/controller/Tags.php b/application/wechat/controller/Tags.php index 0cf10d899..dec85a77c 100644 --- a/application/wechat/controller/Tags.php +++ b/application/wechat/controller/Tags.php @@ -60,13 +60,14 @@ class Tags extends BasicAdmin { } $name = $this->request->post('name', ''); empty($name) && $this->error('粉丝标签名不能为空!'); - if (Db::name($this->table)->where('name', $name)->count() > 0) { - $this->error('粉丝标签标签名已经存在,请使用其它标签名!'); + (Db::name($this->table)->where('name', $name)->count() > 0) && $this->error('粉丝标签标签名已经存在, 请使用其它标签名!'); + $wechat = & load_wechat('User'); + if (false === ($result = $wechat->createTags($name)) && isset($result['tag'])) { + $this->error("添加粉丝标签失败. {$wechat->errMsg}[{$wechat->errCode}]"); } - $result = DataService::save($this->table, ['name' => $name, 'count' => 0]); - empty($result) && $this->error('粉丝标签添加失败,请稍候再试!'); - $info = Db::name($this->table)->where('name', $name)->find(); - empty($info) && $this->error('粉丝标签添加失败,请稍候再试!'); + $result['tag']['count'] = 0; + DataService::save($this->table, $result['tag'], 'id') && $this->success('添加粉丝标签成功!', ''); + $this->error('粉丝标签添加失败,请稍候再试!'); } /**