MemberBasic.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. namespace app\store\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 会员注册审核管理
  7. * Class Auth
  8. * @package app\store\controller
  9. */
  10. class MemberBasic extends Controller
  11. {
  12. /**
  13. * 绑定数据表
  14. * @var string
  15. */
  16. protected $table = 'store_member_basic';
  17. /**
  18. * 会员注册审核
  19. * @auth true
  20. * @menu true
  21. * @throws \think\Exception
  22. * @throws \think\db\exception\DataNotFoundException
  23. * @throws \think\db\exception\ModelNotFoundException
  24. * @throws \think\exception\DbException
  25. * @throws \think\exception\PDOException
  26. */
  27. public function index()
  28. {
  29. $this->title = '会员注册审核';
  30. $query = $this->_query($this->table)->like('nickname,phone')->equal('state#status');
  31. $query->dateBetween('create_at')->order('id desc')->page();
  32. }
  33. protected function _index_page_filter(&$data)
  34. {
  35. foreach ($data as &$v){
  36. $v['area_id']='临沂'.Db::name('store_area')->where('id',$v['area_id'])->value('name');
  37. }
  38. }
  39. /**
  40. * 添加快递公司
  41. * @auth false
  42. * @throws \think\Exception
  43. * @throws \think\db\exception\DataNotFoundException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @throws \think\exception\DbException
  46. * @throws \think\exception\PDOException
  47. */
  48. public function add()
  49. {
  50. $this->_form($this->table, 'form');
  51. }
  52. /**
  53. * 编辑快递公司
  54. * @auth false
  55. * @throws \think\Exception
  56. * @throws \think\db\exception\DataNotFoundException
  57. * @throws \think\db\exception\ModelNotFoundException
  58. * @throws \think\exception\DbException
  59. * @throws \think\exception\PDOException
  60. */
  61. public function edit()
  62. {
  63. $this->_form($this->table, 'form');
  64. }
  65. /**
  66. * 表单数据处理
  67. * @param array $data
  68. * @auth true
  69. */
  70. protected function _form_filter(&$data)
  71. {
  72. if ($this->request->isPost()) {
  73. if (isset($data['state'])) {
  74. if ($data['state'] == 1) {
  75. $info = Db::name('store_member_basic')->where('id', $data['id'])->find();
  76. $user = Db::name('store_member')->where('id',$info['mid'])->find();
  77. // $member = [
  78. // 'username' => $info['username'],
  79. // 'phone' => $info['phone'],
  80. // 'vip_level' => 0,
  81. // ];
  82. $member = [
  83. 'nickname'=>$info['nickname'],
  84. 'ID_car'=>$info['ID_car'],
  85. 'education'=>$info['education'],
  86. 'age'=>$info['age'],
  87. 'sex'=>$info['sex'],
  88. 'height'=>$info['height'],
  89. 'weight'=>$info['weight'],
  90. 'headimg'=>$info['headimg'],
  91. 'province_id'=>1375,
  92. 'city_id'=>1479,
  93. 'area_id'=>$info['area_id'],
  94. 'username' => $info['username'],
  95. 'phone' => $info['phone'],
  96. 'vip_level' => 0,
  97. ];
  98. if(empty($user['openid'])||$user['phone']){
  99. Db::name('store_member')->where('id', $info['mid'])->update($member);
  100. }
  101. else{
  102. $user2 = Db::name('store_member')->where('phone',$info['phone'])->find();
  103. if(empty($user2)){
  104. Db::name('store_member')->where('id', $info['mid'])->update($member);
  105. }
  106. else{
  107. Db::name('store_member')->where('id', $user2['id'])->update(['openid'=>$user['openid']]);
  108. Db::name('store_member')->where('id', $user['id'])->delete();
  109. }
  110. }
  111. }
  112. }
  113. else{
  114. $this->error('请审核后提交');
  115. }
  116. }
  117. }
  118. }