Rewardurl.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace app\admin\controller\reward;
  3. use app\common\controller\Backend;
  4. use app\common\library\Rabbitmq;
  5. use think\Controller;
  6. use think\Exception;
  7. use think\Request;
  8. use think\Config;
  9. use think\Cookie;
  10. /**
  11. * 赏金链接管理
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class Rewardurl extends Backend
  16. {
  17. /**
  18. * Rewardurl模型对象
  19. */
  20. protected $model = null;
  21. public function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->model = model('Rewardurl');
  25. $this->view->assign("contactTypeList", $this->model->getContactTypeList());
  26. $this->assignconfig("contactTypeList", $this->model->getContactTypeList());
  27. }
  28. /**
  29. * 查看
  30. */
  31. public function index()
  32. {
  33. //设置过滤方法
  34. $this->request->filter(['strip_tags']);
  35. $info = $this->model->where(['admin_id' => $this->auth->id])->find();
  36. if($info){
  37. $this->assignconfig("info",$info);
  38. }
  39. if ($this->request->isAjax())
  40. {
  41. //如果发送的来源是Selectpage,则转发到Selectpage
  42. if ($this->request->request('pkey_name'))
  43. {
  44. return $this->selectpage();
  45. }
  46. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  47. $total = $this->model
  48. ->where($where)
  49. ->order($sort, $order)
  50. ->count();
  51. $list = $this->model
  52. ->where($where)
  53. ->order($sort, $order)
  54. ->limit($offset, $limit)
  55. ->select();
  56. $result = array("total" => $total, "rows" => $list);
  57. return json($result);
  58. }
  59. return $this->view->fetch();
  60. }
  61. /**
  62. * 添加
  63. */
  64. public function add()
  65. {
  66. if ($this->request->isPost())
  67. {
  68. $params = $this->request->post("");
  69. if ($params)
  70. {
  71. try
  72. {
  73. $params['admin_id'] = $this->auth->id;
  74. // $params['url'] = "http://www.mp.koread.cn/admin/reward/inviterecord/agentapply?referid=";
  75. $params['url'] = Config::get('site.scheme').'://'.Config::get('site.url_root').'/admin/reward/inviterecord/agentapply?referid=';
  76. $params['url'] .= $this->auth->id;
  77. $info = $this->model->where(['admin_id' => $this->auth->id])->find();
  78. if($info){
  79. $params['updatetime'] = time();
  80. $result = $this->model->where("id={$info['id']}")->update($params);
  81. }else{
  82. $params['createtime'] = time();
  83. $result = $this->model->create($params);
  84. }
  85. if ($result !== false)
  86. {
  87. try
  88. {
  89. $this->success('',null,$params);
  90. }
  91. catch (Exception $e)
  92. {
  93. $this->error($e->getMessage());
  94. }
  95. }
  96. else
  97. {
  98. $this->error($this->model->getError());
  99. }
  100. }
  101. catch (Exception $e)
  102. {
  103. $this->error($e->getMessage());
  104. }
  105. }
  106. $this->error(__('Parameter %s can not be empty', ''));
  107. }
  108. }
  109. /**
  110. * 修改
  111. */
  112. public function change()
  113. {
  114. $row = $this->model->where(['admin_id' => $this->auth->id])->find();
  115. if (!$row)
  116. $this->error(__('No Results were found'));
  117. return json($row);
  118. }
  119. /**
  120. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
  121. * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
  122. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  123. */
  124. }