From d74728f179d8333d98ef79fa9eb95763d3d4f6d4 Mon Sep 17 00:00:00 2001
From: wangxinglong <2371974647@qq.com>
Date: Tue, 23 Nov 2021 17:13:55 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E5=88=9D=E5=A7=8B=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/common.php | 31 +++
app/controller/manager/Category.php | 39 ---
app/controller/manager/Comment.php | 232 ++++++++++++++++++
app/controller/manager/Consumer.php | 48 ++--
app/controller/manager/ConsumerTag.php | 205 ++++++++++++++++
app/model/Base.php | 15 --
app/model/Category.php | 2 +-
app/model/Comment.php | 35 ++-
app/model/Coupon.php | 6 +
app/model/CouponBill.php | 18 ++
app/model/Tag.php | 53 ++++
app/repository/AccountRepository.php | 2 +
app/traits/CouponBillTrait.php | 18 ++
app/traits/CouponTrait.php | 6 +-
public/static/manager/js/business/comment.js | 109 ++++++++
.../static/manager/js/consumer/blank_list.js | 72 ++++++
public/static/manager/js/consumer/index.js | 3 +-
public/static/manager/js/consumer/info.js | 3 +
public/static/manager/js/consumer_tag.js | 189 ++++++++++++++
view/manager/comment/add_black.html | 21 ++
view/manager/comment/index.html | 137 +++++++++++
view/manager/comment/recycle_bin.html | 113 +++++++++
view/manager/config/wechat.html | 4 +-
view/manager/consumer/blank_list.html | 19 +-
view/manager/consumer/index.html | 35 ++-
view/manager/consumer/info.html | 12 +-
view/manager/consumer_tag/add.html | 29 +++
view/manager/consumer_tag/edit.html | 29 +++
view/manager/consumer_tag/index.html | 29 +++
29 files changed, 1422 insertions(+), 92 deletions(-)
create mode 100644 app/controller/manager/Comment.php
create mode 100644 app/controller/manager/ConsumerTag.php
create mode 100644 app/model/CouponBill.php
create mode 100644 app/traits/CouponBillTrait.php
create mode 100644 public/static/manager/js/business/comment.js
create mode 100644 public/static/manager/js/consumer/blank_list.js
create mode 100644 public/static/manager/js/consumer_tag.js
create mode 100644 view/manager/comment/add_black.html
create mode 100644 view/manager/comment/index.html
create mode 100644 view/manager/comment/recycle_bin.html
create mode 100644 view/manager/consumer_tag/add.html
create mode 100644 view/manager/consumer_tag/edit.html
create mode 100644 view/manager/consumer_tag/index.html
diff --git a/app/common.php b/app/common.php
index 76ba9e7..bb50b2c 100644
--- a/app/common.php
+++ b/app/common.php
@@ -642,4 +642,35 @@ if(!function_exists("createUuid")){
. substr($chars, 20, 12);
return $prefix . str_replace("-", "", $uuid);
}
+}
+
+/**
+ * 格式化黑名单时间
+ */
+if(!function_exists("formatBlankTime")){
+ function formatBlankTime($startdate, $enddate) {
+
+ if (strtotime($startdate) > strtotime($enddate)) {
+ $ymd = $enddate;
+ $enddate = $startdate;
+ $startdate = $ymd;
+ }
+
+ $date=floor((strtotime($enddate)-strtotime($startdate))/86400);
+ //echo "相差天数:".$date."天
";
+
+ $hour=floor((strtotime($enddate)-strtotime($startdate))%86400/3600);
+ //echo "相差小时数:".$hour."小时
";
+
+ $minute=floor((strtotime($enddate)-strtotime($startdate))%86400/60);
+ //echo "相差分钟数:".$minute."分钟
";
+
+ $second=floor((strtotime($enddate)-strtotime($startdate))%86400%60);
+ //echo "相差秒数:".$second."秒";
+
+ return ($date>0?$date."天":'').
+ ($hour>0?$hour."小时":'').
+ ($minute>0?$minute."分钟":'').
+ ($second>0?$second."秒":'');
+ }
}
\ No newline at end of file
diff --git a/app/controller/manager/Category.php b/app/controller/manager/Category.php
index f21c023..f76f670 100644
--- a/app/controller/manager/Category.php
+++ b/app/controller/manager/Category.php
@@ -79,45 +79,6 @@ class Category extends Base
return $this->view();
}
- /**
- * 单个字段编辑
- *
- * @return Json
- * @throws DataNotFoundException
- * @throws DbException
- * @throws ModelNotFoundException
- * @throws Exception
- */
- public function modify(): Json
- {
- if ($this->request->isPost()) {
- $item = input('post.');
- $validate = $this->validateByApi($item, [
- 'id|ID' => 'require|number',
- 'field|字段名' => 'require',
- 'value|值' => 'require',
- ]);
-
- if ($validate !== true) {
- return $validate;
- }
-
- if (!$info = CategoryModel::findById($item['id'])) {
- return $this->json(4001, '记录不存在');
- }
-
- $update = [$item['field'] => $item['value']];
-
- try {
- $info->save($update);
- return $this->json();
- } catch (ValidateException $e) {
- return $this->json(4001, $e->getError());
- }
- }
- return $this->json(4000, '非法请求');
- }
-
/**
* 添加
*
diff --git a/app/controller/manager/Comment.php b/app/controller/manager/Comment.php
new file mode 100644
index 0000000..ac25a15
--- /dev/null
+++ b/app/controller/manager/Comment.php
@@ -0,0 +1,232 @@
+json(4001, '状态错误');
+ }
+ if (!$info = CommentModel::findById($id)) {
+ return $this->json(4001, '记录不存在');
+ }
+
+ if ($this->request->isPost()) {
+ $data = ['state' => $state];
+ if ($state == CommentModel::state_hide) {
+ $data['is_delete'] = CommentModel::COMMON_ON;
+ }
+ $info->save($data);
+ return $this->json();
+ }
+
+ $disabled = CommentModel::getAllChildrenIds($id);
+ $disabled[] = $id;
+
+ $this->data['item'] = $info;
+
+ return $this->view();
+ }
+
+ /**
+ * 恢复
+ *
+ * @return Json|View
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @throws Exception
+ */
+ public function recovery()
+ {
+ $id = input('id/d', 0);
+ if (!$info = CommentModel::findById($id)) {
+ return $this->json(4001, '记录不存在');
+ }
+ if ($this->request->isPost()) {
+ $data = ["is_delete"=>CommentModel::COMMON_OFF];
+ $info->save($data);
+ return $this->json();
+ }
+ }
+
+
+ /**
+ * 加入黑名单
+ * @return Json
+ */
+ public function addBlack()
+ {
+ $id = input("id/d");
+ $info = CommentModel::findById($id);
+ if (empty($info)) {
+ return $this->error('记录不存在');
+ }
+
+ if ($this->request->isPost()) {
+ if (empty($info)) {
+ return $this->json(4001, '记录不存在');
+ }
+ $time = input("time/d", 0, "abs");
+ if ($time <= 0) {
+ return $this->json(4001, "时间输入错误");
+ }
+
+ $account = AccountRepository::getInstance()->findOneByWhere(["user_code" => $info["user_code"]]);
+ if (empty($account)) {
+ return $this->json(4001, "用户不存在");
+ }
+
+ $timeSecond = $time * 60;
+ Db::startTrans();
+ try {
+ //如果之前有黑名单设置 如果黑名单时间未过期
+ if (!empty($account["blank_time"]) && strtotime($account["blank_time"]) && strtotime($account["blank_time"]) > time()) {
+ $account->save(["blank_time" => date("Y-m-d H:i:s", (strtotime($account["blank_time"]) + $timeSecond)), "blank_total" => (($account["blank_total"] ?? 0) + $time)]);
+ } else {
+ $account->save(["blank_time" => date("Y-m-d H:i:s", (time() + $timeSecond)), "blank_total" => (($account["blank_total"] ?? 0) + $time)]);
+ }
+ $info->save(["state" => CommentModel::state_hide]);
+ Db::commit();
+
+ return $this->json();
+ } catch (RepositoryException $e) {
+ Db::rollback();
+ return $this->json(5001, "失败");
+ } catch (Exception $e) {
+ Db::rollback();
+ return $this->json(5002, "失败");
+ }
+
+
+ }
+ $this->data["id"] = $id;
+ return $this->view();
+ }
+
+ /**
+ * 彻底删除
+ * @return Json
+ */
+ public function del()
+ {
+ if (!$this->request->isPost()) {
+ return $this->json(4000, '非法请求');
+ }
+ $ids = $this->request->param('ids/a', []);
+ CommentModel::destroy($ids);
+ return $this->json();
+ }
+
+ /**
+ * 列表
+ *
+ * @return Json|View
+ * @throws Exception
+ */
+ public function index()
+ {
+ $stateArray = CommentModel::allState();
+ $typeArray = CommentModel::allType();
+ if ($this->request->isPost()) {
+
+ $keyword = $this->request->param('keyword/s',);
+ $state = $this->request->param('state/d', "-1");
+ $type = $this->request->param('type/d', -1);
+ $page = $this->request->param('page/d', 1);
+ $size = $this->request->param('size/d', 30);
+
+ $whereMap = [["comment.is_delete", "=", CommentModel::COMMON_OFF]];
+ $orders = ['comment.id' => 'desc'];
+ if (!empty($keyword)) {
+ $whereMap[] = ['account.nick_name', 'like', "%$keyword%"];
+ }
+ if ($type >= 0) {
+ $whereMap[] = ['comment.type', '=', $type];
+ }
+ if (isset($stateArray[$state])) {
+ $whereMap[] = ['comment.state', '=', $state];
+ }
+ $list = CommentModel::findList($whereMap, [], $page, $size, function ($q) {
+ return $q->withJoin("account");
+ }, $orders);
+
+
+ return $this->json(0, 'success', $list);
+
+ }
+ $this->data["state"] = $stateArray;
+ $this->data["type"] = $typeArray;
+ return $this->view();
+ }
+
+ /**
+ * 列表
+ *
+ * @return Json|View
+ * @throws Exception
+ */
+ public function recycleBin()
+ {
+ if ($this->request->isPost()) {
+
+ $keyword = $this->request->param('keyword/s',);
+
+ $page = $this->request->param('page/d', 1);
+ $size = $this->request->param('size/d', 30);
+ $whereMap = [["comment.is_delete", "=", CommentModel::COMMON_ON]];
+ if (!empty($keyword)) {
+ $whereMap[] = ['account.nick_name', 'like', "%$keyword%"];
+ }
+ $orders = ['comment.id' => 'desc'];
+ $list = CommentModel::findList($whereMap, [], $page, $size, function ($q) {
+ return $q->withJoin("account");
+ }, $orders);
+ return $this->json(0, 'success', $list);
+ }
+ return $this->view();
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/controller/manager/Consumer.php b/app/controller/manager/Consumer.php
index b100529..2bb3ef7 100644
--- a/app/controller/manager/Consumer.php
+++ b/app/controller/manager/Consumer.php
@@ -62,6 +62,10 @@ class Consumer extends Base
$item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id");
//优惠券未使用总数
$item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id");
+
+ //优惠红包总金额
+ $item->consumer_coupon_bill_total = AccountRepository::getInstance()->consumerCouponBillTotal($item->user_code);
+
});
return $this->json(0, 'success', $list);
@@ -80,6 +84,7 @@ class Consumer extends Base
public function info()
{
$id = input("id/d", 0);
+ $sign = input("sign/d", 0);
$consumer = Account::findOne(["id" => $id], [], function ($q) {
return $q->with("tag");
});
@@ -88,19 +93,23 @@ class Consumer extends Base
$repo = AccountRepository::getInstance();
$page = $this->request->param('page/d', 1);
$size = $this->request->param('size/d', 30);
-
- $list = $repo->consumerCouponList($consumer['user_code'], $page, $size);
+ $where = [["consumer_code", "=", $consumer['user_code']]];
+ if ($sign) {
+ $where[] = ["is_verificated", "=", Coupon::is_verificated_on];
+ }
+ $list = $repo->consumerCouponList($where, $page, $size);
$time = time();
$list["list"]->each(function ($item) use ($time) {
- if(strtotime($item['end_time']) < $time){
+ if (strtotime($item['end_time']) < $time) {
$item->time_state = '已过期';
- }else{
+ } else {
$item->time_state = '未过期';
}
});
return $this->json(0, 'success', $list);
}
+
if (empty($consumer)) {
return $this->json(4001, "消费者不存在");
}
@@ -119,6 +128,7 @@ class Consumer extends Base
$this->data["couponNotUsedTotalCount"] = $rep->consumerNotUsedTotalCoupon($consumer["user_code"]);
$this->data["consumer"] = $consumer->toArray();
+ $this->data["sign"] = $sign;
return $this->view();
}
@@ -150,18 +160,26 @@ class Consumer extends Base
if (isset($stateArray[$state])) {
$whereMap[] = ['state', '=', $state];
}
- $list = $repo->findList($whereMap, [], $page, $size, function ($q) {
- return $q->with("tag");
- }, $orders);
- $list["list"]->each(function ($item) {
- //优惠券领取总数
- $item->coupon_total_count = Coupon::where(["consumer_code" => $item->user_code])->count("id");
- //优惠券使用总数
- $item->coupon_used_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_on)->count("id");
- //优惠券未使用总数
- $item->coupon_not_use_count = Coupon::where(["consumer_code" => $item->user_code])->where("is_verificated", Coupon::is_verificated_off)->count("id");
- });
+ $list = $repo->findList($whereMap, [], $page, $size, null, $orders);
+ $time = time();
+ $list["list"]->each(function ($item) use ($time) {
+ //禁言总时长
+ $item->blank_total_format = formatBlankTime(date("Y-m-d H:i:s",$time + ($item->blank_total * 60)), date("Y-m-d H:i:s",$time ),);
+
+// echo date("Y-m-d H:i:s",$time + $item->blank_total * 60);
+// echo date("Y-m-d H:i:s",$time + $item->blank_total * 60);
+// echo $item->blank_time;
+ //剩余禁言总时长
+ if(!empty($item->blank_time) && strtotime($item->blank_time)>$time){
+ $item->surplus_blank_total_format = formatBlankTime(
+ date("Y-m-d H:i:s",$time ),
+ $item->blank_time);
+ }else{
+ $item->surplus_blank_total_format = '';
+ }
+
+ });
return $this->json(0, 'success', $list);
}
diff --git a/app/controller/manager/ConsumerTag.php b/app/controller/manager/ConsumerTag.php
new file mode 100644
index 0000000..23dc01b
--- /dev/null
+++ b/app/controller/manager/ConsumerTag.php
@@ -0,0 +1,205 @@
+json(4001, '记录不存在');
+ }
+
+ if ($this->request->isPost()) {
+ $item = input('post.');
+ $validate = $this->validateByApi($item, [
+ 'pid|父级分类' => 'require|number',
+ 'name|标题' => 'require|max:100',
+ ]);
+
+ if ($validate !== true) {
+ return $validate;
+ }
+
+ Db::startTrans();
+ try {
+ $info->save($item);
+ Db::commit();
+ return $this->json();
+ } catch (ValidateException $e) {
+ Db::rollback();
+ return $this->json(4001, $e->getError());
+ }
+ }
+
+ $disabled = TagModel::getAllChildrenIds($id);
+ $disabled[] = $id;
+ $this->data['jsonList'] = $this->categoryJson([$info['pid']], $disabled);
+ $this->data['item'] = $info;
+
+ return $this->view();
+ }
+
+ /**
+ * 单个字段编辑
+ *
+ * @return Json
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ * @throws Exception
+ */
+ public function modify(): Json
+ {
+ if ($this->request->isPost()) {
+ $item = input('post.');
+ $validate = $this->validateByApi($item, [
+ 'id|ID' => 'require|number',
+ 'field|字段名' => 'require',
+ 'value|值' => 'require',
+ ]);
+
+ if ($validate !== true) {
+ return $validate;
+ }
+
+ if (!$info = TagModel::findById($item['id'])) {
+ return $this->json(4001, '记录不存在');
+ }
+
+ $update = [$item['field'] => $item['value']];
+
+ try {
+ $info->save($update);
+ return $this->json();
+ } catch (ValidateException $e) {
+ return $this->json(4001, $e->getError());
+ }
+ }
+ return $this->json(4000, '非法请求');
+ }
+
+ /**
+ * 添加
+ *
+ * @return Json|View
+ * @throws Exception
+ */
+ public function add()
+ {
+ if ($this->request->isPost()) {
+ $item = input('post.');
+ $validate = $this->validateByApi($item, [
+ 'pid|父级分类' => 'require|number',
+ 'name|标题' => 'require|max:100',
+ ]);
+
+ if ($validate !== true) {
+ return $validate;
+ }
+ try {
+ TagModel::create($item);
+ return $this->json();
+ } catch (ValidateException $e) {
+ return $this->json(4001, $e->getError());
+ }
+ }
+
+ $this->data['jsonList'] = $this->categoryJson();
+
+ return $this->view();
+ }
+
+
+ /**
+ * 删除
+ * @return Json
+ */
+ public function del()
+ {
+ if (!$this->request->isPost()) {
+ return $this->json(4000, '非法请求');
+ }
+
+ $ids = $this->request->param('ids/a', []);
+ if(!empty(TagModel::findOne([["pid","in",$ids]]))){
+ return $this->json(5001,"该栏目还有下级 不能删除");
+ }
+ TagModel::destroy($ids);
+ return $this->json();
+ }
+
+ /**
+ * 列表
+ *
+ * @return Json|View
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public function index()
+ {
+ if ($this->request->isPost()) {
+ $menus = TagModel::getList();
+ $res = [
+ 'code' => 0,
+ 'msg' => 'success',
+ 'count' => $menus->count(),
+ 'data' => $menus->toArray(),
+ ];
+ return json($res);
+ }
+ return $this->view();
+ }
+
+ /**
+ * @param array $selected
+ * @param array $disabled
+ * @return false|string
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ private function categoryJson(array $selected = [], array $disabled = [])
+ {
+ $categoryList[] = ['name' => '顶级分类', 'id' => 0, 'disabled' => false, 'selected' => in_array(0, $selected)];
+ $list = TagModel::getListByPid();
+ $list = $list->toArray();
+ foreach ($list as $k => $m) {
+ $list[$k]['selected'] = in_array($m['id'], $selected);
+ $list[$k]['disabled'] = in_array($m['id'], $disabled);
+ }
+ $list = CmsRepository::getInstance()->buildMenuChild(0, $list);
+ $categoryList = array_merge($categoryList, CmsRepository::getInstance()->handleSelectedList($list));
+ return json_encode($categoryList, JSON_UNESCAPED_UNICODE);
+ }
+}
\ No newline at end of file
diff --git a/app/model/Base.php b/app/model/Base.php
index 0f5fa55..4163223 100644
--- a/app/model/Base.php
+++ b/app/model/Base.php
@@ -322,22 +322,7 @@ class Base extends Model
return $path;
}
- /**
- * 刷新路径
- *
- * @param int $pid
- * @param array $data 默认全部 若data不为空 至少包含[id,path, $pidField]
- * @param string $pidField 父级ID字段名 默认 pid
- * @throws Exception
- */
- public static function refreshPath(int $pid = 0, array $data = [], string $pidField = 'pid')
- {
- $data = !empty($data) ? $data : self::column('id,path,'.$pidField);
- $updateAllPaths = [];
- self::recursionPath($pid, $data, $updateAllPaths);
- (new static())->saveAll($updateAllPaths);
- }
/**
* 获取递归最新路径
diff --git a/app/model/Category.php b/app/model/Category.php
index 0cdf105..89f9a3c 100644
--- a/app/model/Category.php
+++ b/app/model/Category.php
@@ -30,7 +30,7 @@ class Category extends Base
}
/**
- * 获取全部病种列表
+ * 获取全部列表
*
* @return Disease[]|array|Collection
* @throws DataNotFoundException
diff --git a/app/model/Comment.php b/app/model/Comment.php
index ca6e47a..ae80aeb 100644
--- a/app/model/Comment.php
+++ b/app/model/Comment.php
@@ -1,8 +1,39 @@
"待审核",
+ self::state_success=>"审核通过",
+ self::state_hide=>"隐藏",
+ ];
+ }
+
+ public static function allType(){
+ return [
+ self::type_text=>"文本",
+ self::type_img=>"图片",
+ self::type_voice=>"语音",
+ ];
+ }
+ public function account()
+ {
+ return $this->hasOne(Account::class,"user_code","user_code");
+ }
+ public function business()
+ {
+ return $this->hasOne(Business::class,"code","business_code");
+ }
}
\ No newline at end of file
diff --git a/app/model/Coupon.php b/app/model/Coupon.php
index c6db370..553f34b 100644
--- a/app/model/Coupon.php
+++ b/app/model/Coupon.php
@@ -17,4 +17,10 @@ class Coupon extends Base
//是否验证
const is_verificated_on = 1;//1已验证
const is_verificated_off = 0;//0未验证
+
+
+ public function couponBill()
+ {
+ return $this->hasOne(CouponBill::class,"coupon_id","id");
+ }
}
\ No newline at end of file
diff --git a/app/model/CouponBill.php b/app/model/CouponBill.php
new file mode 100644
index 0000000..4be805b
--- /dev/null
+++ b/app/model/CouponBill.php
@@ -0,0 +1,18 @@
+order('id', 'desc')->field($fields)->select();
+ }
+
+ /**
+ * 获取全部列表
+ *
+ * @return Disease[]|array|Collection
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public static function getList()
+ {
+ return self::field('id,pid,name')->order('id', 'desc')->order('id')->select();
+ }
+
+ /**
+ * 病种 xmSelect json数据
+ *
+ * @param int $pid
+ * @param array $selected
+ * @param array $disabled
+ * @return array|Disease[]|Collection
+ * @throws DataNotFoundException
+ * @throws DbException
+ * @throws ModelNotFoundException
+ */
+ public static function diseaseXmJson(int $pid = 0, array $selected = [], array $disabled = [])
+ {
+ $list = self::getListByPid($pid);
+ foreach ($list as $k => $m) {
+ $list[$k]['selected'] = in_array($m['id'], $selected);
+ $list[$k]['disabled'] = in_array($m['id'], $disabled);
+ }
+
+ return $list;
+ }
}
diff --git a/app/repository/AccountRepository.php b/app/repository/AccountRepository.php
index 0ecb7e2..237baf3 100644
--- a/app/repository/AccountRepository.php
+++ b/app/repository/AccountRepository.php
@@ -6,6 +6,7 @@ use app\exception\RepositoryException;
use app\service\Repository;
use app\traits\CommentTrait;
+use app\traits\CouponBillTrait;
use app\traits\CouponTrait;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@@ -23,6 +24,7 @@ class AccountRepository extends Repository
{
use CommentTrait;
use CouponTrait;
+ use CouponBillTrait;
/**
* 获取指定账户记录By手机号
*
diff --git a/app/traits/CouponBillTrait.php b/app/traits/CouponBillTrait.php
new file mode 100644
index 0000000..1b3432f
--- /dev/null
+++ b/app/traits/CouponBillTrait.php
@@ -0,0 +1,18 @@
+sum("consumer_money");
+ }
+
+
+}
\ No newline at end of file
diff --git a/app/traits/CouponTrait.php b/app/traits/CouponTrait.php
index 795741e..93cb06d 100644
--- a/app/traits/CouponTrait.php
+++ b/app/traits/CouponTrait.php
@@ -48,9 +48,11 @@ trait CouponTrait
* @return array
* @throws \Exception
*/
- public function consumerCouponList($userCode, $page, $size)
+ public function consumerCouponList($where, $page, $size)
{
- return Coupon::findList(["consumer_code" => $userCode], [], $page, $size, null, ["id" => "desc"]);
+ return Coupon::findList($where, [], $page, $size, function ($q){
+ return $q->with("couponBill");
+ }, ["id" => "desc"]);
}
diff --git a/public/static/manager/js/business/comment.js b/public/static/manager/js/business/comment.js
new file mode 100644
index 0000000..6198180
--- /dev/null
+++ b/public/static/manager/js/business/comment.js
@@ -0,0 +1,109 @@
+layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
+ let $ = layui.jquery,
+ form = layui.form,
+ table = layui.table,
+ layer = layui.layer,
+ xmSelect = layui.xmSelect,
+ miniTab = layui.miniTab;
+
+ /**** index begin ***/
+ //index页面
+ if ($('.location-index-page').length > 0) {
+ miniTab.listen();
+
+ // 渲染表格
+ let listUrl = $('#table-container').data('url');
+ let insTb = table.render({
+ elem: '#table-container',
+ toolbar: '#toolbar-tpl',
+ defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
+ title: '搜索'
+ , layEvent: 'search'
+ , icon: 'layui-icon-search'
+ }],
+ url: listUrl,
+ method: 'post',
+ even: true,
+ limits: [10,20,50,100,200,500,1000],
+ request: {
+ pageName: 'page',
+ limitName: 'size',
+ },
+ parseData: function (res) {
+ return {
+ "code": res.code, //解析接口状态
+ "msg": res.msg, //解析提示文本
+ "count": res.data.total, //解析数据长度
+ "data": res.data.list //解析数据列表
+ };
+ },
+ page: true,
+ cols: [[
+ // {type: 'checkbox'},
+ {field: 'id' , width: 80, title: 'ID'},
+ {templet: '#row-cover', title: '头像', style: 'height: 90px;'},
+ {templet:function(d){
+ if( d.account != undefined){
+ return d.account.nick_name
+ }
+ return '';
+ },title: '昵称'},
+ {templet: '#row-gender', title: '性别'},
+ {field: 'create_time', title: '评论时间'},
+
+ {templet: '#row-comment', minWidth: 350, title: '评论内容'},
+ {templet: '#row-state', title: '状态'},
+
+ {templet: '#row-operate', field: 'right', align: 'center', title: '操作', fixed: 'right'}
+ ]],
+ done: function () {
+ Tools.setInsTb(insTb);
+ }
+ });
+
+ // 监听搜索操作
+ form.on('submit(data-search-btn)', function (data) {
+ //执行搜索重载
+ table.reload('table-container', {
+ page: {curr: 1}
+ , where: data.field
+ }, 'data');
+
+ return false;
+ });
+
+
+ //监听行工具条
+ table.on('tool(table-container)', function (obj) {
+ let data = obj.data;
+ let layEvent = obj.event;
+ let url = $($(this).context).data('href');
+ let title = $($(this).context).data('title');
+ let width = $($(this).context).data('width') ? $($(this).context).data('width') : '100%';
+ let height = $($(this).context).data('height') ? $($(this).context).data('height') : '100%';
+ let insTb = Tools.getInsTb();
+
+ switch (layEvent) {
+ // 行 删除
+ case 'examine':
+ $.post(url, {}, function (res) {
+ layer.msg(res.msg)
+ if (res.code === 0) {
+ insTb.reload();
+ }
+ })
+ return false; // 行 删除
+ case 'black':
+ openLayer(url, title, width, height);
+ return false;
+
+ case 'del':
+ delRow(url, [data.id], insTb);
+ return false;
+ }
+ });
+
+ }
+ /*** index end ***/
+
+});
\ No newline at end of file
diff --git a/public/static/manager/js/consumer/blank_list.js b/public/static/manager/js/consumer/blank_list.js
new file mode 100644
index 0000000..70996d1
--- /dev/null
+++ b/public/static/manager/js/consumer/blank_list.js
@@ -0,0 +1,72 @@
+layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function () {
+ let $ = layui.jquery,
+ form = layui.form,
+ table = layui.table,
+ layer = layui.layer,
+ xmSelect = layui.xmSelect,
+ miniTab = layui.miniTab;
+
+ /**** index begin ***/
+ //index页面
+ if ($('.location-index-page').length > 0) {
+ miniTab.listen();
+
+ // 渲染表格
+ let listUrl = $('#table-container').data('url');
+ let insTb = table.render({
+ elem: '#table-container',
+ toolbar: '#toolbar-tpl',
+ defaultToolbar: [{ //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
+ title: '搜索'
+ , layEvent: 'search'
+ , icon: 'layui-icon-search'
+ }],
+ url: listUrl,
+ method: 'post',
+ even: true,
+ limits: [10,20,50,100,200,500,1000],
+ request: {
+ pageName: 'page',
+ limitName: 'size',
+ },
+ parseData: function (res) {
+ return {
+ "code": res.code, //解析接口状态
+ "msg": res.msg, //解析提示文本
+ "count": res.data.total, //解析数据长度
+ "data": res.data.list //解析数据列表
+ };
+ },
+ page: true,
+ cols: [[
+ // {type: 'checkbox'},
+ {field: 'id' , width: 80, title: 'ID'},
+ {templet: '#row-cover', title: '头像', style: 'height: 90px;'},
+ {field: 'nick_name', title: '昵称'},
+
+ {templet: '#row-gender', title: '性别'},
+ {field: 'blank_total_format', title: '禁言总时长'},
+ {field: 'surplus_blank_total_format', title: '剩余禁言时长'},
+
+ {templet: '#row-operate', minWidth: 350, field: 'right', align: 'center', title: '操作', fixed: 'right'}
+ ]],
+ done: function () {
+ Tools.setInsTb(insTb);
+ }
+ });
+
+ // 监听搜索操作
+ form.on('submit(data-search-btn)', function (data) {
+ //执行搜索重载
+ table.reload('table-container', {
+ page: {curr: 1}
+ , where: data.field
+ }, 'data');
+
+ return false;
+ });
+
+ }
+ /*** index end ***/
+
+});
\ No newline at end of file
diff --git a/public/static/manager/js/consumer/index.js b/public/static/manager/js/consumer/index.js
index 3d19428..8871eeb 100644
--- a/public/static/manager/js/consumer/index.js
+++ b/public/static/manager/js/consumer/index.js
@@ -43,10 +43,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
{field: 'id' , width: 80, title: 'ID'},
{templet: '#row-cover', title: '头像', style: 'height: 90px;'},
{field: 'nick_name', title: '昵称'},
- {field: 'gender', title: '性别'},
+ {templet: '#row-gender', title: '性别'},
{field: 'coupon_total_count', title: '优惠券领取数'},
{field: 'coupon_used_count', title: '优惠券使用数'},
{field: 'coupon_not_use_count', title: '优惠券未使用数'},
+ {field: 'consumer_coupon_bill_total', title: '红包总数'},
{field: 'login_time', title: '最近登录'},
diff --git a/public/static/manager/js/consumer/info.js b/public/static/manager/js/consumer/info.js
index f9a5bdb..a06ccd3 100644
--- a/public/static/manager/js/consumer/info.js
+++ b/public/static/manager/js/consumer/info.js
@@ -39,8 +39,11 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'xmSelect'], function
{field: 'id' , width: 80, title: 'ID'},
{field: 'name', title: '名称'},
{field: 'type_name', title: '优惠券类型'},
+ {templet: '#row-received_map', title: '领取位置'},
{field: 'money', title: '金额'},
{field: 'business_name', title: '商家名称'},
+ {field: 'business_name', title: '商家名称'},
+ {templet: '#row-sign_map', title: '签到位置'},
{templet: '#row-state', title: '状态'},
]],
done: function () {
diff --git a/public/static/manager/js/consumer_tag.js b/public/static/manager/js/consumer_tag.js
new file mode 100644
index 0000000..7f2832f
--- /dev/null
+++ b/public/static/manager/js/consumer_tag.js
@@ -0,0 +1,189 @@
+layui.use(['laytpl', 'treeTable','jquery', 'form', 'miniTab', 'xmSelect'], function () {
+ let $ = layui.jquery,
+ form = layui.form,
+ treeTable = layui.treeTable,
+ layer = layui.layer,
+ miniTab = layui.miniTab,
+ xmSelect = layui.xmSelect;
+
+ let modifyUrl = $('#row-modify').data('url');
+
+ /**** index begin ***/
+ //index页面
+ if ($('.location-index-page').length > 0) {
+ miniTab.listen();
+
+ // 渲染表格
+ let listUrl = $('#menu-table').data('url');
+ let insTb = treeTable.render({
+ elem: '#menu-table',
+ toolbar: '#toolbar-tpl',
+ defaultToolbar: [],
+ method: 'POST',
+ skin: 'line',
+ url: listUrl,
+ page: false,
+ tree: {
+ iconIndex: 1, // 折叠图标显示在第几列
+ isPidData: true, // 是否是id、pid形式数据
+ idName: 'id', // id字段名称
+ pidName: 'pid' // pid字段名称
+ },
+ cols: [[
+ {type: 'checkbox'},
+ {field: 'name', minWidth: 200, title: '名称'},
+ {field: 'commision', width: 80, align: 'center', title: '默认佣金', edit: 'text'},
+ {templet: '#menu-operate', width: 150, align: 'center', title: '操作'}
+ ]],
+ done: function () {
+ }
+ });
+
+ //监听单元格编辑
+ treeTable.on('edit(menu-table)', function(obj){
+ $.post(modifyUrl, {id: obj.data.id, field: obj.field, value: obj.value}, function (res) {
+ layer.msg(res.msg)
+ if (res.code === 0) {
+ insTb.refresh();
+ }
+ })
+
+ });
+
+ //监听工具条 注意区别toolbar和tool toolbar是表头上的工具条 tool是行中的工具条
+ treeTable.on('toolbar(menu-table)', function (obj) {
+ let layEvent = obj.event;
+
+ if (layEvent === 'expand') {
+ insTb.expandAll();
+ return false;
+ }
+
+ if (layEvent === 'fold') {
+ insTb.foldAll();
+ return false;
+ }
+
+ if (layEvent === 'del') {
+ let selected = insTb.checkStatus(false);
+ let ids = [];
+ let url = $(obj.elem.context).data('href')
+ $.each(selected, function (index, val) {
+ ids.push(val.id);
+ })
+
+ del(url, ids);
+ return false;
+ }
+
+ if (layEvent === 'add') {
+ let url = $(obj.elem.context).data('href');
+ let title = $(obj.elem.context).data('title');
+ let index = layer.open({
+ title: title,
+ type: 2,
+ shade: 0.2,
+ maxmin: true,
+ shadeClose: true,
+ area: ['100%', '100%'],
+ content: url,
+ });
+ $(window).on("resize", function () {
+ layer.full(index);
+ });
+ return false;
+ }
+ });
+
+ //刷新
+ $('body').on('click', '[data-table-refresh]', function () {
+ insTb.refresh();
+ });
+
+ //删除
+ function del(url, ids) {
+ let index = layer.confirm('确认删除吗?', {
+ btn: ['确认','取消'], //按钮
+ title: '操作提示',
+ }, function() {
+ $.post(url, {ids: ids}, function (res) {
+ layer.msg(res.msg)
+ if (res.code === 0) {
+ insTb.refresh();
+ }
+ })
+ }, function(){
+ layer.close(index)
+ return false;
+ });
+ }
+
+ //监听工具条
+ treeTable.on('tool(menu-table)', function (obj) {
+ let data = obj.data;
+ let layEvent = obj.event;
+ let url = $(obj.tr.context).data('href');
+ let title = $(obj.tr.context).data('title');
+
+ if (layEvent === 'del') {
+ let ids = [data.id];
+ del(url, ids);
+ return false;
+ }
+
+ if (layEvent === 'edit') {
+ let index = layer.open({
+ title: title,
+ type: 2,
+ shade: 0.2,
+ maxmin: true,
+ shadeClose: true,
+ area: ['100%', '100%'],
+ content: url,
+ });
+
+ $(window).on("resize", function () {
+ layer.full(index);
+ });
+ return false;
+ }
+ });
+ }
+ /*** index end ***/
+
+
+ // add和edit页面
+ if ($('.location-operate-page').length > 0) {
+ let parentMenu = $('#parent-menu');
+ let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : [];
+ xmSelect.render({
+ el: '#parent-menu',
+ paging: false,
+ autoRow: true,
+ radio: true,
+ clickClose: true,
+ name: 'pid',
+ tips: '请选择上级分类',
+ direction: 'auto',
+ height: 'auto',
+ model: {
+ icon: 'hidden',
+ },
+ prop: {
+ name: 'name',
+ value: 'id',
+ },
+ tree: {
+ show: true,
+ strict: false,
+ clickCheck: true,
+ expandedKeys: true,
+ clickExpand: false
+ },
+ theme: {
+ color: '#1e84ff',
+ },
+ data: menuList
+ });
+ }
+});
\ No newline at end of file
diff --git a/view/manager/comment/add_black.html b/view/manager/comment/add_black.html
new file mode 100644
index 0000000..46761bc
--- /dev/null
+++ b/view/manager/comment/add_black.html
@@ -0,0 +1,21 @@
+{layout name="manager/layout" /}
+