| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <?php
- /**
- * Created by PhpStorm.
- * Name: 芸众商城系统
- * Author: 广州市芸众信息科技有限公司
- * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
- * Date: 2022/8/5
- * Time: 9:42
- */
- namespace business\admin\controllers;
- use business\common\controllers\components\BaseController;
- use business\common\models\MessageNotice;
- use business\common\notice\BusinessNoticeFactory;
- use business\common\services\customers\CustomerNoticeService;
- class NoticeController extends BaseController
- {
- public function preAction()
- {
- parent::preAction(); // TODO: Change the autogenerated stub
- }
- //未读列表
- public function unread()
- {
- $search = [
- 'status' => 0,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- 'notice_type' => request()->input('notice_type'),
- 'plugin' => request()->input('plugin'),
- ];
- $list = MessageNotice::getList($search)->paginate(20);
- $toArrayList = $this->mapList($list);
- return $this->successJson('list', $toArrayList);
- }
- //已读列表
- public function read()
- {
- $search = [
- 'status' => 1,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- 'notice_type' => request()->input('notice_type'),
- 'plugin' => request()->input('plugin'),
- ];
- $list = MessageNotice::getList($search)->paginate(20);
- $toArrayList = $this->mapList($list);
- return $this->successJson('list', $toArrayList);
- }
- //待处理列表
- public function waitHandle()
- {
- $search = [
- 'handle_status' => 1,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- 'notice_type' => request()->input('notice_type'),
- 'plugin' => request()->input('plugin'),
- ];
- $list = MessageNotice::getList($search)->paginate(20);
- $toArrayList = $this->mapList($list);
- return $this->successJson('list', $toArrayList);
- }
- protected function mapList($list)
- {
- $list = $list->toArray();
- list($list['unreadMum'],$list['waitHandleNum']) = $this->countQuantity();
- return $list;
- }
- protected function countQuantity()
- {
- $waitHandle = [
- 'handle_status' => 1,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- 'plugin' => request()->input('plugin'),
- 'notice_type' => request()->input('notice_type'),
- ];
- $unread = [
- 'status' => 0,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- 'plugin' => request()->input('plugin'),
- 'notice_type' => request()->input('notice_type'),
- ];
- $unreadMum = MessageNotice::getList($unread)->count();
- $waitHandleNum = MessageNotice::getList($waitHandle)->count();
- return [$unreadMum,$waitHandleNum];
- }
- //待处理
- public function laterHandle()
- {
- $taskNotice = MessageNotice::find(intval(request()->input('notice_id')));
- if ($taskNotice) {
- $taskNotice->fill(['handle_status'=>1])->save();
- }
- return $this->successJson('加入待处理');
- }
- //已处理
- public function alreadyHandle()
- {
- $taskNotice = MessageNotice::find(intval(request()->input('notice_id')));
- if ($taskNotice) {
- $taskNotice->fill(['handle_status'=>0])->save();
- }
- return $this->successJson('已处理');
- }
- //操作已读
- public function markRead()
- {
- $taskNotice = MessageNotice::find(intval(request()->input('notice_id')));
- if ($taskNotice) {
- $taskNotice->fill(['status'=>1])->save();
- }
- return $this->successJson('已读');
- }
- //操作全部已读
- public function batchMarkRead()
- {
- $search = [
- 'status' => 0,
- 'recipient_id' => BusinessNoticeFactory::loginUserStaffId(),
- ];
- $list = MessageNotice::getList($search)->get();
- if ($list->isNotEmpty()) {
- $list->map(function (MessageNotice $taskNotice) {
- $taskNotice->fill(['status'=>1])->save();
- });
- }
- return $this->successJson('全部已读');
- }
- public function allAppModule()
- {
- $a = [
- 'app_module' => BusinessNoticeFactory::allModule(),
- 'type' => BusinessNoticeFactory::getFormatAllType(request('plugin')),
- ];
- return $this->successJson('eee', $a);
- }
- public function ttt()
- {
- $html = request()->input('html', '测试消息通知'.time());
- $data = [
- 'user_ids' => [BusinessNoticeFactory::loginUserStaffId()],
- 'param'=> [
- 'head' => '商城消息通知测试'.time(),
- 'title' => '测试测试哈哈哈',
- ],
- 'html' => $html,
- ];
- BusinessNoticeFactory::createInstance('shop', 'shop')->create($data);
- return $this->successJson('success', $data);
- }
- }
|