Vipsignreply.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Bear
  5. * Date: 2020/3/23
  6. * Time: 下午5:51
  7. */
  8. namespace app\admin\controller\wechat;
  9. use app\common\controller\Backend;
  10. use app\common\library\Redis;
  11. use app\main\constants\AdminConstants;
  12. use app\main\constants\CacheConstants;
  13. use app\main\constants\ErrorCodeConstants;
  14. use app\main\constants\SubscribeDelayConstants;
  15. use app\main\service\AdminService;
  16. use app\main\service\ReplyVipService;
  17. use app\main\service\SubscribeVipDelayService;
  18. use app\main\service\UrlService;
  19. class Vipsignreply extends Backend
  20. {
  21. protected $noNeedRight = ['index'];
  22. public function index()
  23. {
  24. $where = [
  25. 'admin_id' => $this->auth->id,
  26. 'title' => '签到',
  27. ];
  28. $find = model('wechat_autoreply')->where($where)->find();
  29. if ($this->request->isPost()) {
  30. $data = json_decode($this->request->param('data'), true);
  31. $result = ReplyVipService::instance()->createSignReply($data, $this->auth->id);
  32. if ($result->code == ErrorCodeConstants::SUCCESS) {
  33. $this->success();
  34. } else {
  35. $this->error($result->msg);
  36. }
  37. }
  38. if ($find && $find['text_content'] != '') {
  39. $data = json_decode($find['text_content'], true);
  40. if ($data['deploy_type'] == SubscribeDelayConstants::VIP_DEPLOY_GROUP) {
  41. $groupList = model('vip_group')->whereIn('id', $data['admin_group'])->column('id,id,name,createtime,updatetime');
  42. foreach($data['admin_group'] as $groupId){
  43. if (array_key_exists($groupId, $groupList)) {
  44. $data['selected'][$groupId] = $groupList[$groupId];
  45. }
  46. }
  47. }
  48. if ($find['status'] == 'hidden') {
  49. $data['text'] = '[]';
  50. $data['type'] = 1;
  51. }
  52. } else {
  53. $data = [
  54. 'text' => '[]',
  55. 'type' => 1,
  56. 'text_split' => '',
  57. ];
  58. }
  59. $this->assignconfig($data);
  60. return $this->view->fetch();
  61. }
  62. }