MemberUniqueModel.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 17/2/23
  6. * Time: 上午10:42
  7. */
  8. /**
  9. * 微信开放平台Unionid表
  10. */
  11. namespace app\frontend\modules\member\models;
  12. use app\backend\models\BackendModel;
  13. use app\common\traits\ReplaceableModelTrait;
  14. class MemberUniqueModel extends BackendModel
  15. {
  16. use ReplaceableModelTrait;
  17. public $table = 'yz_member_unique';
  18. public $dateFormat = 'U';
  19. protected $guarded = [''];
  20. protected $primaryKey = 'unique_id';
  21. /**
  22. * 检查是否存在unionid
  23. *
  24. * @param $uniacid
  25. * @param $unionid
  26. * @return mixed
  27. */
  28. public static function getUnionidInfo($uniacid, $unionid)
  29. {
  30. return self::uniacid()
  31. ->where('unionid', $unionid)
  32. ->orderby('unique_id', 'desc');
  33. }
  34. public static function getUnionidInfoByMemberId($uniacid, $member_id)
  35. {
  36. return self::where('uniacid', $uniacid)
  37. ->where('member_id', $member_id)
  38. ->orderby('unique_id', 'desc');
  39. }
  40. /**
  41. * 添加数据
  42. *
  43. * @param $data
  44. */
  45. public static function insertData($data)
  46. {
  47. $default = array(
  48. 'uniacid' => 0,
  49. 'unionid' => 0,
  50. 'member_id' => 0,
  51. 'type' => '',
  52. 'created_at' => time()
  53. );
  54. $data = array_merge($default, $data);
  55. return self::create($data);
  56. }
  57. /**
  58. * 更新登录类型
  59. *
  60. * @param $data
  61. */
  62. public static function updateData($data)
  63. {
  64. self::where('unique_id', $data['unique_id'])
  65. ->update(['type'=>$data['type']]);
  66. }
  67. }