User.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. *
  4. * @copyright ©2020 点小铺
  5. * @author hanj
  6. * @link: https://dyuit.com
  7. * Created by VSCode
  8. */
  9. namespace app\admin\model\store;
  10. use app\common\model\store\User as StoreUserModel;
  11. /**
  12. * 商家用户模型
  13. * Class StoreUser
  14. * @package app\admin\model
  15. */
  16. class User extends StoreUserModel
  17. {
  18. /**
  19. * 新增商家用户记录
  20. * @param $wxapp_id
  21. * @param $data
  22. * @return bool|false|int
  23. */
  24. public function add($wxapp_id, $data)
  25. {
  26. if (self::checkExist($data['user_name'])) {
  27. $this->error = '商家用户名已存在';
  28. return false;
  29. }
  30. return $this->save([
  31. 'user_name' => $data['user_name'],
  32. 'password' => dyu_hash($data['password']),
  33. 'wxapp_id' => $wxapp_id,
  34. ]);
  35. }
  36. /**
  37. * 商家用户登录
  38. * @param $wxapp_id
  39. * @throws \think\Exception
  40. * @throws \think\exception\DbException
  41. */
  42. public function login($wxapp_id)
  43. {
  44. // 验证用户名密码是否正确
  45. $user = self::detail(['wxapp_id' => $wxapp_id], ['wxapp']);
  46. $this->loginState($user);
  47. }
  48. }