UuidRelation.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\model;
  3. use think\Model;
  4. class UuidRelation extends Model
  5. {
  6. protected $connection = 'mysql';
  7. protected $pk = 'id';
  8. protected $name = 'uuid_relation';
  9. public static function getuuid($uid, $ptype)
  10. {
  11. $query = self::where(['weid' => weid(), 'ptype' => $ptype, 'uid' => $uid])->whereNotNull('uuid')->where('uuid','<>', '');
  12. $mob = $query->order('id desc')->find();
  13. if (!empty($mob)) {
  14. return $mob->uuid;
  15. } else {
  16. if (empty($uuid)) {
  17. $Membermob = new Member;
  18. $memberinfo = $Membermob->getUserByWechat();
  19. $uuid = $memberinfo['uuid'];
  20. if (!empty($memberinfo) && empty($uuid)) {
  21. if ($ptype == 'technical') {
  22. $Technical = \app\model\Technical::where('uid', $memberinfo['id'])->find();
  23. $uuid = $Technical->uuid;
  24. }
  25. if ($ptype == 'store') {
  26. $Store = \app\model\Store::where('uid', $memberinfo['id'])->find();
  27. $uuid = $Store->uuid;
  28. }
  29. if ($uuid) {
  30. UuidRelation::create(['weid' => weid(), 'ptype' => $ptype, 'uuid' => $uuid, 'uid' => $memberinfo['id']]);
  31. }
  32. $data['api'] = Author()::getlan();
  33. }
  34. }
  35. return $uuid;
  36. }
  37. }
  38. public static function getuid($uuid)
  39. {
  40. $query = self::where(['weid' => weid(), 'uuid' => $uuid]);
  41. $mob = $query->order('id desc')->find();
  42. if (!empty($mob)) {
  43. return $mob->uid;
  44. }
  45. }
  46. }