Agency.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://demo.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  12. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  13. // +----------------------------------------------------------------------
  14. namespace app\user\controller;
  15. use app\common\model\RegionalAgency;
  16. use app\common\model\User;
  17. use app\common\model\UserPartner;
  18. use library\Controller;
  19. use think\Db;
  20. /**
  21. * 区域代理管理
  22. * Class Member
  23. * @package app\Member\controller
  24. */
  25. class Agency extends Controller
  26. {
  27. /**
  28. * 申请列表
  29. * @var string
  30. */
  31. protected $table = 'RegionalAgency';
  32. /**
  33. * 列表
  34. * @auth true
  35. * @menu true
  36. * @throws \think\Exception
  37. * @throws \think\db\exception\DataNotFoundException
  38. * @throws \think\db\exception\ModelNotFoundException
  39. * @throws \think\exception\DbException
  40. * @throws \think\exception\PDOException
  41. */
  42. public function index()
  43. {
  44. $this->search_url = strtolower($this->request->controller()).'/index_search';
  45. $this->title = '申请记录';
  46. $sel_where = [];
  47. $sel_where[] = ['w.is_deleted','=',0];
  48. if($name = $this->request->get('name')) $sel_where[] =['w.true_name','=',$name];
  49. if($phone = $this->request->get('phone')) $sel_where[] =['w.phone','=',$phone];
  50. $query = $this->_query($this->table)
  51. ->alias('w')
  52. ->where($sel_where)
  53. ->field('w.*,m.headimg,m.openid,m.name as m_name')
  54. ->join('store_member m','m.id = w.user_id');
  55. $query->dateBetween('w.create_at')->order('w.id desc')->page();
  56. }
  57. /**
  58. * 数据列表处理
  59. * @auth true
  60. * @menu true
  61. * @param array $data
  62. * @throws \think\db\exception\DataNotFoundException
  63. * @throws \think\db\exception\ModelNotFoundException
  64. * @throws \think\exception\DbException
  65. */
  66. protected function _index_page_filter(&$data)
  67. {
  68. }
  69. /**
  70. * 审核
  71. * @auth true
  72. * @menu true
  73. * @throws \think\Exception
  74. * @throws \think\db\exception\DataNotFoundException
  75. * @throws \think\db\exception\ModelNotFoundException
  76. * @throws \think\exception\DbException
  77. * @throws \think\exception\PDOException
  78. */
  79. public function edit()
  80. {
  81. $this->title = '审核';
  82. $this->_form($this->table, 'form');
  83. }
  84. protected function _form_filter(&$data)
  85. {
  86. if($data['status'] > 0) $data['check_time'] = date('Y-m-d H:i:s');
  87. }
  88. protected function _form_result($id)
  89. {
  90. $apply_info = RegionalAgency::where('id',$id)->find()->toArray();
  91. switch ($apply_info['status']){
  92. case 1:
  93. $user_info = User::field('is_agency,partner_lev,is_partner')->where('id',$apply_info['user_id'])->find() ;
  94. if($user_info->is_agency == 0) {
  95. if($user_info->partner_lev == 0) $user_info->partner_lev = 1;
  96. $user_info->is_agency = 1;
  97. $user_info->is_partner = 1;
  98. $user_info->save();
  99. }
  100. break;
  101. case 2:
  102. $user_info = User::field('is_agency,partner_lev,is_partner')->where('id',$apply_info['user_id'])->find() ;
  103. if($user_info->is_agency > 0) {
  104. $user_info->is_agency = 0;
  105. $user_info->save();
  106. }
  107. break;
  108. }
  109. }
  110. }