PushBinding.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace app\adminapi\controller\v1\setting;
  3. use app\adminapi\controller\AuthController;
  4. use Exception;
  5. use think\db\exception\DataNotFoundException;
  6. use think\db\exception\DbException;
  7. use think\db\exception\ModelNotFoundException;
  8. use think\Request;
  9. use crmeb\services\UtilService as Util;
  10. use crmeb\services\QrcodeService;
  11. use app\models\user\User;
  12. use app\models\user\BindUser;
  13. use app\models\system\MerchantDailyReport;
  14. class PushBinding extends AuthController
  15. {
  16. /**
  17. * 生成h5页面二维码
  18. */
  19. public function get_qrcode()
  20. {
  21. try {
  22. $token = time();
  23. // $urlCode = QrcodeService::getQrcodePath('qrcode_' . $this->merId . '_' . time() . '.jpg', '/api/wechat/wxAuth?mer_id=' . $this->merId, false, $this->merId);
  24. $urlCode = QrcodeService::getQrcodePath('qrcode_' . $this->merId . '_' . time() . '.jpg', '/bind/auth.html?token=' . $token . '&mer_id=' . $this->merId, false, $this->merId);
  25. return $this->success(['code_src' => $urlCode]);
  26. } catch (Exception $e) {
  27. return $this->fail('查看推广二维码失败!', ['line' => $e->getLine(), 'meassge' => $e->getMessage()]);
  28. }
  29. }
  30. /**
  31. * 获取绑定推送用户列表
  32. */
  33. public function getBindUserList()
  34. {
  35. $where = Util::getMore([
  36. ['page', 1],
  37. ['limit', 20],
  38. ['nickname', ''],
  39. ]);
  40. $where['mer_id'] = $this->merId ?: '';
  41. return $this->success(BindUser::systemPage($where));
  42. }
  43. /**
  44. * 修改状态
  45. * @param $id
  46. * @param $status
  47. * @return mixed
  48. */
  49. public function set_status($id, $status)
  50. {
  51. if ($status == '' || $id == 0) return $this->fail('参数错误');
  52. BindUser::where(['id' => $id])->update(['status' => $status]);
  53. return $this->success($status == 0 ? '关闭成功' : '开启成功');
  54. }
  55. /**
  56. * 删除指定资源
  57. *
  58. * @param int $id
  59. * @return \think\Response
  60. */
  61. public function delete($id)
  62. {
  63. if (!$id) return $this->fail('数据不存在');
  64. $bindUser = BindUser::get($id);
  65. if (!$bindUser) return $this->fail('数据不存在!');
  66. if ($bindUser['is_del']) return $this->fail('已删除!');
  67. $data['is_del'] = 1;
  68. if (!BindUser::edit($data, $id))
  69. return $this->fail(BindUser::getErrorInfo('删除失败,请稍候再试!'));
  70. else
  71. return $this->success('删除成功!');
  72. }
  73. /**
  74. * 发送商户报表模板消息
  75. */
  76. public function sendMerchantMessage()
  77. {
  78. MerchantDailyReport::sendMerchantMessage();
  79. }
  80. }