Shopacceptmessage.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\shop\controller;
  11. use addon\wechat\model\Wechat;
  12. use app\model\shop\ShopAcceptMessage as ShopAcceptMessageModel;
  13. use think\facade\Cache;
  14. /**
  15. * 商家接受会员消息管理
  16. * Class Shopacceptmessage
  17. * @package app\shop\controller
  18. */
  19. class Shopacceptmessage extends BaseShop
  20. {
  21. /**
  22. * 商家接受会员消息列表
  23. */
  24. public function lists()
  25. {
  26. if (request()->isAjax()) {
  27. $page = input('page', 1);
  28. $page_size = input('page_size', PAGE_LIST_ROWS);
  29. $search_text_type = input('search_text_type', 'nickname');
  30. $search_text = input('search_text', '');
  31. $condition = [];
  32. if ($search_text) {
  33. $condition[] = [ $search_text_type, 'like', '%' . $search_text . '%' ];
  34. }
  35. $model = new ShopAcceptMessageModel();
  36. $list = $model->getShopAcceptMessagePageList($condition, $page, $page_size);
  37. return $list;
  38. } else {
  39. return $this->fetch('shopacceptmessage/lists');
  40. }
  41. }
  42. /**
  43. * 添加
  44. */
  45. public function add()
  46. {
  47. if (request()->isAjax()) {
  48. $model = new ShopAcceptMessageModel();
  49. $data = [
  50. 'site_id' => $this->site_id,
  51. 'mobile' => input('mobile', ''),
  52. 'wx_openid' => input('wx_openid', ''),
  53. 'nickname' => input('nickname', ''),
  54. ];
  55. $res = $model->addShopAcceptMessage($data);
  56. return $res;
  57. }
  58. }
  59. /**
  60. * 编辑
  61. * @return array
  62. */
  63. public function edit()
  64. {
  65. if (request()->isAjax()) {
  66. $id = input('id', 0);
  67. $model = new ShopAcceptMessageModel();
  68. $data = [
  69. 'mobile' => input('mobile', ''),
  70. 'wx_openid' => input('wx_openid', ''),
  71. 'nickname' => input('nickname', ''),
  72. ];
  73. $res = $model->editShopAcceptMessage($data, [ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  74. return $res;
  75. }
  76. }
  77. /**
  78. * 删除
  79. */
  80. public function delete()
  81. {
  82. if (request()->isAjax()) {
  83. $model = new ShopAcceptMessageModel();
  84. $id = input('id', 0);
  85. $res = $model->deleteShopAcceptMessage([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ]);
  86. return $res;
  87. }
  88. }
  89. /**
  90. * 创建绑定二维码
  91. */
  92. public function createBindQrcode()
  93. {
  94. if (request()->isAjax()) {
  95. $key = 'verify_' . unique_random(6) . $this->site_id;
  96. $wechat = new Wechat($this->site_id);
  97. $res = $wechat->getTempQrcode($key, 600);
  98. if ($res[ 'code' ] != 0) return $res;
  99. return success(0, '', [ 'key' => $key, 'path' => $res[ 'data' ] ]);
  100. }
  101. }
  102. /**
  103. * 获取扫码绑定数据
  104. * @return array
  105. */
  106. public function getBindData()
  107. {
  108. if (request()->isAjax()) {
  109. $key = input('key', '');
  110. $cache = Cache::pull($key);
  111. if ($cache) {
  112. return success(0, '', $cache);
  113. } else {
  114. return error();
  115. }
  116. }
  117. }
  118. }