diff --git a/addon/article/model/Article.php b/addon/article/model/Article.php index c8697dcd..b7e79e11 100644 --- a/addon/article/model/Article.php +++ b/addon/article/model/Article.php @@ -25,7 +25,9 @@ class Article extends NewBaseModel{ protected $append = [ 'category_name' ]; - + protected $autoWriteTimestamp = 'int'; // 开启自动时间戳 + protected $createTime = 'create_time'; // 默认添加时间字段 + protected $updateTime = 'update_time'; // 默认编辑时间字段 /** * Common: 列表获取 diff --git a/addon/article/model/ArticleCategory.php b/addon/article/model/ArticleCategory.php index 02dd10ef..673fbab0 100644 --- a/addon/article/model/ArticleCategory.php +++ b/addon/article/model/ArticleCategory.php @@ -17,6 +17,9 @@ use app\model\NewBaseModel; class ArticleCategory extends NewBaseModel{ protected $pk = 'category_id'; + protected $autoWriteTimestamp = 'int'; // 开启自动时间戳 + protected $createTime = 'create_time'; // 默认添加时间字段 + protected $updateTime = 'update_time'; // 默认编辑时间字段 /** * Common: 列表获取 * Author: wu-hui diff --git a/addon/article/model/ArticleHistory.php b/addon/article/model/ArticleHistory.php index 7304f3c0..274a8545 100644 --- a/addon/article/model/ArticleHistory.php +++ b/addon/article/model/ArticleHistory.php @@ -18,6 +18,7 @@ class ArticleHistory extends NewBaseModel{ protected $pk = 'id'; //protected $autoWriteTimestamp = false; // 开启自动时间戳 + protected $autoWriteTimestamp = 'int'; // 开启自动时间戳 protected $createTime = 'create_time'; // 默认添加时间字段 protected $updateTime = 'update_time'; // 默认编辑时间字段 protected $deleteTime = false; // 软删除字段 diff --git a/addon/message/api/controller/Message.php b/addon/message/api/controller/Message.php new file mode 100644 index 00000000..a50948db --- /dev/null +++ b/addon/message/api/controller/Message.php @@ -0,0 +1,88 @@ +checkToken(); + if ($token['code'] < 0) return $this->response($token); + // 参数获取 + $page = input('page', 1); + $page_size = input('page_size', PAGE_LIST_ROWS); + $message_type = input('message_type',0); + // 获取内容 + $field = [ + 'a.id', + 'a.is_see', + 'a.order_id', + 'a.created_time', + 'a.reply_content', + 'mc.type', + 'mc.message_title', + 'mc.message_content', + ]; + // 条件生成 + $condition = [ + ['a.site_id','=',$this->site_id], + ['a.member_id', '=', $this->member_id ], + ]; + if($message_type > 0) $condition[] = ['mc.type', '=', $message_type ]; + // 表关联 + $join = [ + ['message_center mc', 'mc.id = a.message_center_id', 'left'], + ]; + $list = (new MessageRead())->getPageList($condition, $page, $page_size, 'a.created_time desc,a.id desc', $field, 'a', $join); + + return $this->response($list); + } + /** + * Common: 消息查看 + * Author: wu-hui + * Time: 2023/03/04 16:31 + */ + public function see(){ + $id = input('id',0); + model('message_center_read')->update(['is_see'=>1], ['id'=>$id]); + + return $this->response($this->success()); + } + /** + * Common: 留言信息 + * Author: wu-hui + * Time: 2023/03/04 18:04 + * @return false|string + */ + public function remarks(){ + // 用户登录 + $token = $this->checkToken(); + if ($token['code'] < 0) return $this->response($token); + // 记录留言信息 + (new messageModel())->addMessage($this->site_id,$this->params['remarks'],4,$this->member_id,0,'',$this->params['image_list']); + + return $this->response($this->success()); + } + + + +} \ No newline at end of file diff --git a/addon/message/model/Message.php b/addon/message/model/Message.php index c0fbe374..c4addb23 100644 --- a/addon/message/model/Message.php +++ b/addon/message/model/Message.php @@ -8,19 +8,50 @@ use think\facade\Db; class Message extends BaseModel{ + private $types = [ + 1 => '交易信息', + 2 => '系统消息', + 3 => '通知消息', + 4 => '留言反馈', + ]; + /** - * 获取列表 - * @param array $condition - * @param int $page - * @param int $page_size - * @param string $order - * @param string $field - * @param string $alias - * @param array $join + * Common: 获取消息列表 + * Author: wu-hui + * Time: 2023/03/04 15:02 * @return array + * @throws \think\db\exception\DbException */ - public function getPageList($condition = [], $page = 1, $page_size = PAGE_LIST_ROWS, $order = '', $field = 'a.*', $alias = 'a', $join = []){ - $list = model('message_center')->pageList($condition, $field, $order, $page, $page_size, $alias, $join); + public function getList($siteId){ + // 参数获取 + $page = input('page',1); + $pageSize = input('page_size',PAGE_LIST_ROWS); + $title = input('title',''); + $type = input('type',''); + // 条件生成 + $where = [ + ['a.site_id','=',$siteId], + ['a.type','in',[2,3]] + ]; + // 其他条件 + if($title) $where[] = ['a.message_title','like',"%{$title}%"]; + if($type) $where[] = ['a.type','=',$type]; + // 列表获取 + $result = Db::name('message_center') + ->alias('a') + ->field('a.id,a.type,a.created_time,a.message_title,count(mcr.message_center_id) as total') + ->join('message_center_read mcr','mcr.message_center_id = a.id', 'left') + ->where($where) + ->group('a.id') + ->order('a.id','DESC') + ->paginate(['list_rows' => $pageSize,'page' => $page]); + if($result) $result = $result->toArray(); + + $list = [ + 'count' => $result['total'], + 'list' => $result['data'], + 'page_count' => $result['last_page'], + ]; return $this->success($list); } /** @@ -32,9 +63,10 @@ class Message extends BaseModel{ * @param int $type * @param string|int $member_id * @param int $orderId + * @param string $title * @return array */ - public function addMessage(int $siteId,string $content,int $type,$member_id = 'all',int $orderId = 0){ + public function addMessage(int $siteId,string $content,int $type,$member_id = 'all',int $orderId = 0,$title = '',$image = ''){ if(!$content) return $this->error('','消息不能为空!'); // 记录消息信息 try{ @@ -42,8 +74,10 @@ class Message extends BaseModel{ ->insertGetId([ 'site_id' => $siteId, 'type' => $type, + 'message_title' => $title ?? $this->types[$type], 'message_content' => $content, - 'created_time' => time() + 'created_time' => time(), + 'image_list' => $image, ]); // 关联用户信息 if($member_id == 'all'){ @@ -76,6 +110,84 @@ class Message extends BaseModel{ } } + /** + * Common: 删除消息 + * Author: wu-hui + * Time: 2023/03/04 15:48 + * @param $id + * @return array + */ + public function delInfo($id){ + // 删除消息信息 + Model('message_center')->delete(['id'=>$id]); + Model('message_center_read')->delete(['message_center_id'=>$id]); + + return $this->success(); + } + /** + * Common: 获取留言信息 + * Author: wu-hui + * Time: 2023/03/04 18:07 + * @param $siteId + * @return array + * @throws \think\db\exception\DbException + */ + public function getRemarks($siteId){ + // 参数获取 + $page = input('page',1); + $pageSize = input('page_size',PAGE_LIST_ROWS); + $nickname = input('nickname',''); + $type = (int)input('type',0); + // 条件生成 + $where = [ + ['a.site_id','=',$siteId], + ['a.type','=',4] + ]; + if($nickname) $where[] = ['m.username|m.nickname','like',"%{$nickname}%"]; + if($type > 0) $where[] = ['mcr.is_see','=',$type == 1 ? 0 : 1];// 是否已读:0=未读,1=已读 + // 列表获取 + $result = Db::name('message_center') + ->alias('a') + ->field('a.id,a.type,a.created_time,mcr.member_id,mcr.is_see,m.username,m.nickname,m.headimg') + ->join('message_center_read mcr','mcr.message_center_id = a.id', 'left') + ->join('member m','m.member_id = mcr.member_id','left') + ->where($where) + ->group('a.id') + ->order('a.id','DESC') + ->paginate(['list_rows' => $pageSize,'page' => $page]); + if($result) $result = $result->toArray(); + + $list = [ + 'count' => $result['total'], + 'list' => $result['data'], + 'page_count' => $result['last_page'], + ]; + return $this->success($list); + } + + /** + * Common: 获取单条信息 + * Author: wu-hui + * Time: 2023/03/06 9:38 + * @param array $where + * @param string $field + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function getInfo($where = [], $field = '*'){ + $result = Db::name('message_center') + ->alias('a') + ->field($field) + ->join('message_center_read mcr','mcr.message_center_id = a.id', 'left') + ->join('member m','m.member_id = mcr.member_id','left') + ->where($where) + ->find(); + + return $this->success($result); + } + diff --git a/addon/message/model/MessageRead.php b/addon/message/model/MessageRead.php new file mode 100644 index 00000000..00018bb7 --- /dev/null +++ b/addon/message/model/MessageRead.php @@ -0,0 +1,26 @@ +pageList($condition, $field, $order, $page, $page_size, $alias, $join); + return $this->success($list); + } + + +} \ No newline at end of file diff --git a/addon/message/shop/controller/Message.php b/addon/message/shop/controller/Message.php index 17efaed1..53dbb712 100644 --- a/addon/message/shop/controller/Message.php +++ b/addon/message/shop/controller/Message.php @@ -17,47 +17,15 @@ use addon\message\model\Message as messageModel; use think\facade\Db; class Message extends BaseShop{ - // 进入消息中心 + /** + * Common: 进入消息中心 + * Author: wu-hui + * Time: 2023/03/04 15:03 + * @return array|mixed + * @throws \think\db\exception\DbException + */ public function index(){ - if(request()->isAjax()){ - - - - - } - - - debug(table('message_center_read')); - // 参数获取 - $page = input('page',1); - $pageSize = input('page_size',PAGE_LIST_ROWS); - // 获取内容 - $field = [ - 'a.id', - 'a.type', - 'a.created_time', - 'count(a.id) as total', - '(select count(id) from )', - - ]; - // 表关联 - $join = [ - ['message_center_read mcr', 'mcr.message_center_id = a.id', 'left'], - ]; - // 条件生成 - $condition = [ - ['a.site_id','=',$this->site_id] - ]; - $res = (new messageModel())->getPageList($condition, $page, $pageSize, 'a.created_time desc,a.id desc', $field, 'a', $join); - - debug($res); - - - - - - - + if(request()->isAjax()) return (new messageModel())->getList($this->site_id); $this->forthMenu(); return $this->fetch('message/index'); @@ -73,11 +41,23 @@ class Message extends BaseShop{ // 参数获取 $type = input('type',2); $content = input('message_content',''); + $title = input('title',''); - return (new messageModel())->addMessage($this->site_id,$content,$type); + return (new messageModel())->addMessage($this->site_id,$content,$type,'all',0,$title); } return $this->fetch('message/send_message'); } + /** + * Common: 删除信息 + * Author: wu-hui + * Time: 2023/03/04 15:48 + * @return array + */ + public function delMessage(){ + $id = input('id'); + + return (new messageModel())->delInfo($id); + } } \ No newline at end of file diff --git a/addon/message/shop/controller/Remark.php b/addon/message/shop/controller/Remark.php new file mode 100644 index 00000000..a8debb10 --- /dev/null +++ b/addon/message/shop/controller/Remark.php @@ -0,0 +1,67 @@ +isAjax()) return (new messageModel())->getRemarks($this->site_id); + + $this->forthMenu(); + return $this->fetch('remark/index'); + } + /** + * Common: 查看详情&回复内容 + * Author: wu-hui + * Time: 2023/03/06 10:09 + * @return array|mixed + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + */ + public function seeInfo(){ + // 获取基本信息 + $messageCenterId = input('message_center_id'); + Model('message_center_read')->update(['is_see'=>1],['message_center_id'=>$messageCenterId]); + if(request()->isAjax()) { + // 回复内容 + $replyContent = input('reply_content'); + Model('message_center_read')->update(['reply_content'=>$replyContent],['message_center_id'=>$messageCenterId]); + + return success(); + } + // 获取信息 + $where = [ + ['a.id','=',$messageCenterId] + ]; + $field = 'a.id,a.created_time,a.message_content,a.image_list,mcr.is_see,m.username,m.nickname,m.headimg'; + $info = (new messageModel())->getInfo($where,$field)['data']; + $info['image_list'] = $info['image_list'] ? explode(',',$info['image_list']) : []; + $this->assign('info',$info); + $this->assign('message_center_id',$messageCenterId); + + return $this->fetch('remark/see'); + } + + + +} \ No newline at end of file diff --git a/addon/message/shop/view/message/index.html b/addon/message/shop/view/message/index.html index 815e5903..0b1233b4 100644 --- a/addon/message/shop/view/message/index.html +++ b/addon/message/shop/view/message/index.html @@ -5,7 +5,6 @@ background-color: #009688; color: #fff; } - {/block} @@ -16,51 +15,22 @@
- +
- +
- +
- - - - - - - - + +
-
-
- - -
- -
- -
- - -
-
-
-
- - -
-
-
@@ -74,97 +44,43 @@ - - - - {/block} {block name="script"} diff --git a/addon/message/shop/view/message/send_message.html b/addon/message/shop/view/message/send_message.html index 87051334..1f051780 100644 --- a/addon/message/shop/view/message/send_message.html +++ b/addon/message/shop/view/message/send_message.html @@ -61,6 +61,12 @@ {block name="body"}
+
+ +
+ +
+
@@ -101,11 +107,13 @@ layer.msg('请输入消息内容!'); return false; } + if(!field['title']){ + layer.msg('请输入消息标题!'); + return false; + } // 数据提交 layer.confirm('确认发布当前消息给所有用户?', {icon: 3, title:'提示'}, function(index){ layer.close(index); - if(repeat_flag) return; - repeat_flag = true; $.ajax({ type: 'POST', dataType: 'JSON', @@ -113,7 +121,6 @@ data: field, async: false, success: function(res){ - repeat_flag = false; if (res.code == 0) { layer.alert('发布成功', function(index){ parent.layer.close(_thisIndex); diff --git a/addon/message/shop/view/remark/index.html b/addon/message/shop/view/remark/index.html new file mode 100644 index 00000000..e7e4daaf --- /dev/null +++ b/addon/message/shop/view/remark/index.html @@ -0,0 +1,160 @@ +{extend name="app/shop/view/base.html"/} +{block name="resources"} + +{/block} + +{block name="main"} + +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+ +
+ + + + +{/block} + +{block name="script"} + +{/block} \ No newline at end of file diff --git a/addon/message/shop/view/remark/see.html b/addon/message/shop/view/remark/see.html new file mode 100644 index 00000000..a05bfb9d --- /dev/null +++ b/addon/message/shop/view/remark/see.html @@ -0,0 +1,112 @@ +{extend name="app/shop/view/base.html"/} +{block name="resources"} + +{/block} + +{block name="body"} +
+
+ +
+ +
{$info['nickname'] ?? $info['username']}
+
+
+
+ +
+ {:date('Y-m-d H:i:s',$info['created_time'])} +
+
+
+ +
+ +
+
+
+ +
+ {foreach $info['image_list'] as $img} + + {/foreach} +
+
+
+ +
+ +
+
+ +
+ + + +
+
+{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/addon/wechat/api/controller/Wechat.php b/addon/wechat/api/controller/Wechat.php index 7106c08f..253bb086 100644 --- a/addon/wechat/api/controller/Wechat.php +++ b/addon/wechat/api/controller/Wechat.php @@ -180,6 +180,6 @@ class Wechat extends BaseApi $config_model = new ConfigModel(); $config_result = $config_model->getWechatConfig($this->site_id)[ 'data' ][ 'value' ]; - return $this->response($this->success([ 'qrcode' => $config_result[ 'qrcode' ] ])); + return $this->response($this->success([ 'qrcode' => $config_result[ 'qrcode' ] ?? '' ])); } } \ No newline at end of file diff --git a/app/common.php b/app/common.php index d98bd22d..80729f5a 100644 --- a/app/common.php +++ b/app/common.php @@ -1829,4 +1829,73 @@ function decode($code) $num += strpos($sourceString, $code[$i]) * pow(4, $i); } return $num; +} + +/** + * Common: 下划线字符串 转 驼峰字符串 + * Author: wu-hui + * Time: 2022/10/20 16:25 + * @param $string + * @param string $separator + * @return string + */ +function camelize($string,$separator = '_'){ + $string = $separator. str_replace($separator, " ", strtolower($string)); + return ltrim(str_replace(" ", "", ucwords($string)), $separator ); +} +/** + * Common: 根据类型获取对应的时间戳 + * Author: wu-hui + * Time: 2022/11/01 17:20 + * @param $type + * @return array + */ +function getTimeStamp($type){ + $startTime = $endTime =0; + #year=本年,month=本月,today=今日,yesterday=昨日,last_week=上周, + switch($type){ + // 本年 + case "year": + $startTime = strtotime(date("Y-1-1")); + $endTime = strtotime(date("Y-1-1"). " +1 year -1 day "); + break; + // 本月 + case "month": + $startTime = strtotime(date("Y-m-1")); + $endTime = strtotime(date("Y-m-1"). " +1 month -1 day "); + break; + // 今日 + case "today": + $startTime = strtotime(date("Y-m-d")); + $endTime = strtotime(date("Y-m-d"). " +1 day "); + break; + // 昨日 + case "yesterday": + $startTime = strtotime(date("Y-m-d"). " -1 day "); + $endTime = strtotime(date("Y-m-d")); + break; + // 上周 + case "last_week": + $week = date('w') == 0 ? 7 : date('w'); + $startTime = strtotime('today -' . ($week - 1) . 'day -1 week'); + $endTime = strtotime('today +' . (8 - $week) . 'day -1 week'); + break; + + } + return [$startTime,$endTime]; +} +/** + * Common: 字符串脱敏处理 + * Author: wu-hui + * Time: 2022/11/03 10:48 + * @param string $str 字符串内容 + * @param int $front 前面保留数字字数 + * @param int $after 后面保留数字字数 + * @return string + */ +function desensitizationHandle($str,$front,$after){ + $frontStr = mb_substr($str,0,$front); + $afterStr = mb_substr($str,-$after,$after); + + return $frontStr.'***'.$afterStr; } \ No newline at end of file diff --git a/app/shop/controller/NewBaseShop.php b/app/shop/controller/NewBaseShop.php new file mode 100644 index 00000000..ead2f58a --- /dev/null +++ b/app/shop/controller/NewBaseShop.php @@ -0,0 +1,70 @@ +thisDefaultModel->getList($this->site_id); + } + /** + * Common: 公共内容 —— 添加/编辑信息 + * Author: wu-hui + * Time: 2022/10/18 14:09 + */ + public function editInfo(){ + if (request()->isAjax()) { + // 参数获取 + $info = input('info',[]); + $info['site_id'] = $this->site_id; + + return $this->thisDefaultModel->editInfo($info); + } else { + // 获取id + $id = input('id',0); + $this->assign('id',$id); + // 获取信息 + if($id > 0){ + $info = $this->thisDefaultModel->singleInfo($id); + $this->assign('info',$info['data'] ?? []); + }else{ + $this->assign('info',[]); + } + + } + } + /** + * Common: 删除单条信息 + * Author: wu-hui + * Time: 2022/10/18 14:13 + */ + public function delete(){ + $id = input('id', 0); + + return $this->thisDefaultModel->delInfo($id); + } + + + + +} \ No newline at end of file diff --git a/public/picture/aijiu/article_bg.jpg b/public/picture/aijiu/article_bg.jpg new file mode 100644 index 00000000..b1bf0535 Binary files /dev/null and b/public/picture/aijiu/article_bg.jpg differ diff --git a/public/picture/aijiu/customer_1.png b/public/picture/aijiu/customer_1.png new file mode 100644 index 00000000..592adacd Binary files /dev/null and b/public/picture/aijiu/customer_1.png differ diff --git a/public/picture/aijiu/customer_2.png b/public/picture/aijiu/customer_2.png new file mode 100644 index 00000000..83d102ca Binary files /dev/null and b/public/picture/aijiu/customer_2.png differ diff --git a/public/picture/aijiu/customer_3.png b/public/picture/aijiu/customer_3.png new file mode 100644 index 00000000..48e4e22c Binary files /dev/null and b/public/picture/aijiu/customer_3.png differ diff --git a/public/picture/aijiu/customer_not.png b/public/picture/aijiu/customer_not.png new file mode 100644 index 00000000..f09114fd Binary files /dev/null and b/public/picture/aijiu/customer_not.png differ diff --git a/public/picture/aijiu/dianzan.png b/public/picture/aijiu/dianzan.png new file mode 100644 index 00000000..4280aac5 Binary files /dev/null and b/public/picture/aijiu/dianzan.png differ diff --git a/public/picture/aijiu/distribution_extension_bg.jpg b/public/picture/aijiu/distribution_extension_bg.jpg new file mode 100644 index 00000000..a5605d0b Binary files /dev/null and b/public/picture/aijiu/distribution_extension_bg.jpg differ diff --git a/public/picture/aijiu/fenxiao.png b/public/picture/aijiu/fenxiao.png new file mode 100644 index 00000000..8276b6a2 Binary files /dev/null and b/public/picture/aijiu/fenxiao.png differ diff --git a/public/picture/aijiu/integral.png b/public/picture/aijiu/integral.png new file mode 100644 index 00000000..3d3559d5 Binary files /dev/null and b/public/picture/aijiu/integral.png differ diff --git a/public/picture/aijiu/liulan.png b/public/picture/aijiu/liulan.png new file mode 100644 index 00000000..6ae1ac4d Binary files /dev/null and b/public/picture/aijiu/liulan.png differ diff --git a/public/picture/aijiu/personal_center_vip_bg.png b/public/picture/aijiu/personal_center_vip_bg.png new file mode 100644 index 00000000..294a7766 Binary files /dev/null and b/public/picture/aijiu/personal_center_vip_bg.png differ diff --git a/public/picture/aijiu/ranking_1.png b/public/picture/aijiu/ranking_1.png new file mode 100644 index 00000000..96806765 Binary files /dev/null and b/public/picture/aijiu/ranking_1.png differ diff --git a/public/picture/aijiu/ranking_2.png b/public/picture/aijiu/ranking_2.png new file mode 100644 index 00000000..388a43d0 Binary files /dev/null and b/public/picture/aijiu/ranking_2.png differ diff --git a/public/picture/aijiu/ranking_3.png b/public/picture/aijiu/ranking_3.png new file mode 100644 index 00000000..0a688074 Binary files /dev/null and b/public/picture/aijiu/ranking_3.png differ diff --git a/public/picture/aijiu/ranking_title_bg.jpg b/public/picture/aijiu/ranking_title_bg.jpg new file mode 100644 index 00000000..eae00cba Binary files /dev/null and b/public/picture/aijiu/ranking_title_bg.jpg differ diff --git a/public/picture/aijiu/reward_box.png b/public/picture/aijiu/reward_box.png new file mode 100644 index 00000000..06679cbf Binary files /dev/null and b/public/picture/aijiu/reward_box.png differ diff --git a/public/picture/aijiu/sign.png b/public/picture/aijiu/sign.png new file mode 100644 index 00000000..504c94c4 Binary files /dev/null and b/public/picture/aijiu/sign.png differ