Fans.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\controller\wechat;
  10. use app\admin\controller\Auth;
  11. use mall\response\Response;
  12. use think\facade\Request;
  13. use think\facade\View;
  14. use app\admin\service\wechat\Fans as FansService;
  15. class Fans extends Auth {
  16. /**
  17. * 列表
  18. * @return string|\think\response\Json
  19. * @throws \think\db\exception\DataNotFoundException
  20. * @throws \think\db\exception\DbException
  21. * @throws \think\db\exception\ModelNotFoundException
  22. */
  23. public function index(){
  24. if(Request::isAjax()){
  25. $list = FansService::getList(Request::param());
  26. return Response::returnArray("ok",0,$list['data'],$list['count']);
  27. }
  28. return View::fetch();
  29. }
  30. /**
  31. * 同步黑名单
  32. * @return \think\response\Json
  33. */
  34. public function sync_black(){
  35. try {
  36. FansService::syncBlack();
  37. }catch (\Exception $e){
  38. return Response::returnArray($e->getMessage(),0);
  39. }
  40. return Response::returnArray("同步成功!");
  41. }
  42. /**
  43. * 同步标签
  44. * @return \think\response\Json
  45. */
  46. public function sync_tags(){
  47. try {
  48. FansService::syncTags();
  49. }catch (\Exception $e){
  50. return Response::returnArray($e->getMessage(),0);
  51. }
  52. return Response::returnArray("同步成功!");
  53. }
  54. /**
  55. * 添加黑名单
  56. * @return \think\response\Json
  57. */
  58. public function add_black(){
  59. try {
  60. FansService::addBlack(Request::param("openid"));
  61. return Response::returnArray('拉入黑名单成功!');
  62. } catch (\Exception $e) {
  63. return Response::returnArray($e->getMessage(),0);
  64. }
  65. }
  66. /**
  67. * 移出黑名单
  68. * @return \think\response\Json
  69. */
  70. public function remove_black(){
  71. try {
  72. FansService::removeBlack(Request::param("openid"));
  73. return Response::returnArray('移出黑名单成功!');
  74. } catch (\Exception $e) {
  75. return Response::returnArray($e->getMessage(),0);
  76. }
  77. }
  78. /**
  79. * 删除
  80. * @return \think\response\Json
  81. */
  82. public function delete(){
  83. try{
  84. FansService::delete(Request::param("id",0,"intval"));
  85. return Response::returnArray("删除成功");
  86. }catch (\Exception $ex){
  87. return Response::returnArray($ex->getMessage(),0);
  88. }
  89. }
  90. }