ActivityHx.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. namespace app\operate\controller;
  3. use app\common\model\ActivityPrice;
  4. use app\common\model\ActivitySponsor;
  5. use app\common\model\ActivityTemplate;
  6. use app\common\model\ChinaArea;
  7. use app\common\model\DatumIntro;
  8. use app\common\model\User;
  9. use library\Controller;
  10. use think\Db;
  11. /**
  12. * 活动
  13. * Class ActivityHx
  14. * @package app\operate\controller
  15. */
  16. class ActivityHx extends Controller
  17. {
  18. protected $table = 'StoreMember';
  19. /**
  20. * 列表
  21. * @auth true
  22. * @menu true
  23. * @throws \think\Exception
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. * @throws \think\exception\PDOException
  28. */
  29. public function index()
  30. {
  31. $this->title = '核销管理';
  32. $where = [];
  33. $where[] = ['m.is_deleted','=',0];
  34. $where[] = ['m.is_hx','=',1];
  35. if($name = input('get.name')) $where[] = ['m.name','like','%'.$name.'%'];
  36. if($phone = input('get.phone')) $where[] = ['m.phone','like','%'.$phone.'%'];
  37. $field="m.id,m.openid,m.name,m.is_first,m.headimg,m.level_exp,m.phone,m.status,m.create_at,m.account_type";
  38. $query = $this->_query($this->table)
  39. ->field($field)
  40. ->alias('m')
  41. ->where($where)
  42. ->order('id desc')->page();
  43. }
  44. /**
  45. * 添加
  46. * @auth true
  47. * @menu true
  48. * @throws \think\Exception
  49. * @throws \think\db\exception\DataNotFoundException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. * @throws \think\exception\DbException
  52. * @throws \think\exception\PDOException
  53. */
  54. public function add()
  55. {
  56. $this->title = '添加';
  57. if($this->request->post()) {
  58. $phone = input('phone');
  59. $user_info = User::where('phone',$phone)->find();
  60. if(empty($user_info))$this->error('用户不存在');
  61. if($user_info->is_deleted || !$user_info->status) $this->error('用户已禁用');
  62. User::where('id',$user_info->id)->update(['is_hx'=>1]);
  63. $this->success('添加成功');
  64. }
  65. $this->_form($this->table, 'form');
  66. }
  67. /**
  68. * 删除
  69. * @auth true
  70. * @throws \think\Exception
  71. * @throws \think\exception\PDOException
  72. */
  73. public function del()
  74. {
  75. $this->_save($this->table, ['is_hx' => '0']);
  76. $this->success('删除成功');
  77. }
  78. /**
  79. * 删除
  80. * @auth true
  81. * @throws \think\Exception
  82. * @throws \think\exception\PDOException
  83. */
  84. public function remove()
  85. {
  86. $this->_save($this->table, ['is_hx' => '0']);
  87. }
  88. }