MemberBasic.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. /**
  34. * 添加快递公司
  35. * @auth false
  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 add()
  43. {
  44. $this->_form($this->table, 'form');
  45. }
  46. /**
  47. * 编辑快递公司
  48. * @auth false
  49. * @throws \think\Exception
  50. * @throws \think\db\exception\DataNotFoundException
  51. * @throws \think\db\exception\ModelNotFoundException
  52. * @throws \think\exception\DbException
  53. * @throws \think\exception\PDOException
  54. */
  55. public function edit()
  56. {
  57. $this->_form($this->table, 'form');
  58. }
  59. /**
  60. * 表单数据处理
  61. * @param array $data
  62. * @auth true
  63. */
  64. protected function _form_filter(&$data)
  65. {
  66. if ($this->request->isPost()) {
  67. if (isset($data['state'])) {
  68. if ($data['state'] == 1) {
  69. $info = Db::name('store_member_basic')->where('id', $data['id'])->find();
  70. $user = Db::name('store_member')->where('id',$info['mid'])->find();
  71. // $member = [
  72. // 'username' => $info['username'],
  73. // 'phone' => $info['phone'],
  74. // 'vip_level' => 0,
  75. // ];
  76. $member = [
  77. 'nickname'=>$info['nickname'],
  78. 'ID_car'=>$info['ID_car'],
  79. 'education'=>$info['education'],
  80. 'age'=>$info['age'],
  81. 'sex'=>$info['sex'],
  82. 'height'=>$info['height'],
  83. 'weight'=>$info['weight'],
  84. 'headimg'=>$info['headimg'],
  85. 'province_id'=>1375,
  86. 'city_id'=>1479,
  87. 'area_id'=>$info['area_id'],
  88. 'username' => $info['username'],
  89. 'phone' => $info['phone'],
  90. 'vip_level' => 0,
  91. ];
  92. if(empty($user['openid'])||$user['phone']){
  93. Db::name('store_member')->where('id', $info['mid'])->update($member);
  94. }
  95. else{
  96. $user2 = Db::name('store_member')->where('phone',$info['phone'])->find();
  97. if(empty($user2)){
  98. Db::name('store_member')->where('id', $info['mid'])->update($member);
  99. }
  100. else{
  101. Db::name('store_member')->where('id', $user2['id'])->update(['openid'=>$user['openid']]);
  102. Db::name('store_member')->where('id', $user['id'])->delete();
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }
  109. }